Skip to content

refactor(models): Refine MessageAgentThought SQLAlchemy typing#37

Open
tomerqodo wants to merge 2 commits intosentry_combined_20260121_augment_sentry_coderabbit_1_base_refactormodels_refine_messageagentthought_sqlalchemy_typing_pr425from
sentry_combined_20260121_augment_sentry_coderabbit_1_head_refactormodels_refine_messageagentthought_sqlalchemy_typing_pr425
Open

refactor(models): Refine MessageAgentThought SQLAlchemy typing#37
tomerqodo wants to merge 2 commits intosentry_combined_20260121_augment_sentry_coderabbit_1_base_refactormodels_refine_messageagentthought_sqlalchemy_typing_pr425from
sentry_combined_20260121_augment_sentry_coderabbit_1_head_refactormodels_refine_messageagentthought_sqlalchemy_typing_pr425

Conversation

@tomerqodo
Copy link
Copy Markdown

Benchmark PR from qodo-benchmark#425

tool_call_response.append(
ToolPromptMessage(
content=tool_responses.get(tool, agent_thought.observation),
content=str(tool_inputs.get(tool, agent_thought.observation)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The agent history incorrectly uses tool_inputs instead of tool_responses for ToolPromptMessage content, providing the agent with tool inputs instead of outputs.
Severity: HIGH

Suggested Fix

In base_agent_runner.py on line 502, change content=str(tool_inputs.get(tool, agent_thought.observation)) to use the tool_responses variable, which holds the actual tool output. The line should be content=str(tool_responses.get(tool, agent_thought.observation)).

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: api/core/agent/base_agent_runner.py#L502

Potential issue: In the `organize_agent_history` method, the content for
`ToolPromptMessage` is sourced from `tool_inputs` instead of the correct
`tool_responses` variable. This causes the agent's conversation history to record the
input parameters sent to a tool, rather than the actual output returned by the tool. As
a result, the language model will not have the necessary information from previous tool
executions to make correct decisions in subsequent steps, breaking the agent's reasoning
process in multi-turn interactions.

Did we get this right? 👍 / 👎 to inform future reviews.

tool_call_response.append(
ToolPromptMessage(
content=tool_responses.get(tool, agent_thought.observation),
content=str(tool_inputs.get(tool, agent_thought.observation)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The ToolPromptMessage is incorrectly created with tool inputs from tool_inputs instead of tool outputs from tool_responses, sending the wrong information back to the agent.
Severity: HIGH

Suggested Fix

In api/core/agent/base_agent_runner.py on line 502, change the content parameter for ToolPromptMessage to use the tool_responses dictionary. Replace str(tool_inputs.get(tool, agent_thought.observation)) with str(tool_responses.get(tool, agent_thought.observation)).

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: api/core/agent/base_agent_runner.py#L502

Potential issue: When creating the `ToolPromptMessage` for the agent's conversation
history, the code incorrectly uses `tool_inputs.get(...)` instead of the intended
`tool_responses.get(...)`. This causes the tool's input arguments to be sent back to the
agent as if they were the tool's output. As a result, the agent lacks the actual results
from the tool execution, which breaks its reasoning chain and prevents it from
functioning correctly.

Did we get this right? 👍 / 👎 to inform future reviews.

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