mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-05 16:07:33 +00:00
Root cause: normalizeCodexUntrustedContext only rewrote function_call_output items whose name matched a fixed list of Codex context tools. Newer Codex clients send page/tab context under new names (for example browser_tabs), so the item kept its missing call_id and validateFunctionCallOutputRequest rejected the whole request with HTTP 400. Change: gate agent context by namespace == "agent" and a missing or blank call_id instead of an enumerated name list. Known context names keep their existing tags and format checks; any other agent-namespace name is rendered under the generic <external_agent_context> tag so client-supplied names are never interpolated into tags unchecked. Items with a call_id, without the agent namespace, with a non-string output, or with duplicate members are left untouched and keep the original validation path. A zero-copy namespace probe replaces the name-literal fast path. Tests: add browser_tabs, unknown/renamed agent context names, escaped namespace, blank call_id, real tool outputs still rejected (400), and call_id regression cases; adapt existing unrelated-tool-result fixtures to model real tool outputs without the agent namespace. Full handler and service unit packages pass; go build and gofmt are clean.