public class LLMChatSession extends Object:
High-level chat session with history, tool-calling and optional compaction.
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | contextLengthTokenscontextLengthTokens as Int: |
Configured context length in tokens. |
| public readonly property | contextUsagePercentcontextUsagePercent as Int: |
Last known context usage percentage, capped to 100. |
| public readonly property | lastCompletionTokenslastCompletionTokens as Int: |
Last completion token count reported by the provider. |
| public readonly property | lastPromptTokenslastPromptTokens as Int: |
Last prompt token count reported by the provider. |
| public readonly property | lastTotalTokenslastTotalTokens as Int: |
Last total token count reported by the provider. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | LLMChatSessionLLMChatSession(provider as Object): |
Creates a session bound to one provider. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | ask | Sends one user prompt and returns the final assistant answer. |
| public | consumeCompactionFlagconsumeCompactionFlag() as Boolean: |
Returns and clears the compaction flag. |
| public | threadthread() as ArrayList: |
Returns the current thread history. |
| public | withCompactionObserverwithCompactionObserver(observer as LLMCompactionObserver) as LLMChatSession: |
Attaches an observer notified before the context compactor starts. |
| public | withCompactorwithCompactor(strategy as String, threshold as Int) as LLMChatSession: |
Configures context compaction. |
| public | withContextWindowwithContextWindow(contextLengthTokens as Int, compactAtPercent as Int = 90) as LLMChatSession: |
Configures token-based context accounting. |
| public | withMaxToolCallswithMaxToolCalls(limit as Int) as LLMChatSession: |
Configures the maximum number of tool calls. |
| public | withSystemwithSystem(systemPrompt as String) as LLMChatSession: |
Sets or replaces the system prompt. |
| public | withToolCallObserverwithToolCallObserver(observer as LLMToolCallObserver) as LLMChatSession: |
Attaches an observer notified around every requested tool call. |
| public | withToolswithTools(tools as ToolRegistry) as LLMChatSession: |
Attaches a tool registry. |