klyn.llm.LLMChatSession.withContextWindow
method

    public withContextWindow(contextLengthTokens as Int, compactAtPercent as Int = 90) as LLMChatSession:

Description

Configures token-based context accounting.

`contextLengthTokens` is the model context window. When a compactor is configured, the session compacts after a response whose reported `usage.total_tokens` reaches `compactAtPercent`.

    session = LLMChatSession(provider) \
    .withContextWindow(200000, 90) \
    .withCompactor("Summarize the useful context.", 0)