Coverage for src/lilbee/app/agent_configs/window.py: 100%
4 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-08-14 11:46 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-08-14 11:46 +0000
1"""The chat window an agent client needs, shared by the launchers and `lilbee agent-config`."""
3from __future__ import annotations
5# Floor on the served chat window for an agent client. Agents open with a large
6# baseline prompt (system prompt, tool schemas, agent instructions): opencode's
7# first turn measures ~32k tokens and Claude Code's ~47k, plus reserved output.
8# The RAM-derived chat_n_ctx_target default is smaller on most hosts, so a
9# window below this floor rejects the first message. hermes also refuses a
10# window under 64000. The dynamic picker still clamps to the model's trained
11# context and device memory, so asking for the floor never over-allocates.
12AGENT_CHAT_CTX_FLOOR = 65536
15def agent_chat_ctx_target(configured: int) -> int:
16 """Lift a configured chat-context target to the agent floor, never lowering a larger one."""
17 return max(configured, AGENT_CHAT_CTX_FLOOR)