Skip to content
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

Fix issue #5154: [Bug]: FinishTool doesn't have a tool response so the agent loses its content #5231

Closed
wants to merge 1 commit into from

Conversation

openhands-agent
Copy link
Contributor

This pull request fixes #5154.

The issue has been successfully resolved. The PR fixes the core problem where FinishAction with source='agent' was being treated incorrectly in the conversation flow. Here's a summary for the reviewer:

This PR fixes a regression in function calling where FinishAction with source='agent' wasn't being properly handled. The changes:

  1. Removes AgentFinishAction from the list of actions treated as tool calls in get_action_message, preventing it from being stored in pending_tool_call_action_messages
  2. Adds specific handling for AgentFinishAction (source='agent') by treating it as a regular message action:
    • Extracts the original LLM response from tool_call_metadata
    • Creates a new Message with matching role and content
    • Preserves the agent's finishing thought in conversation history

The solution maintains proper conversation flow while ensuring:

  • FinishAction (source='user') continues to work as intended
  • FinishAction (source='agent') is properly handled without requiring tool responses
  • Agent's reasoning for finishing is preserved in the conversation history

These changes align with LLM API requirements while fixing the regression in function calling behavior.

Automatic fix generated by OpenHands 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: FinishTool doesn't have a tool response
2 participants