-
-
Notifications
You must be signed in to change notification settings - Fork 52
fix: apply_plan() flattens multiple tool call results #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6792576
83fc482
a35c4fe
8096e0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,6 +37,45 @@ def test_memory_entry_str(self): | |||||||||||||||||||||||||||||||||||
| assert "Test content" in str_repr | ||||||||||||||||||||||||||||||||||||
| assert "observation" in str_repr | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def test_memory_entry_str_with_list_of_dicts(self): | ||||||||||||||||||||||||||||||||||||
| """Test MemoryEntry string representation with list values (e.g. tool_calls).""" | ||||||||||||||||||||||||||||||||||||
| mock_agent = Mock() | ||||||||||||||||||||||||||||||||||||
| content = { | ||||||||||||||||||||||||||||||||||||
| "action": [ | ||||||||||||||||||||||||||||||||||||
| {"name": "move_one_step", "response": "moved"}, | ||||||||||||||||||||||||||||||||||||
| {"name": "arrest_citizen", "response": "arrested"}, | ||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| entry = MemoryEntry(content=content, step=1, agent=mock_agent) | ||||||||||||||||||||||||||||||||||||
| str_repr = str(entry) | ||||||||||||||||||||||||||||||||||||
| assert "move_one_step" in str_repr | ||||||||||||||||||||||||||||||||||||
| assert "arrest_citizen" in str_repr | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| def test_memory_entry_str_with_nested_tool_calls_list(self): | |
| """Test MemoryEntry string representation with nested tool_calls list under action.""" | |
| mock_agent = Mock() | |
| content = { | |
| "action": { | |
| "tool_calls": [ | |
| {"name": "move_one_step", "response": "moved"}, | |
| {"name": "arrest_citizen", "response": "arrested"}, | |
| ] | |
| } | |
| } | |
| entry = MemoryEntry(content=content, step=1, agent=mock_agent) | |
| str_repr = str(entry) | |
| assert "move_one_step" in str_repr | |
| assert "arrest_citizen" in str_repr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list handling added here only applies when a
listis a direct value at the top level ofMemoryEntry.content. However, in the actual data path fromapply_plan(), the memory entry content will be{"action": {"tool_calls": [...]}}— the list is nested inside the"tool_calls"key of a dict. Whenformat_nested_dictencounters this list, it falls through to theelsebranch (line 39-41) and renders it as a raw Python list string, not using the new tree formatting.To properly handle this,
format_nested_dictshould also handlelistvalues, similar to the handling added at lines 53-59. Otherwise the nice tree display only works for the synthetic test case, not the real data structure produced by the fix inllm_agent.py.