Skip to content

refactor(models): Refine MessageAgentThought SQLAlchemy typing#24

Open
tomerqodo wants to merge 2 commits intocursor_combined_20260121_qodo_grep_cursor_copilot_1_base_refactormodels_refine_messageagentthought_sqlalchemy_typing_pr425from
cursor_combined_20260121_qodo_grep_cursor_copilot_1_head_refactormodels_refine_messageagentthought_sqlalchemy_typing_pr425
Open

refactor(models): Refine MessageAgentThought SQLAlchemy typing#24
tomerqodo wants to merge 2 commits intocursor_combined_20260121_qodo_grep_cursor_copilot_1_base_refactormodels_refine_messageagentthought_sqlalchemy_typing_pr425from
cursor_combined_20260121_qodo_grep_cursor_copilot_1_head_refactormodels_refine_messageagentthought_sqlalchemy_typing_pr425

Conversation

@tomerqodo
Copy link
Copy Markdown

@tomerqodo tomerqodo commented Jan 21, 2026

Benchmark PR from qodo-benchmark#425


Note

Modernizes agent thought persistence and history reconstruction.

  • Refactors MessageAgentThought to extend TypeBase with Mapped[...] typing, insert_default/default_factory ID generation, Decimal pricing fields, explicit defaults, and reordered required fields (created_by_role/created_by)
  • Updates BaseAgentRunner to:
    • Create thoughts using Decimal prices and CreatorUserRole enum; add tool_process_data default
    • Safely append thought text; handle missing/invalid JSON for tool_input/observation when rebuilding history
    • Build tool call lists from tool names more defensively and handle empty cases
  • Adds AgentThoughtValidation (Pydantic) model scaffold
  • Tests updated to rely on auto-generated MessageAgentThought.id and align with new model behavior

Written by Cursor Bugbot for commit 8821d28. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

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)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

answer_unit_price=0,
answer_price_unit=0,
answer_unit_price=Decimal("0.001"),
answer_price_unit=Decimal(0),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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").

Fix in Cursor Fix in Web

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