Skip to content

Sanitize Codex Responses message translation#139

Merged
xichen1997 merged 1 commit into
runta-dev:mainfrom
highclaws-com:fix-translate-for-codex
May 22, 2026
Merged

Sanitize Codex Responses message translation#139
xichen1997 merged 1 commit into
runta-dev:mainfrom
highclaws-com:fix-translate-for-codex

Conversation

@w32zhong

@w32zhong w32zhong commented May 22, 2026

Copy link
Copy Markdown
Contributor

Spotted this error when using Weixin with Codex OAuth and replayed chat history contains extra assistant message
fields such as reasoning_content, which the Codex Responses endpoint does not accept.

2026-05-22T16:23:31.353789809Z 2026-05-22T16:23:31.353591Z  INFO clawshell::app: Forwarding request to upstream method=GET path=/models virtual_key=vk-openai-codex                                                                           
2026-05-22T16:23:31.852544426Z 2026-05-22T16:23:31.852419Z  WARN clawshell::app: Upstream returned error oauth_provider=codex effective_path=/models status=400 Bad Request response_body={                                                   
2026-05-22T16:23:31.852576536Z   "error": {                                                                                                                                                                                                   
2026-05-22T16:23:31.852579459Z     "message": "[{'type': 'missing', 'loc': ('query', 'client_version'), 'msg': 'Field required', 'input': None}]",              
2026-05-22T16:23:31.852581951Z     "type": "invalid_request_error",                                                                                                                                                                           
2026-05-22T16:23:31.852583963Z     "param": null,                                                                                                                                                                                             
2026-05-22T16:23:31.852585910Z     "code": null                                                                                                                                                                                               
2026-05-22T16:23:31.852588046Z   }                                                                                                                                                                                                            
2026-05-22T16:23:31.852589789Z }                                                                                                                                                                                                              
2026-05-22T16:23:31.852592074Z 2026-05-22T16:23:31.852457Z  INFO clawshell::app: Request completed method=GET path=/models query= status=400 Bad Request latency_ms=498                                                                       
2026-05-22T16:23:31.900669382Z 2026-05-22T16:23:31.900559Z  INFO clawshell::app: Forwarding request to upstream method=POST path=/api/show virtual_key=vk-openai-codex                                                                        
2026-05-22T16:23:31.915812645Z 2026-05-22T16:23:31.915628Z  INFO clawshell::app: Request completed method=POST path=/api/show query= status=403 Forbidden latency_ms=15                                                                       
2026-05-22T16:23:32.722081729Z 2026-05-22T16:23:32.721815Z  INFO clawshell::app: Forwarding request to upstream method=POST path=/api/show virtual_key=vk-openai-codex                                                                        
2026-05-22T16:23:32.756354940Z 2026-05-22T16:23:32.756166Z  INFO clawshell::app: Request completed method=POST path=/api/show query= status=403 Forbidden latency_ms=34                                                                       
2026-05-22T16:23:32.777907955Z 2026-05-22T16:23:32.777738Z  INFO clawshell::app: Forwarding request to upstream method=POST path=/api/show virtual_key=vk-openai-codex                                                                        
2026-05-22T16:23:32.816114667Z 2026-05-22T16:23:32.815940Z  INFO clawshell::app: Request completed method=POST path=/api/show query= status=403 Forbidden latency_ms=38                                                                       
2026-05-22T16:23:33.026752047Z 2026-05-22T16:23:33.026625Z  INFO clawshell::app: Forwarding request to upstream method=POST path=/v1/chat/completions virtual_key=vk-openai-codex                                                             
2026-05-22T16:23:33.494637368Z 2026-05-22T16:23:33.494519Z  WARN clawshell::app: Upstream returned error oauth_provider=codex effective_path=/responses status=400 Bad Request response_body={                                                
2026-05-22T16:23:33.494667680Z   "error": {                                                                                                                                                                                                   
2026-05-22T16:23:33.494671450Z     "message": "Unknown parameter: 'input[2].reasoning_content'.",                                                                                                                                             
2026-05-22T16:23:33.494689458Z     "type": "invalid_request_error",                                                                                                                                                                           
2026-05-22T16:23:33.494692117Z     "param": "input[2].reasoning_content",                                                                                                                                                                     
2026-05-22T16:23:33.494694623Z     "code": "unknown_parameter"                                                                                                                                                                                
2026-05-22T16:23:33.494696947Z   }                                                                                                                                                                                                            
2026-05-22T16:23:33.494699117Z }

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — sanitize chat completions messages during Responses API translation by constructing a new message object with only explicitly allowed fields (role, content, phase, type), stripping unsupported fields like reasoning_content that Codex rejects.

  • Build sanitized message from scratchconvert_message_to_input_items now constructs a new input_message map instead of cloning and mutating the original message, automatically dropping any fields not in the allowlist.
  • Preserve phase for Codex flows — carries over the Codex-specific phase field from the source message.
  • Add test for field stripping — verifies name and reasoning_content are absent while type, role, content, and phase survive translation.

Pullfrog  | View workflow run | Using Big Pickle (free) | 𝕏

@xichen1997

Copy link
Copy Markdown
Collaborator

LGTM, thanks!

@xichen1997
xichen1997 enabled auto-merge May 22, 2026 18:17
@xichen1997
xichen1997 added this pull request to the merge queue May 22, 2026
Merged via the queue into runta-dev:main with commit 8f70180 May 22, 2026
4 checks passed
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.

2 participants