Skip to content

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

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

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