Skip to content

Commit 16bcebf

Browse files
committed
test(core): add strategy-level tool trajectory regression test
Add test_summarization_strategy_preserves_tool_trajectory_in_summary_input, matching the issue #8086 triage reproduction: a recording summarizer runs over a tool call/result pair with a named function, JSON arguments, and a shared call id, and the summarizer transcript must carry the tool name, arguments, result, and call id. Red against main (transcript contains only function_call / function_result placeholders) and green with the summarizer input fix. All 94 tests in tests/core/test_compaction.py pass; ruff clean.
1 parent c4842d0 commit 16bcebf

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎python/packages/core/tests/core/test_compaction.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,35 @@ async def test_summarization_strategy_bounds_summary_input_to_complete_groups()
916916
assert oversized_message.message_id not in summarized_message_ids
917917

918918

919+
async def test_summarization_strategy_preserves_tool_trajectory_in_summary_input() -> None:
920+
summarizer = _RecordingSummarizer()
921+
messages = [
922+
Message(role="user", contents=["use the tool"]),
923+
_assistant_function_call("call_1"),
924+
_tool_result("call_1", "ok"),
925+
Message(role="assistant", contents=["tool completed"]),
926+
Message(role="user", contents=["what next"]),
927+
Message(role="assistant", contents=["here is the follow-up"]),
928+
]
929+
strategy = SummarizationStrategy(
930+
client=summarizer, # type: ignore[arg-type] # pyrefly: ignore[bad-argument-type] # ty: ignore[invalid-argument-type]
931+
target_count=2,
932+
threshold=0,
933+
)
934+
annotate_message_groups(messages)
935+
936+
changed = await strategy(messages)
937+
938+
assert changed is True
939+
assert len(summarizer.requests) == 1
940+
summary_request_text = summarizer.requests[0][1].text
941+
assert summary_request_text is not None
942+
assert "tool" in summary_request_text
943+
assert '{"value":"x"}' in summary_request_text
944+
assert "[call_id=call_1]" in summary_request_text
945+
assert "ok" in summary_request_text
946+
947+
919948
async def test_summarization_strategy_skips_oversized_first_group() -> None:
920949
summarizer = _RecordingSummarizer()
921950
messages = [

0 commit comments

Comments
 (0)