Skip to content

fix: pass through client errors (400/404/409/422) and strip stale item references when store=false#511

Closed
kiroo92 wants to merge 0 commit intoWei-Shaw:mainfrom
kiroo92:main
Closed

fix: pass through client errors (400/404/409/422) and strip stale item references when store=false#511
kiroo92 wants to merge 0 commit intoWei-Shaw:mainfrom
kiroo92:main

Conversation

@kiroo92
Copy link

@kiroo92 kiroo92 commented Feb 7, 2026

Problem

OpenClaw sends POST /v1/responses with input items referencing previous response IDs (rs_...). Since OAuth accounts force store=false, these items are never persisted on OpenAI's side, causing 404 errors. The proxy converts 404 to a generic 502, so the client keeps retrying the same broken request in an infinite loop.

Changes

  1. handleErrorResponse: Pass through 400/404/409/422 as invalid_request_error with the original upstream status code and message, instead of converting to generic 502.
  2. applyCodexOAuthTransform: When store=false (always true for OAuth accounts), force preserveReferences=false in filterCodexInput to remove item_reference entries and strip stale id fields from input items.

Result

  • Input items referencing non-persisted responses are cleaned before forwarding to upstream
  • Client errors are passed through transparently so callers can act on the real problem
  • Tool call continuation (call_id) still works correctly

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