Skip to content

feat(server): add scoped Responses API support - #219

Open
PhilipJohnBasile wants to merge 1 commit into
youssofal:mainfrom
PhilipJohnBasile:agent/issue-193-responses-api
Open

feat(server): add scoped Responses API support#219
PhilipJohnBasile wants to merge 1 commit into
youssofal:mainfrom
PhilipJohnBasile:agent/issue-193-responses-api

Conversation

@PhilipJohnBasile

@PhilipJohnBasile PhilipJohnBasile commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a standalone stateless, text-only /v1/responses adapter that reuses the existing chat inference path
  • support structured text input, streaming and non-streaming responses, function/custom tools, and namespace-grouped client functions
  • round-trip namespace calls with their original name and namespace, preserve continuations and parallel calls, and validate events against OpenAI 2.52
  • accept current Codex request metadata and preserve native xhigh reasoning through the current RequestPolicy path

Scope and limitations

This is Codex Responses compatibility with hosted tools disabled. Codex 0.146 sends web_search in its default request; MTPLX intentionally returns a precise 400 unless hosted tools are disabled or removed. Hosted web/tool search, background jobs, server-side Response storage, previous_response_id, multimodal input, and stream obfuscation are not implemented. Requests for stream_options.include_obfuscation=true fail closed with a precise 400 rather than silently omitting padding.

The committed fixtures are reduced, sanitized representative contracts from loopback Codex 0.146 captures; they are not complete copies of the raw request.

This addresses the bounded local subset requested in #193 without claiming default hosted-tool Codex compatibility.

Current-main integration

Semantically rebased onto 90d8c4b (current main) as one signed-off commit: ede7180.

  • the Responses request-observability keys enter through RequestPolicy, which owns the 2.8.0 request prologue
  • current chat-client logprobs and unclosed-reasoning recovery behavior are retained
  • Responses output still suppresses the UI-only stats footer in streaming and non-streaming paths
  • requested xhigh remains xhigh; requested/effective values and a false downgrade flag remain observable
  • Responses usage preserves and bounds the chat path's reported reasoning-token count
  • the representative prompt fixture now tolerates current-main's additional system message while still asserting the exact instructions, skills block, AGENTS guidance, and final user request
  • the representative xhigh fake stream now closes the active reasoning block before emitting OK, matching current-main reasoning recovery

Verification

Publication was gated on macOS 14 ARM64 / Python 3.11 against exact head ede7180, using the frozen repository lockfile (Ruff 0.15.12):

  • uv run --frozen --extra server --extra dev --with openai==2.52.0 pytest -ra tests/test_server_openai.py tests/test_server_responses.py tests/test_request_observability_golden.py
  • uv run --frozen --extra server --extra dev ruff check mtplx/server/openai.py mtplx/server/request_policy.py mtplx/server/responses.py tests/test_server_openai.py tests/test_server_responses.py tests/test_request_observability_golden.py
  • uv run --frozen --extra server --extra dev python -m compileall -q mtplx/server/openai.py mtplx/server/request_policy.py mtplx/server/responses.py tests/test_server_openai.py tests/test_server_responses.py tests/test_request_observability_golden.py
  • bash scripts/hygiene_scan.sh .
  • git diff --check upstream/main...HEAD
  • one-commit ancestry and absence of temporary workflow/diagnostic files

All publication gates passed before the branch was force-updated. The upstream ci, hygiene, and build workflows are waiting for maintainer approval because this is a fork PR; their action_required state is not a test failure.

Review history

The first implementation was held after live Codex captures exposed unsupported namespace tools, xhigh, and incomplete fixture coverage. This revision adds namespace conversion, official SSE/schema validation, duplicate-name rejection, representative fixtures, explicit scope documentation, reasoning-usage preservation, fail-closed obfuscation handling, and footer-isolation regressions.

The earlier frozen diff was independently reviewed. Its first review rejected two contract defects (reasoning usage and silently ignored obfuscation); both were fixed with regressions before this semantic rebase.

@youssofal

Copy link
Copy Markdown
Owner

Review queued for the next cycle, together with #193. The stateless adapter reusing the chat inference path is the right starting shape; the OpenAI 2.52 event validation is what I will test against first.

@PhilipJohnBasile
PhilipJohnBasile force-pushed the agent/issue-193-responses-api branch from 5e01f83 to 0978862 Compare August 13, 2026 19:05
@PhilipJohnBasile
PhilipJohnBasile marked this pull request as ready for review August 13, 2026 19:06
@youssofal

Copy link
Copy Markdown
Owner

The 2.8.0 refactor moved the request prologue this PR patches (RequestPolicy extraction), so this needs a semantic rebase, not a textual one. I want it in. Rebase onto v2.8.0 and I will run the Codex fixture matrix against it; the reasoning_effort high mapping changed too (now maps up to xhigh), so the _xhigh fixture is the one to re-check.

@github-actions
github-actions Bot force-pushed the agent/issue-193-responses-api branch from 1f129a9 to e105cae Compare August 18, 2026 03:16

PhilipJohnBasile commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Current-main refresh completed and the PR branch was force-updated as one clean signed-off commit.

  • upstream main: 90d8c4b57233b61731269866b13d5af697284d8c
  • exact PR head: ede7180e5e68d74e11626bd0097f25efb05605d6
  • commit count ahead: 1
  • intended changed files: 10
  • temporary rebase workflow and tests/conftest.py diagnostics: absent from the final diff

The semantic resolution keeps the Responses reasoning metadata in RequestPolicy, preserves current logprobs and unclosed-reasoning recovery, keeps Responses-only footer suppression in both output paths, and preserves xhigh end-to-end. The current-main fixture adjustments retain the protocol assertions while accounting for the additional system message and closing the active reasoning block before OK.

Publication was gated on the frozen uv.lock toolchain on macOS ARM64 / Python 3.11. The focused Responses/OpenAI tests, RequestPolicy observability golden tests, Ruff, compileall, hygiene scan, diff check, and one-commit/clean-file assertions all passed before the force-update.

The upstream ci, hygiene, and build runs now show action_required because fork workflows require maintainer approval. They are queued, not failing.

Signed-off-by: Philip John Basile <PBasile@Basilecom.com>
@github-actions
github-actions Bot force-pushed the agent/issue-193-responses-api branch from 867f46c to ede7180 Compare August 18, 2026 16:36
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