Skip to content

Commit

Permalink
fix bad function call that caused lab API 400s (#38)
Browse files Browse the repository at this point in the history
- We saw lab api 400s like this run:
https://mp4-server.koi-moth.ts.net/run/#231315/ss
- The fix is to have the error message be a function turn as opposed to
a user turn
- Here's an agent run with the fix branching from the agent state before
the error in the previous run:
https://mp4-server.koi-moth.ts.net/run/#244894/e=8532127042727147,sg,uq
- Here's another branch from the same place but using an anthropic
model: https://mp4-server.koi-moth.ts.net/run/#244895/uq
  • Loading branch information
amydeng2000 authored Jan 29, 2025
1 parent 419ed60 commit 71ce715
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions modules/actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ async def get_result_message_simple(agent: Agent) -> Optional[Message]:
output = ""
if tool_name not in agent.toolkit_dict:
return Message(
role="user",
role="function",
content=reject_command_prompt,
name=tool_name,
function_call=None,
)

Expand All @@ -35,8 +36,9 @@ async def get_result_message_simple(agent: Agent) -> Optional[Message]:
if not tool_params:
if agent_args:
return Message(
role="user",
role="function",
content=reject_arguments_prompt,
name=tool_name,
function_call=None,
)
return Message(
Expand All @@ -52,15 +54,17 @@ async def get_result_message_simple(agent: Agent) -> Optional[Message]:
output = await tool_fn(agent.state, **agent_args)
except TypeError:
return Message(
role="user",
role="function",
content=reject_arguments_prompt,
name=tool_name,
function_call=None,
)
)
elif len(required_args) != 1:
# tell agent the command failed
return Message(
role="user",
role="function",
content=reject_arguments_prompt,
name=tool_name,
function_call=None,
)
else:
Expand Down
3 changes: 2 additions & 1 deletion tests/modules/test_actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ async def async_tool_fn(*args, **kwargs):
TOOL_OBJECT_NO_ARGS,
{"name": "score", "arguments": "Extra stuff"},
RESPONSE_REJECT := base.Message(
role="user",
role="function",
name="score",
content=templates.reject_arguments_prompt,
function_call=None,
),
Expand Down

0 comments on commit 71ce715

Please sign in to comment.