Skip to content

Responses API validation error#2002

Merged
jxnl merged 2 commits intomainfrom
cursor/567-251-responses-api-validation-error-2921
Jan 16, 2026
Merged

Responses API validation error#2002
jxnl merged 2 commits intomainfrom
cursor/567-251-responses-api-validation-error-2921

Conversation

@jxnl
Copy link
Collaborator

@jxnl jxnl commented Jan 16, 2026

fix: Prevent reaskresponsestools from crashing with reasoning items

Describe your changes

Adds a check for hasattr(tool_call, "arguments") in the reask_responses_tools function. This prevents the function from attempting to access the .arguments attribute on ResponseReasoningItem objects, which do not have it, thus resolving a bug where validation errors were not properly sent back to the LLM during retry attempts when using reasoning models.

Issue ticket number and link

567-251: #1957

Checklist before requesting a review

  • I have performed a self-review of my code
  • If it is a core feature, I have added thorough tests.
  • If it is a core feature, I have added documentation.

Linear Issue: 567-251

Open in Cursor Open in Web


Important

Fixes crash in reask_responses_tools by checking for arguments attribute, ensuring proper handling of reasoning items.

  • Behavior:
    • Adds hasattr(tool_call, "arguments") check in reask_responses_tools to prevent crashes with ResponseReasoningItem objects.
    • Ensures validation errors are sent back to LLM during retries.
  • Functions:
    • Adds _filter_responses_tool_calls() to filter tool calls in utils.py.
    • Adds _format_responses_tool_call_details() to format tool call details in utils.py.
  • Tests:
    • Adds test_reask_responses_tools_skips_reasoning_items_and_includes_details in test_streaming_reask_bug.py to verify reasoning items are skipped and tool details are included.

This description was created by Ellipsis for 8ad4b0b. You can customize this summary. It will automatically update as commits are pushed.

Co-authored-by: jason <jason@jxnl.co>
@cursor
Copy link

cursor bot commented Jan 16, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@github-actions github-actions bot added bug Something isn't working python Pull requests that update python code size:M This PR changes 30-99 lines, ignoring generated files. labels Jan 16, 2026
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 16, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
instructor 8ad4b0b Commit Preview URL

Branch Preview URL
Jan 16 2026, 02:03 PM

Co-authored-by: jason <jason@jxnl.co>
@jxnl jxnl marked this pull request as ready for review January 16, 2026 14:16
@jxnl jxnl merged commit 3b86812 into main Jan 16, 2026
16 checks passed
@jxnl jxnl deleted the cursor/567-251-responses-api-validation-error-2921 branch January 16, 2026 14:17
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 8ad4b0b in 1 minute and 24 seconds. Click for details.
  • Reviewed 146 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. instructor/providers/openai/utils.py:31
  • Draft comment:
    Consider using a list comprehension in _filter_responses_tool_calls for conciseness and adding a comment that explicitly skips items (e.g. reasoning items) that don’t have an 'arguments' attribute.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 85% None
2. instructor/providers/openai/utils.py:44
  • Draft comment:
    The helper _format_responses_tool_call_details cleanly extracts details using getattr. Consider adding type annotations for the 'tool_call' parameter to improve clarity.
  • Reason this comment was not posted:
    Confidence changes required: 20% <= threshold 85% None
3. instructor/providers/openai/utils.py:134
  • Draft comment:
    Ensure that _filter_responses_tool_calls reliably filters out items without the 'arguments' attribute so that accessing tool_call.arguments won’t cause runtime errors. The current design appears correct, but a brief inline note could clarify this intent.
  • Reason this comment was not posted:
    Confidence changes required: 20% <= threshold 85% None
4. tests/test_streaming_reask_bug.py:138
  • Draft comment:
    The test 'test_reask_responses_tools_skips_reasoning_items_and_includes_details' effectively validates that reasoning items are skipped and that tool call details are appended. Consider adding an additional case with multiple valid tool calls to further strengthen coverage.
  • Reason this comment was not posted:
    Confidence changes required: 20% <= threshold 85% None

Workflow ID: wflow_vKnvg29gv7mJkRg0

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

cursor bot pushed a commit that referenced this pull request Jan 16, 2026
Update CHANGELOG for PRs #2000, #2002, #2005, #2007, and #2011.

Co-authored-by: jason <jason@jxnl.co>
@jxnl jxnl mentioned this pull request Jan 16, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working python Pull requests that update python code size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants