Skip to content

feat(gateway): add opt-in source-scoped protocol extras - #37

Merged
ALikesToCode merged 1 commit into
integrate/gateway-waves-1-3from
feat/protocol-extras
Oct 9, 2026
Merged

ALikesToCode merged 1 commit into
integrate/gateway-waves-1-3from
feat/protocol-extras

Conversation

@ALikesToCode

Copy link
Copy Markdown
Owner

Summary

Adds source-scoped protocol extras behind PROTOCOL_EXTRAS_ENABLED, which defaults to false. With the flag off, strict translation, namespace handling and raw request and response bytes are unchanged. An invalid flag value also disables the feature and logs one warning without the value.

  • With the flag on, a managed request can carry reviewed fields from its own protocol in _multillm.protocol_extras. The extras stay outside the Chat pivot body and are restored only when the target provider explicitly admits each field:
    • Messages: top_k;
    • Responses: truncation: "disabled";
    • Chat: seed, logprobs, top_logprobs.
  • Translated JSON responses keep the reviewed native response fields (Messages stop_sequence, Chat system_fingerprint, Responses service_tier) under the same rules.
  • Input is bounded and strict:
    • scalar values only, at most 32 fields and 16 KiB;
    • the source must match the originating protocol;
    • unknown fields, nested objects, credentials and fields that conflict with the body are rejected with HTTP 400 on _multillm.protocol_extras, and the error never echoes untrusted names or values;
    • an upstream response carrying the internal namespace fails with 502 on translated JSON paths.
  • Provider admission defaults to the empty set. A protocol name alone never admits a field.
  • Conversion reports distinguish what was kept from what was sent. A field that is retained but not re-emitted is lossy, with retained_in_ir: true and re_emitted: false. Reports contain fixed paths and no values.
  • Nothing is stored. The carrier lives only for one managed operation. SSE translation stays strict and does not carry extras, and raw passthrough is unchanged.

Details are in docs/protocol-extras.md.

Integration

This branch wires the strict translators (validation only) and the Flask response bridge (translate_managed_response, plus extras in the recorded conversion report). The Wave 4 integration PR still has to make these changes in routes/unified.py:

  • use request_to_ir and request_from_ir with provider admission at managed request dispatch;
  • route same-protocol managed requests through translate_managed_request, so the namespace is validated and stripped;
  • connect managed_request_report to request diagnostics and the conversion-report endpoint.

Until then, translated requests validate their extras and drop them, and same-protocol requests are forwarded exactly as they are today.

Shared registrations

  • Added PROTOCOL_EXTRAS_ENABLED to the Container env keys.

Tests

  • tests/test_protocol_extras.py: new. It covers:
    • round trips with and without provider admission;
    • every source contract;
    • unsafe fields failing without echoing them;
    • namespace, size and conflict rejection;
    • unchanged bytes when disabled and for raw streams;
    • response namespace rejection;
    • fidelity reports;
    • the response bridge;
    • prompt cache usage with extras enabled.
  • Full Python suite: 3,573 passed, 2 skipped. ruff, mypy and bandit are clean.
  • npm run test:worker: 1,318 passed.
  • cf:migrations:check, test:deploy, free routes, client headers and the wrangler deploy --dry-run bundle all pass.
  • tests/test_frontend_build.mjs fails locally because @tailwindcss/cli is not installed. It fails the same way on main.

This is part of Wave 4. It is based on integrate/gateway-waves-1-3, and the Wave 4 integration PR adds the README line.

Carry reviewed per-protocol fields outside the Chat pivot behind PROTOCOL_EXTRAS_ENABLED (default off), restore them only for providers that admit each field, and report retained versus re-emitted fields without values.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a691d5b5-99fe-42a6-a11d-1084a1b9e018

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
multillm-proxy e185390 Oct 08 2026, 11:02 PM

@ALikesToCode
ALikesToCode merged commit a4fe9ea into integrate/gateway-waves-1-3 Oct 9, 2026
4 of 7 checks passed
@ALikesToCode
ALikesToCode deleted the feat/protocol-extras branch October 26, 2026 20:16
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