core/agent+config: soft context budget in estimated tokens

Replace max_context_chars with max_context_tokens (default 200k est.
tokens via char/4); compact and /status use the token budget.
This commit is contained in:
2026-07-15 10:58:01 +08:00
parent d2cab4198b
commit 58041c6c87
13 changed files with 59 additions and 45 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ def test_soft_compact_transcript_shrinks_tools() -> None:
ToolChatMessage(content=big, tool_call_id="1"),
ToolChatMessage(content="recent", tool_call_id="2"),
]
out = soft_compact_transcript(messages, max_chars=500)
out = soft_compact_transcript(messages, max_tokens=100)
assert "truncated" in out or len(out) < len(big) + 50
assert "recent" in out