Skip to content

The agent that grows with you

test(agent): fold todo_list hydration regression into TestHydrateTodoStore

kshitijk4poor05254937a429
diff --git a/tests/agent/test_run_agent.py b/tests/agent/test_run_agent.py
index 00c16454b60..5e47fbb0451 100644
--- a/tests/agent/test_run_agent.py
+++ b/tests/agent/test_run_agent.py
@@ -720,7 +720,7 @@ class TestInit:
class TestHydrateTodoStore:
@staticmethod
- def _assistant_todo_call(call_id="c1"):
+ def _assistant_todo_call(call_id="c1", name="todo", arguments="{}"):
return {
"role": "assistant",
"content": None,
@@ -728,11 +728,32 @@ class TestHydrateTodoStore:
{
"id": call_id,
"type": "function",
- "function": {"name": "todo", "arguments": "{}"},
+ "function": {"name": name, "arguments": arguments},
}
],
}
+ @pytest.mark.parametrize(
+ "name,arguments",
+ [
+ ("todo_list", "{}"),
+ ("tool_call", json.dumps({"calls": [{"name": "todo_list", "arguments": {}}]})),
+ ],
+ ids=["direct", "bridged"],
+ )
+ def test_todo_list_name_hydrates(self, agent, name, arguments):
+ """Regression for #124960: the current name and its tool_call-bridged form pair like legacy ``todo``."""
+ todos = [{"id": "t", "content": "Task", "status": "pending"}]
+ history = [
+ self._assistant_todo_call(name=name, arguments=arguments),
+ {"role": "tool", "tool_call_id": "c1", "content": json.dumps({"todos": todos, "revision": 3})},
+ ]
+
+ with patch("run_agent._set_interrupt"), patch("agent.interrupt_control._set_interrupt"):
+ agent._hydrate_todo_store(history)
+
+ assert agent._todo_store.snapshot() == {"todos": todos, "revision": 3}
+
def test_no_todo_in_history(self, agent):
history = [
{"role": "user", "content": "hello"},
diff --git a/tests/agent/test_todo_history_canonicalization_124960.py b/tests/agent/test_todo_history_canonicalization_124960.py
deleted file mode 100644
index 54840b93ad6..00000000000
--- a/tests/agent/test_todo_history_canonicalization_124960.py
+++ /dev/null
@@ -1,68 +0,0 @@
-"""Regression for #124960: Todo history pairing follows dispatch canonicalization."""
-
-import json
-from unittest.mock import patch
-
-from model_tools import _LEGACY_TOOL_ALIASES
-from run_agent import AIAgent
-from tools.todo_tool import TODO_SCHEMA, TodoStore
-
-
-def _agent() -> AIAgent:
- agent = object.__new__(AIAgent)
- agent.quiet_mode = True
- agent._todo_store = TodoStore()
- return agent
-
-
-def _assistant_call(name: str, call_id: str = "todo-call") -> dict:
- return {
- "role": "assistant",
- "content": None,
- "tool_calls": [{
- "id": call_id,
- "type": "function",
- "function": {"name": name, "arguments": "{}"},
- }],
- }
-
-
-def test_current_todo_list_name_hydrates_eleven_items_across_turns():
- todos = [
- {"id": str(index), "content": f"Task {index}", "status": "pending"}
- for index in range(11)
- ]
- history = [
- _assistant_call(TODO_SCHEMA["name"]),
- {
- "role": "tool",
- "tool_call_id": "todo-call",
- "content": json.dumps({"todos": todos, "revision": 7}),
- },
- ]
- agent = _agent()
-
- with patch("run_agent._set_interrupt"):
- agent._hydrate_todo_store(history)
-
- assert agent._todo_store.snapshot() == {"todos": todos, "revision": 7}
-
-
-def test_history_pairing_uses_the_same_alias_table_as_dispatch(monkeypatch):
- synthetic_alias = "legacy_todo_probe"
- monkeypatch.setitem(_LEGACY_TOOL_ALIASES, synthetic_alias, TODO_SCHEMA["name"])
-
- assert AIAgent._assistant_has_todo_tool_call(
- _assistant_call(synthetic_alias), "todo-call"
- )
-
-
-def test_unrelated_alias_and_wrong_call_id_remain_rejected(monkeypatch):
- monkeypatch.setitem(_LEGACY_TOOL_ALIASES, "legacy_reader_probe", "read_file")
-
- assert not AIAgent._assistant_has_todo_tool_call(
- _assistant_call("legacy_reader_probe"), "todo-call"
- )
- assert not AIAgent._assistant_has_todo_tool_call(
- _assistant_call(TODO_SCHEMA["name"]), "different-call"
- )