Compact screenshot context every 4 steps by default
This commit is contained in:
@@ -98,3 +98,21 @@ def test_press_key_supports_hotkey_combo(tmp_path: Path, monkeypatch) -> None:
|
||||
assert result["key"] == "win+r"
|
||||
assert result["message"] == "Key combo executed."
|
||||
assert agent_module.pyautogui.last_hotkey == ("win", "r")
|
||||
|
||||
|
||||
def test_context_compaction_trigger_and_payload(tmp_path: Path, monkeypatch) -> None:
|
||||
agent = _build_agent(tmp_path, monkeypatch)
|
||||
agent.objective = "Open settings app"
|
||||
agent.previous_response_id = "resp_123"
|
||||
agent.step = 4
|
||||
agent.last_context_compact_step = 0
|
||||
agent.options.screen_context_decay_steps = 4
|
||||
agent.recent_tool_summaries = ["step=1 tool=see_screen status=ok"]
|
||||
agent.last_screen_data_url = "data:image/png;base64,abc"
|
||||
agent.last_screen_meta = {"width": 1280, "height": 720, "path": "C:/tmp/frame.png"}
|
||||
|
||||
assert agent._should_compact_context() is True
|
||||
compacted = agent._build_compacted_pending_input()
|
||||
assert len(compacted) == 2
|
||||
assert "Context compaction activated" in compacted[0]["content"][0]["text"]
|
||||
assert "Open settings app" in compacted[0]["content"][0]["text"]
|
||||
|
||||
Reference in New Issue
Block a user