feat(webui): visualize context usage by logical round (#5649)
* feat(webui): visualize per-request context reuse * refactor(webui): report usage by logical round * fix(webui): align context chart with logical rounds * refactor(webui): derive turn usage from logical rounds * fix(webui): polish context usage details
This commit is contained in:
1 parent
8fb7bc34ec
commit
6b82d642fc
35 files changed
+994
-274
No files matched your search
@@ -629,6 +629,7 @@ async def test_runner_uses_no_tools_finalization_after_max_iterations():
|
||||
arguments={"path": "."},
|
||||
)
|
||||
],
|
||||
usage=LLMUsage.reported(input_tokens=1, output_tokens=1),
|
||||
)
|
||||
return LLMResponse(
|
||||
content="Read the directory twice. More investigation remains.",
|
||||
@@ -660,6 +661,14 @@ async def test_runner_uses_no_tools_finalization_after_max_iterations():
|
||||
assert calls[-1]["tools"] is None
|
||||
assert "tool-call budget" in calls[-1]["messages"][-1]["content"]
|
||||
assert tools.execute.await_count == 2
|
||||
assert result.usage is not None
|
||||
assert result.usage.input_tokens == 12
|
||||
assert result.usage.output_tokens == 9
|
||||
assert [(item.input_tokens, item.output_tokens) for item in result.round_usages] == [
|
||||
(1, 1),
|
||||
(1, 1),
|
||||
(10, 7),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -914,6 +923,11 @@ async def test_runner_retries_empty_final_response_with_summary_prompt():
|
||||
assert result.usage is not None
|
||||
assert result.usage.input_tokens == 13
|
||||
assert result.usage.output_tokens == 9
|
||||
assert [(item.input_tokens, item.output_tokens) for item in result.round_usages] == [
|
||||
(5, 1),
|
||||
(5, 1),
|
||||
(3, 7),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -1258,6 +1272,13 @@ async def test_runner_accumulates_usage_and_preserves_cache_reads():
|
||||
assert result.usage.cache_read_tokens == 230 # 80 + 150
|
||||
assert result.usage.context_tokens == 200
|
||||
assert result.usage.request_count == 2
|
||||
assert [
|
||||
(item.input_tokens, item.cache_read_tokens)
|
||||
for item in result.round_usages
|
||||
] == [
|
||||
(100, 80),
|
||||
(200, 150),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in new issue
Block a user