Fix response-tracking and analytics for enforce routes and deployment edges (OSP-101)#5
Draft
BenItBuhner wants to merge 1 commit into
Draft
Fix response-tracking and analytics for enforce routes and deployment edges (OSP-101)#5BenItBuhner wants to merge 1 commit into
BenItBuhner wants to merge 1 commit into
Conversation
… edges
- Thread x-opencode-* extraHeaders through EnforceRouter so session-scoped
upstream analytics keep working when enforce mode is enabled
- Record winning provider/model on request finish for per-edge visibility
- Add process-lifetime response counters exposed via /health/detailed and
/v1/admin/logs; dashboard now shows responses since process start
- Treat reasoning_content and similar vendor fields as non-empty in enforce
validation so reasoning models (e.g. Minimax M3) are not falsely retried
- Substitute {model}/{{model}} in provider endpoint URLs for deployment edges
- Log client-aborted streams and forward session headers on Anthropic routes
Co-authored-by: Bennett Buhner <BenItBuhner@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
Fixes OSP-101: response-tracking and analytics were unreliable for some models and routing edges (notably custom deployments like Minimax M3).
Root causes addressed:
x-opencode-*headers — OpenAI routes built session headers butEnforceRouternever forwarded them toFallbackRouter, breaking upstream/session-scoped response counting when enforce was enabled.recordRequestFinishsupportedresolvedProvider/resolvedModelbut routes only logged the logical model, so per-edge analytics in the dashboard showed–.content: null+reasoning_contentas empty, causing false retries/failures for models like Minimax M3.{model}/{{model}}in provider endpoint paths (e.g. Azure-style deployments) were not substituted.recordRequestFinish.Changes
extraHeadersandresolvedRoutethroughEnforceRouter→FallbackRouterrequest_statsto/health/detailedand/v1/admin/logsreasoning_content/reasoning/thinkingas non-empty in enforce validation{model}inbuildEndpointUrlusing upstream model idbuildUpstreamExtraHeadershelper; Anthropic routes now forward session headers toocancel()handler logs client-aborted requests (status 499)Testing
bun test tests/enforce-router.test.ts tests/enforce-validator.test.ts tests/request-log.test.ts tests/provider-helpers.test.ts tests/fallback-router.test.ts— all passopencode-providerconfig fixture failures unrelated to this change)bun run typecheck— passes (excluding pre-existingmodels-list.test.tstyping noise)Linear
Resolves OSP-101
Linear Issue: OSP-101