googleapis / googleapis/java-genai

Feature Request: Public API to initialize Chat with history

Open
#819 1 comment 0 reactions 1 assignee Claimed by @hemasekhar-p View on GitHub
type: feature request
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.