Repository navigation
feat(server): integrate OpenAI Chat buffered proxy - #2414
Merged
Merged
Conversation
This was referenced Sep 26, 2026
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Pouyanpi
marked this pull request as ready for review
September 26, 2026 20:41
Contributor
|
Pouyanpi
force-pushed
the
pouyanpi/openai-chat-buffered-integration-4
branch
from
September 26, 2026 20:53
7162ba0 to
43c9841
Compare
Pouyanpi
force-pushed
the
pouyanpi/openai-chat-buffered-integration-4
branch
2 times, most recently
from
September 26, 2026 21:19
e91c3e8 to
c4126a8
Compare
Pouyanpi
force-pushed
the
pouyanpi/openai-chat-buffered-integration-4
branch
from
October 5, 2026 12:58
c4126a8 to
4c14da9
Compare
This was referenced Oct 5, 2026
Pouyanpi
force-pushed
the
pouyanpi/openai-chat-buffered-integration-4
branch
from
October 5, 2026 14:58
4c14da9 to
dad6b4a
Compare
This was referenced Oct 5, 2026
Pouyanpi
force-pushed
the
pouyanpi/openai-chat-buffered-integration-4
branch
from
October 6, 2026 11:05
dad6b4a to
0c5c264
Compare
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Pouyanpi
force-pushed
the
pouyanpi/openai-chat-buffered-integration-4
branch
from
October 9, 2026 09:58
43ef5a4 to
852674e
Compare
After the closed Chat projections merged, the buffered integration fixtures relied on an unreviewed top-level "opaque" member, which the request and response roots now reject. The unsupported-response example used tool_calls: [], which is now a valid empty value. The checked-in contract export no longer matched the policy models. Use reviewed opaque fields (metadata and usage) to show byte-preserving relay, use an actual tool call as the unsupported response, and regenerate the export with the contract export CLI. The export and the runtime now both accept only null or empty annotations. Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
The response projection accepts empty or null assistant content, as OpenAI's schema allows, for example when generation stops at a length limit or a content filter. The buffered proxy still read the target's message, which raises for null content and runs output rails on an empty string. After shape validation, check has_text and return ContentInspectionNotApplicable when there is no text, so the kernel relays the original response without output checks. Validation still runs first: a missing message or missing content key is rejected, and null content with refusal, reasoning, tool, or citation content is rejected. Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Clients such as the OpenAI SDK send Accept-Encoding: gzip, and the proxy forwarded it. A provider that compressed the response then failed output inspection with a 502, because encoded successful responses cannot be inspected. Replace Accept-Encoding with identity on guarded provider requests. A provider that still encodes the response is rejected rather than relayed without inspection. Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
The OpenAI boundary summary said relaying responses without text was left to the integration, which now does it. The buffered integration docs did not describe the relay or the identity-encoding request, and still showed a Poetry command for the contract export CLI. State that empty or null content is relayed without output checks only after the closed projection passes. Document the identity-encoding request and the rejection of encoded responses. Use uv for the export command, and note that exported annotations allow only an empty list. Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Declare Unicode case-alias rejection and closed-by-default unknown-field policy in the shared contract vocabulary. Regenerate the buffered Chat export and verify exported acceptance against the handwritten runtime under both trusted field policies. Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
The guarded Chat glue replaced Accept-Encoding with identity on every guarded request. The plain body is needed only when output checks run. Without them the response is relayed unchanged, so the client's compression preference can be kept. Move the header change into the buffered kernel, which knows the resolved inspection policy. It applies to any guarded operation, not just OpenAI Chat. The guarded Chat glue forwards the request as before. A still-encoded response under output inspection remains rejected. Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
TestRaiseLLMCallException fails on some CI orderings. The exception helper prefers model and provider names from llm_call_info_var. An earlier test on the same worker leaves that variable set to a fake model, so these tests read model=fake instead of their own test-model. Reset llm_call_info_var around each test in the class. This is test isolation only and does not change runtime behavior. Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Patch coverage reported about 51 changed lines without coverage. 24 of them were the contract export CLI, which the tests exercised only in subprocesses that coverage does not measure. The rest were endpoint, revision binding, adapter, and error rendering branches. Run the CLI in process for stdout, output, check, mismatch, and export failure, while keeping the subprocess tests for the module entry point. Cover endpoint route and binding declarations, revision binding values, the guarded operation's revision check and its OpenAPI parameter, paired request adapters, unique error status codes, HTTP failure rendering without exception text, and policy models used as mapping values. The lines left uncovered cannot be reached through the declarations: the profile-mismatch checks (one capability profile exists), a PolicyModel check that export performs first, the object-schema guard (PolicyModel cannot be a root model), and the __main__ entry line. Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Integrates the authoritative OpenAI Chat projections into the buffered provider-native proxy path and exports their guard contract.
Why
The integration must preserve original provider data while connecting exact guarded targets, checker execution, native errors, route ownership, and OpenAPI documentation. Its exported contract describes the models actually bound to the endpoint.
What Changed
POST /v1/chat/completionsendpoint and reserves its API-version path family.contracts/openai/_generated/chat-completions.buffered.guard.yaml.Review Notes
Review this PR against #2413. The exported YAML is for inspection and documentation; request handling does not load it. The export contains request and buffered-response policy. The shared CLI consumes an existing endpoint declaration; Python models and bindings remain handwritten.
Streaming requests are recognized but rejected before dispatch. Replacement eligibility does not enable executing replacement outcomes, which remain unsupported here.
create_openai_chat_router(...)returns anAPIRouter, not a standalone configured server. The embedding application suppliesContentCheckerandHttpDispatch; concrete outbound transport, deployment composition, and trusted Rails configuration resolution remain separate work.Validation
Offline experimental tests passed, including export and mocked HTTP integration tests. Pre-commit and the exported-contract drift check passed. No live provider calls were used.
AI Assistance
Codex assisted with implementation, tests, documentation, and stack maintenance.
Checklist
Stack Position
Part 3 of 3.
Stack Context
The Python projection models and runtime bindings are authoritative. This buffered stack declares their policy alongside the types and exports YAML for inspection and documentation. Request handling does not load the exported contract.
The open chain is #2411 → #2413 → #2414 → #2434 → #2435 → #2436 → #2437. #2412 is closed; its provider provenance and boundary documentation are included in #2413.
Streaming continues in #2434–#2437. The shared exporter currently emits request and buffered-response policy; streaming contract export remains separate work.
Review each PR against its listed base branch.
pouyanpi/guard-contract-foundation-1developpouyanpi/openai-chat-buffered-projections-3pouyanpi/guard-contract-foundation-1pouyanpi/openai-chat-buffered-integration-4pouyanpi/openai-chat-buffered-projections-3Summary by CodeRabbit