Skip to content

Feature Request: Public API to initialize Chat with history #819

Closed as not planned

Description

@vorburger

Currently, the Chat API in google-genai (Java SDK) does not expose a way to initialize a Chat session with an existing history of messages (e.g., loaded from persistent storage).

When reloading a session from disk (e.g. JSON/YAML), developers currently have to work around this limitation by either:

  1. Re-sending all previous messages to the model, which is slow and consumes tokens.
  2. Using reflection to manually populate the private comprehensiveHistory and curatedHistory fields in ChatBase, which is fragile and not recommended.

It would be very beneficial to have a public API (e.g., an overload of Chats.create() or a builder method) that accepts an initial List<Content> to restore the conversation state.

Activity

  1. self-assigned this
    on Feb 9, 2026
  2. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Feb 9, 2026
  3. hemasekhar-p commented on Feb 11, 2026

    @hemasekhar-p

    Hi @vorburger, Thanks for raising this Feature request. After reviewing the current java-genai SDK documentation and source code, there is no public API available to initialize a Chat instance with pre-existing history. we'll be filing a feature request to track this internally.

  4. vorburger commented on Oct 4, 2026

    @vorburger
    ContributorAuthor

    This might not actually be required anymore with the Interactions API... I'm looking into whether I'll close this.

    @hemasekhar-p do you want to assign this issue to me?

  5. vorburger commented on Oct 8, 2026

    @vorburger
    ContributorAuthor

    With the move to the Interactions API, this isn't really required anymore; I'm therefore closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions