Skip to content

OpenAI GPT-5 improvements #9

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

Merged
merged 15 commits into from
Aug 10, 2025
Merged

OpenAI GPT-5 improvements #9

merged 15 commits into from
Aug 10, 2025

Conversation

ammario
Copy link
Member

@ammario ammario commented Aug 10, 2025

A series of fixes for making GPT-5 reliable and effective with anyclaude.

UX changes

  • Converts opaque OpenAI service errors into 429s so CC natively retries instead of failing. These are very common.
  • Rich debugging support via ANYCLAUDE_DEBUG
  • Supports specifying reasoning effort and service tier

Codebase

  • Added CI

Remaining issues

  • GPT-5 often fails to use the native tool calls. These failures seems intermittent.

ammario and others added 15 commits August 10, 2025 12:39
OpenAI's API rejects requests with duplicate tool call IDs. This fix
filters out duplicate tool calls during Anthropic message conversion,
keeping only the first occurrence of each unique tool call ID.

- Add deduplication logic in convertToAnthropicMessagesPrompt
- Add comprehensive unit tests for duplicate filtering
- Fixes 400 errors when using OpenAI models with tool calls

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Instead of marking all properties as required for OpenAI, now preserves
the original schema's required fields and additionalProperties settings.
This prevents validation errors when optional fields are not provided.

- Only use existing required array if present
- Preserve original additionalProperties value
- Fixes overly strict schema validation for OpenAI models

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
When ANYCLAUDE_DEBUG env var is set, captures full HTTP request/response
data for 4xx errors (except 429) to temp JSON files for debugging.

- Add writeDebugToTempFile helper function
- Capture errors from Anthropic proxy, provider errors, and streaming
- Write debug info to /tmp/anyclaude-debug-{timestamp}-{randomId}.json
- Print temp file path to console for easy access
- Helps diagnose API compatibility issues across providers

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…low|medium|high and forwards as reasoning.effort; updates help
- Extract duplicate filtering logic into separate module (filter-duplicates.ts)
- Add comprehensive validation to ensure tool call/result consistency
- Verify order preservation and detect orphaned tool results
- Enhance debug logging to capture full stream dumps
- Include original vs filtered message counts in debug output
- Add stream timeline with timestamps for all chunks
- Improve error context with request/response metadata

This helps diagnose sporadic OpenAI server errors that occur after
extended conversations with duplicate tool calls from Claude Code.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Debug file should not be tracked in version control

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Level 1 (default): Basic debug with error logging only
- Level 2: Verbose debug with duplicate filtering details
- Defaults to level 1 for any non-numeric value

This reduces noise in debug output by hiding duplicate filtering
messages unless explicitly requested with level 2.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ammario ammario merged commit f42e039 into main Aug 10, 2025
1 check passed
@ammario ammario deleted the ammar branch August 10, 2025 20:50
ammario added a commit that referenced this pull request Aug 10, 2025
This reverts commit f42e039.

I think this messed up some builds.
ammario added a commit that referenced this pull request Aug 11, 2025
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