feat: add ResponsesApiTransport + wire Codex build_kwargs#13430
Conversation
58309ac to
28a4b2d
Compare
🚨 CRITICAL Supply Chain Risk DetectedThis PR contains a pattern that has been used in real supply chain attacks. A maintainer must review the flagged code carefully before merging. 🚨 CRITICAL: Install-hook file added or modifiedThese files can execute code during package installation or interpreter startup. Files: Scanner only fires on high-signal indicators: .pth files, base64+exec/eval combos, subprocess with encoded commands, or install-hook files. Low-signal warnings were removed intentionally — if you're seeing this comment, the finding is worth inspecting. |
28a4b2d to
76c30a4
Compare
🚨 CRITICAL Supply Chain Risk DetectedThis PR contains a pattern that has been used in real supply chain attacks. A maintainer must review the flagged code carefully before merging. 🚨 CRITICAL: Install-hook file added or modifiedThese files can execute code during package installation or interpreter startup. Files: Scanner only fires on high-signal indicators: .pth files, base64+exec/eval combos, subprocess with encoded commands, or install-hook files. Low-signal warnings were removed intentionally — if you're seeing this comment, the finding is worth inspecting. |
Add ResponsesApiTransport wrapping codex_responses_adapter.py behind the ProviderTransport ABC. Auto-registered via _discover_transports(). Wire ALL Codex transport methods to production paths in run_agent.py: - build_kwargs: main _build_api_kwargs codex branch (50 lines extracted) - normalize_response: main loop + flush + summary + retry (4 sites) - convert_tools: memory flush tool override - convert_messages: called internally via build_kwargs - validate_response: response validation gate - preflight_kwargs: request sanitization (2 sites) Remove 7 dead legacy wrappers from AIAgent (_responses_tools, _chat_messages_to_responses_input, _normalize_codex_response, _preflight_codex_api_kwargs, _preflight_codex_input_items, _extract_responses_message_text, _extract_responses_reasoning_text). Keep 3 ID manipulation methods still used by _build_assistant_message. Update 18 test call sites across 3 test files to call adapter functions directly instead of through deleted AIAgent wrappers. 24 new tests. 343 codex/responses/transport tests pass (0 failures). PR 4 of the provider transport refactor.
76c30a4 to
7d33dcf
Compare
🚨 CRITICAL Supply Chain Risk DetectedThis PR contains a pattern that has been used in real supply chain attacks. A maintainer must review the flagged code carefully before merging. 🚨 CRITICAL: Install-hook file added or modifiedThese files can execute code during package installation or interpreter startup. Files: Scanner only fires on high-signal indicators: .pth files, base64+exec/eval combos, subprocess with encoded commands, or install-hook files. Low-signal warnings were removed intentionally — if you're seeing this comment, the finding is worth inspecting. |
Summary
PR 4 of the provider transport refactor (PR 1: #12975, PR 2: #13073, PR 3: #13366).
Adds the second concrete transport —
ResponsesApiTransportfor the Codex/Responses API — and wires all transport methods to production paths. Removes 7 dead legacy wrappers from AIAgent.What ships
agent/transports/codex.py— ResponsesApiTransport (220 lines)build_kwargs()— 50 lines of kwargs construction extracted from run_agent.pynormalize_response()— wraps adapter, maps to NormalizedResponse with tool call provider_dataconvert_tools()— wraps_responses_tools()convert_messages()— wraps_chat_messages_to_responses_input()(called via build_kwargs)validate_response()— checks response.output with output_text fallbackpreflight_kwargs()— request sanitization (wraps_preflight_codex_api_kwargs)map_finish_reason()— completed/incomplete/failed/cancelled mappingrun_agent.py— All Codex paths wired, legacy wrappers removedbuild_kwargs()normalize_response()(with back-compat shim)normalize_response()normalize_response()normalize_response()convert_tools()validate_response()preflight_kwargs()Removed from AIAgent: 7 dead wrappers (
_responses_tools,_chat_messages_to_responses_input,_normalize_codex_response,_preflight_codex_api_kwargs,_preflight_codex_input_items,_extract_responses_message_text,_extract_responses_reasoning_text). 3 ID manipulation methods kept (_deterministic_call_id,_split_responses_tool_id,_derive_responses_function_call_id) — still used by_build_assistant_message.Tests updated: 18 call sites across 3 test files migrated from
agent._method()to direct adapter function calls.What stays on agent
_run_codex_stream()/_run_codex_create_stream_fallback()— streaming_build_assistant_message)_looks_like_codex_intermediate_ack()— agent loop heuristicTest plan