Skip to content

The agent that grows with you

Merge remote-tracking branch 'origin/main' into agent/81234-merge-20260821

poisdahla5b326a471d2
diff --cc tests/agent/test_reference_handoff_active_turn.py
index 45df7c76b62,49767bc8f35..fcb90977562
--- a/tests/agent/test_reference_handoff_active_turn.py
+++ b/tests/agent/test_reference_handoff_active_turn.py
@@@ -16,10 -14,12 +16,13 @@@ from agent.context_compressor import
COMPRESSED_SUMMARY_HAS_USER_TURN_KEY,
COMPRESSED_SUMMARY_METADATA_KEY,
COMPRESSION_CONTINUATION_USER_CONTENT,
+ ContextCompressor,
HISTORICAL_TASK_HEADING,
SUMMARY_PREFIX,
+ _MERGED_PRIOR_CONTEXT_HEADER,
+ _MERGED_SUMMARY_DELIMITER,
_SUMMARY_END_MARKER,
+ history_before_user_originated_turn,
is_compaction_summary_message,
is_user_originated_turn,
reference_handoff_would_drive_next_model_call,
@@@ -46,12 -42,29 +49,35 @@@ def _standalone_handoff(task: str = "fi
}
+def _composite_handoff(ask: str = "REAL ASK") -> dict:
+ handoff = _standalone_handoff()
+ handoff["content"] += f"\n\n{ask}"
+ return handoff
+
+
+ def _merged_assistant_carrier(
+ *, finish_reason: str = "stop", tool_calls: list[dict] | None = None
+ ) -> dict:
+ """Production merge-into-tail shape with the carrier's completion state."""
+ carrier = {
+ "role": "assistant",
+ "content": (
+ f"{_MERGED_PRIOR_CONTEXT_HEADER}\n"
+ "Refactor complete.\n\n"
+ f"{_MERGED_SUMMARY_DELIMITER}\n"
+ f"{SUMMARY_PREFIX}\n{HISTORICAL_TASK_HEADING}\n"
+ "User asked: 'finish the already-done refactor'\n\n"
+ f"{_SUMMARY_END_MARKER}"
+ ),
+ "finish_reason": finish_reason,
+ COMPRESSED_SUMMARY_METADATA_KEY: True,
+ COMPRESSED_SUMMARY_HAS_USER_TURN_KEY: True,
+ }
+ if tool_calls is not None:
+ carrier["tool_calls"] = tool_calls
+ return carrier
+
+
class TestReferenceHandoffWouldDriveNextModelCall:
def test_standalone_handoff_alone_drives(self):
messages = [_standalone_handoff()]