Skip to content

Conversation

@hurtdidit
Copy link

Bug Description

response.py execute() crashes with KeyError: 'message' when neither text nor message keys exist in self.args dictionary.

Current Buggy Code (line 7)

return Response(message=self.args["text"] if "text" in self.args else self.args["message"], break_loop=True)

When both keys are missing, this throws KeyError: 'message' and causes the agent to completely stall.

Proposed Fix

message_text = self.args.get("text") or self.args.get("message", "")
return Response(message=message_text, break_loop=True)

Using .get() with a safe fallback prevents the crash.

Impact

  • Causes agents to completely stall when edge case occurs
  • Confirmed on multiple Agent Zero instances
  • Works fine in normal cases (happy path) but fails on error handling edge cases

Testing

  1. Trigger response tool with missing text/message args (edge case)
  2. With fix: Returns empty response safely instead of crashing
  3. Normal usage: No change in behavior

Note: This PR replaces #925 which incorrectly targeted main instead of development.

Bug: response.py execute() crashes with KeyError when neither 'text' nor
'message' keys exist in self.args dictionary.

Current buggy code:
  self.args['text'] if 'text' in self.args else self.args['message']

This fails when both keys are missing, causing agent to completely stall.

Fix: Use .get() method with safe fallback:
  message_text = self.args.get('text') or self.args.get('message', '')
  return Response(message=message_text, break_loop=True)

Impact: Prevents agent stalls in edge cases where response tool is
called without proper arguments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant