LLMChatSession
class in package klyn.llm

    public class LLMChatSession extends Object:

Object
└ LLMChatSession

High-level chat session with history, tool-calling and optional compaction.

Properties

Modifier and Type | Member | Description
--- | --- | ---
public readonly property | contextLengthTokens `contextLengthTokens as Int:` | Configured context length in tokens.
public readonly property | contextUsagePercent `contextUsagePercent as Int:` | Last known context usage percentage, capped to 100.
public readonly property | lastCompletionTokens `lastCompletionTokens as Int:` | Last completion token count reported by the provider.
public readonly property | lastPromptTokens `lastPromptTokens as Int:` | Last prompt token count reported by the provider.
public readonly property | lastTotalTokens `lastTotalTokens as Int:` | Last total token count reported by the provider.

Properties inherited from Object: type
Constructors

Modifier and Type | Member | Description
--- | --- | ---
public | LLMChatSession `LLMChatSession(provider as Object):` | Creates a session bound to one provider.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public | ask `ask(prompt as String) as String throws Exception:` | Sends one user prompt and returns the final assistant answer.
public | consumeCompactionFlag `consumeCompactionFlag() as Boolean:` | Returns and clears the compaction flag.
public | thread `thread() as ArrayList:` | Returns the current thread history.
public | withCompactionObserver `withCompactionObserver(observer as LLMCompactionObserver) as LLMChatSession:` | Attaches an observer notified before the context compactor starts.
public | withCompactor `withCompactor(strategy as String, threshold as Int) as LLMChatSession:` | Configures context compaction.
public | withContextWindow `withContextWindow(contextLengthTokens as Int, compactAtPercent as Int = 90) as LLMChatSession:` | Configures token-based context accounting.
public | withMaxToolCalls `withMaxToolCalls(limit as Int) as LLMChatSession:` | Configures the maximum number of tool calls.
public | withSystem `withSystem(systemPrompt as String) as LLMChatSession:` | Sets or replaces the system prompt.
public | withToolCallObserver `withToolCallObserver(observer as LLMToolCallObserver) as LLMChatSession:` | Attaches an observer notified around every requested tool call.
public | withTools `withTools(tools as ToolRegistry) as LLMChatSession:` | Attaches a tool registry.

Methods inherited from Object: fromJson, toDict, toJson, toString, toXml