googleapis / googleapis/java-genai
Feature Request: Public API to initialize Chat with history
- Dominant language
- Java
- Stars
- 397
- Forks
- 125
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 41
Description
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` to restore the conversation state.
Contributor guide
Assessment
This issue has not been assessed yet.