refactor(models): Refine MessageAgentThought SQLAlchemy typing#24
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| tool_call_response.append( | ||
| ToolPromptMessage( | ||
| content=tool_responses.get(tool, agent_thought.observation), | ||
| content=str(tool_inputs.get(tool, agent_thought.observation)), |
There was a problem hiding this comment.
Tool response replaced with tool input in history
High Severity
The ToolPromptMessage content now uses tool_inputs.get(tool, ...) instead of tool_responses.get(tool, ...). This means tool outputs/responses are replaced with tool inputs when reconstructing agent conversation history. The LLM will receive incorrect context where tool call responses show what was sent to the tool rather than what was returned by the tool.
| answer_unit_price=0, | ||
| answer_price_unit=0, | ||
| answer_unit_price=Decimal("0.001"), | ||
| answer_price_unit=Decimal(0), |
There was a problem hiding this comment.
Answer price unit values are swapped
Medium Severity
The answer_unit_price and answer_price_unit values appear swapped. The message fields use message_unit_price=Decimal(0) and message_price_unit=Decimal("0.001"), but the answer fields use the opposite pattern: answer_unit_price=Decimal("0.001") and answer_price_unit=Decimal(0). The model defaults both *_price_unit fields to Decimal("0.001").
Benchmark PR from qodo-benchmark#425
Note
Modernizes agent thought persistence and history reconstruction.
MessageAgentThoughtto extendTypeBasewithMapped[...]typing,insert_default/default_factoryID generation, Decimal pricing fields, explicit defaults, and reordered required fields (created_by_role/created_by)BaseAgentRunnerto:Decimalprices andCreatorUserRoleenum; addtool_process_datadefaultthoughttext; handle missing/invalid JSON fortool_input/observationwhen rebuilding historytoolnames more defensively and handle empty casesAgentThoughtValidation(Pydantic) model scaffoldMessageAgentThought.idand align with new model behaviorWritten by Cursor Bugbot for commit 8821d28. Configure here.