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
+2 -1
View File
@@ -142,7 +142,7 @@ async def test_rounds(state: ReplState) -> None:
assert state.agent.max_rounds == 40
async def test_status_shows_context_chars(
async def test_status_shows_context_tokens(
state: ReplState, capsys: pytest.CaptureFixture[str]
) -> None:
from plyngent.lmproto.openai_compatible.model import UserChatMessage
@@ -150,6 +150,7 @@ async def test_status_shows_context_chars(
state.agent.messages = [UserChatMessage(content="hello")]
assert await handle_slash(state, "/status") is True
out = capsys.readouterr().out
assert "context_tokens~=" in out
assert "context_chars=" in out
assert "tool_result_max=" in out
assert str(state.workspace) in out