Repository navigation
feat: add the legacy completions surface and harden the gateway - #5
Merged
Merged
Conversation
Add POST /v1/completions (buffered and streamed) so prompt-style OpenAI clients work, and fix the defects found while auditing the tree for the improvement proposals: - cancel the upstream SSE reader, add an idle watchdog and recover a spawned server whose endpoint went stale - release every sticky-session slot (stale replay and prepare failures) and cache the replacement under the conversation key - fail a completion fast when the event stream is unavailable, and let /v1/responses answer a pre-stream failure with a real HTTP status - bound the metrics route label, keep /ready on cached state, parse integers strictly and fail closed on bad permission/alias JSON - pin validated media addresses, re-check local attachment sizes and honour pre-aborted signals - parse adjacent tool-call envelopes, keep reasoning out of a "none" variant, and report usage with reasoning inside the output budget - sign streamed Anthropic thinking blocks identically to the buffered path, and emit response.failed for a failed Responses turn - resolve media concurrently and observe upstream latency on failures - add GET /admin/config and document every changed behaviour 305 unit tests (20 files) pass; typecheck and build are clean.
dinhdev666
force-pushed
the
feat/gateway-hardening
branch
from
December 2, 2026 17:19
2cd275e to
0491946
Compare
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
Implements the improvement proposal set: one new public surface and a set of correctness, security, performance and documentation fixes found while auditing the tree.
IMPROVEMENT_PROPOSALS.mdwas the working document and is removed by this pull request (its content is now the changelog below).Added
POST /v1/completions— legacy OpenAI completions, buffered (text_completion) and streamed (text_completionchunks +[DONE]), withx-conversation-id/x-opencode-agentsupport.GET /admin/config— effective configuration with API keys and the upstream password redacted.parallel_tool_calls: falseis now honoured by the tool bridge (one bridged call per turn).Fixed
markStale()recovers a spawned server instead of retrying a dead URL.prepare()failures also release the acquired slot.event_stream_unavailable) when the event stream is down;/v1/responsesno longer commits the SSE head before the first event, so pre-stream failures return a real HTTP status./v1/responses: resolved model/#variantare preserved,sequence_numberstays contiguous on failures, failed turns reportstatus: "failed"/response.failed, and usage keepsprompt + completion === total.signature_deltaidentical to the buffered signature, block layout matches the buffered payload, streamed tool args are normalised,is_error-safe usage accounting includes thinking tokens inoutput_tokens.none-only variant set no longer reports reasoning as enabled.routelabel is bounded (no caller-controlled cardinality)./readyreads cached state only; upstream latency is observed on failures too; catalogue calls use a short timeout; shutdown has a bounded drain.Documentation
docs/API.md,docs/ARCHITECTURE.md,docs/CONFIGURATION.md,docs/VERIFICATION.md,README.mdand.env.examplewere updated for every changed contract, endpoint, field and behaviour.Verification
pnpm typecheck— cleanpnpm build— cleanpnpm test— 305 passed (20 files)pnpm lint:commits— passes (onescope-emptywarning for a repository-wide change)