GeezerVison is showing github.com — Merge remote-tracking branch 'origin/dev' into codex/service-manager-… · lidge-jun/opencodex@7119f66
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/server/management/route-registry.ts +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -149,9 +149,9 @@ export const MANAGEMENT_ROUTES: readonly ManagementRoute[] = [ | 149 | 149 | { method: "GET", path: "/api/client-integrations/aside/profiles/{profileId}", module: "server/management/aside-profile-routes", mutates: false, mechanism: "prefix-decode" }, | 150 | 150 | { method: "PUT", path: "/api/client-integrations/aside/profiles/{profileId}", module: "server/management/aside-profile-routes", mutates: true, mechanism: "prefix-decode" }, | 151 | 151 | { method: "GET", path: "/api/client-integrations/aside/profiles/journal", module: "server/management/aside-profile-routes", mutates: false, mechanism: "prefix-decode" }, | 152 | | - { method: "DELETE", path: "/api/client-integrations/aside/profiles/journal", module: "server/management/aside-profile-routes", mutates: true, mechanism: "prefix-decode", exempt: { reason: "deferred-verb", why: "Aside history deletion uses the dashboard journal cleanup; the CLI has history and restore but no deletion verb yet.", owner: "260904_priority65_closeout WP7", ownerDoc: "devlog/_plan/260904_priority65_closeout/060_wp7_rollback_journal_crud.md" } }, | | 152 | + { method: "DELETE", path: "/api/client-integrations/aside/profiles/journal", module: "server/management/aside-profile-routes", mutates: true, mechanism: "prefix-decode", exempt: { reason: "deferred-verb", why: "Aside history deletion uses the dashboard journal cleanup; the CLI has history and restore but no deletion verb yet.", owner: "260904_priority65_closeout WP7", ownerDoc: "devlog/_fin/260904_priority65_closeout/060_wp7_rollback_journal_crud.md" } }, | 153 | 153 | { method: "GET", path: "/api/client-integrations/aside/profiles/{profileId}/journal", module: "server/management/aside-profile-routes", mutates: false, mechanism: "prefix-decode" }, | 154 | | - { method: "DELETE", path: "/api/client-integrations/aside/profiles/{profileId}/journal", module: "server/management/aside-profile-routes", mutates: true, mechanism: "prefix-decode", exempt: { reason: "deferred-verb", why: "Aside profile history deletion uses the dashboard journal cleanup; the CLI has scoped history and restore but no deletion verb yet.", owner: "260904_priority65_closeout WP7", ownerDoc: "devlog/_plan/260904_priority65_closeout/060_wp7_rollback_journal_crud.md" } }, | | 154 | + { method: "DELETE", path: "/api/client-integrations/aside/profiles/{profileId}/journal", module: "server/management/aside-profile-routes", mutates: true, mechanism: "prefix-decode", exempt: { reason: "deferred-verb", why: "Aside profile history deletion uses the dashboard journal cleanup; the CLI has scoped history and restore but no deletion verb yet.", owner: "260904_priority65_closeout WP7", ownerDoc: "devlog/_fin/260904_priority65_closeout/060_wp7_rollback_journal_crud.md" } }, | 155 | 155 | { method: "POST", path: "/api/client-integrations/aside/profiles/{profileId}/restore", module: "server/management/aside-profile-routes", mutates: true, mechanism: "prefix-decode" }, | 156 | 156 | // server/management/codex-prompt-routes | 157 | 157 | { method: "GET", path: "/api/codex-prompt", module: "server/management/codex-prompt-routes", mutates: false }, | @@ -187,7 +187,7 @@ export const MANAGEMENT_ROUTES: readonly ManagementRoute[] = [ | 187 | 187 | // server/management/integration-routes | 188 | 188 | { method: "GET", path: "/api/client-integrations", module: "server/management/integration-routes", mutates: false }, | 189 | 189 | { method: "GET", path: "/api/client-integrations/journal", module: "server/management/integration-routes", mutates: false }, | 190 | | - { method: "DELETE", path: "/api/client-integrations/journal", module: "server/management/integration-routes", mutates: true, exempt: { reason: "deferred-verb", why: "Retiring one rollback row is a dashboard-local cleanup; the CLI verb that would drive it is owed by a later work-phase and is not implemented here.", owner: "260904_priority65_closeout WP7", ownerDoc: "devlog/_plan/260904_priority65_closeout/060_wp7_rollback_journal_crud.md" } }, | | 190 | + { method: "DELETE", path: "/api/client-integrations/journal", module: "server/management/integration-routes", mutates: true, exempt: { reason: "deferred-verb", why: "Retiring one rollback row is a dashboard-local cleanup; the CLI verb that would drive it is owed by a later work-phase and is not implemented here.", owner: "260904_priority65_closeout WP7", ownerDoc: "devlog/_fin/260904_priority65_closeout/060_wp7_rollback_journal_crud.md" } }, | 191 | 191 | { method: "POST", path: "/api/client-integrations/restore", module: "server/management/integration-routes", mutates: true }, | 192 | 192 | // server/management/lab-automation-routes | 193 | 193 | { method: "GET", path: "/api/lab/automation", module: "server/management/lab-automation-routes", mutates: false, exempt: { reason: "local-transport", why: "ocx lab reads the same rows from the local SQLite projection; src/cli/lab.ts imports ../lab/query directly and never fetches /api/lab." } }, | @@ -293,7 +293,7 @@ export const MANAGEMENT_ROUTES: readonly ManagementRoute[] = [ | 293 | 293 | { method: "PATCH", path: "/api/providers", module: "server/management/provider-routes", mutates: true }, | 294 | 294 | { method: "POST", path: "/api/providers", module: "server/management/provider-routes", mutates: true }, | 295 | 295 | { method: "POST", path: "/api/providers/test", module: "server/management/provider-routes", mutates: true }, | 296 | | - { method: "PUT", path: "/api/providers", module: "server/management/provider-routes", mutates: true, exempt: { reason: "deferred-verb", why: "Issue #3280 scopes this atomic batch endpoint to the GUI JSON editor; a matching CLI verb is outside wp5 and remains owed.", owner: "wp5-followup", ownerDoc: "devlog/_plan/260903_bug_drawdown_bcda/050_phase5.md" } }, | | 296 | + { method: "PUT", path: "/api/providers", module: "server/management/provider-routes", mutates: true, exempt: { reason: "deferred-verb", why: "Issue #3280 scopes this atomic batch endpoint to the GUI JSON editor; a matching CLI verb is outside wp5 and remains owed.", owner: "wp5-followup", ownerDoc: "devlog/_fin/260903_bug_drawdown_bcda/050_phase5.md" } }, | 297 | 297 | { method: "PUT", path: "/api/provider-context-caps", module: "server/management/provider-routes", mutates: true }, | 298 | 298 | // server/management/quota-reset-routes | 299 | 299 | { method: "GET", path: "/api/quota-resets", module: "server/management/quota-reset-routes", mutates: false, mechanism: "negated-guard" }, | |
Collapse file Copy file name to clipboardExpand all lines: src/server/responses/core.ts +9-2Lines changed: 9 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2791,6 +2791,10 @@ export async function handleComboResponses( | 2791 | 2791 | logCtx.routeDecision = comboRouteDecisionTrace(config, comboId, pick, requestedModel); | 2792 | 2792 |
| 2793 | 2793 | let lastFailure: Response | null = null; | | 2794 | + // The exhausted-combo mapping below runs outside the loop, where `failure.upstreamCode` | | 2795 | + // is gone, so carry the loop's own classification decision instead of re-deriving a | | 2796 | + // weaker one from the status alone (#4149). | | 2797 | + let lastFailureClassifiesOverflow = false; | 2794 | 2798 | while (pick) { | 2795 | 2799 | if (options.abortSignal?.aborted) return clientCancelledResponse(); | 2796 | 2800 | const childLog: RequestLogContext = { | @@ -3003,6 +3007,7 @@ export async function handleComboResponses( | 3003 | 3007 | const classifyOverflow = failure.response.status === 413 | 3004 | 3008 | && (wantsStream || (failure.upstreamCode !== "outbound_body_too_large" | 3005 | 3009 | && failure.upstreamCode !== "translation_buffer_limit")); | | 3010 | + lastFailureClassifiesOverflow = classifyOverflow; | 3006 | 3011 | if (storedPool401ReplayDispatched) { | 3007 | 3012 | if (failureDecision === "hop" && unreadableEncryptedAgentTask && !comboPayloadReadable) { | 3008 | 3013 | const recoveredTarget = await pickWithWait({ | @@ -3089,9 +3094,11 @@ export async function handleComboResponses( | 3089 | 3094 | } | 3090 | 3095 | if ( | 3091 | 3096 | lastFailure?.status === 413 | 3092 | | - && (rawBody as { stream?: unknown } | null)?.stream === true | | 3097 | + && lastFailureClassifiesOverflow | 3093 | 3098 | ) { | 3094 | | - return streamingContextOverflowResponse(requestedModel, options.translatorBudget); | | 3099 | + return (rawBody as { stream?: unknown } | null)?.stream === true | | 3100 | + ? streamingContextOverflowResponse(requestedModel, options.translatorBudget) | | 3101 | + : jsonContextOverflowResponse(); | 3095 | 3102 | } | 3096 | 3103 | return lastFailure!; | 3097 | 3104 | } | |
Collapse file Copy file name to clipboardExpand all lines: tests/responses/responses-context-overflow.test.ts +65Lines changed: 65 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,6 +44,26 @@ function upstream413(onHit?: () => void): ReturnType<typeof Bun.serve> { | 44 | 44 | return upstreamStatus(413, onHit); | 45 | 45 | } | 46 | 46 |
| | 47 | +/** | | 48 | + * A 413 whose body carries a per-request free-tier cap. `comboFailureDecision` reads that | | 49 | + * as target-local and hops, so a combo tries every target and then exhausts, which is the | | 50 | + * mapping site this fixture exercises. | | 51 | + */ | | 52 | +function freePromptCap413(onHit?: () => void): ReturnType<typeof Bun.serve> { | | 53 | + const upstream = Bun.serve({ | | 54 | + hostname: "127.0.0.1", | | 55 | + port: 0, | | 56 | + fetch() { | | 57 | + onHit?.(); | | 58 | + return Response.json({ | | 59 | + detail: "err_free_prompt_cap: prompt exceeds this tier; echoed private request marker should-not-reach-client", | | 60 | + }, { status: 413 }); | | 61 | + }, | | 62 | + }); | | 63 | + upstreams.push(upstream); | | 64 | + return upstream; | | 65 | +} | | 66 | + | 47 | 67 | function provider( | 48 | 68 | adapter: "openai-responses" | "openai-chat" | "anthropic", | 49 | 69 | upstream: ReturnType<typeof Bun.serve>, | @@ -268,4 +288,49 @@ describe("Responses provider input overflow", () => { | 268 | 288 | await server.stop(true); | 269 | 289 | } | 270 | 290 | }); | | 291 | + // A 413 carrying `err_free_prompt_cap` is a per-request free-tier cap, so | | 292 | + // `comboFailureDecision` hops instead of stopping. Every target then refuses and the | | 293 | + // combo falls out of its loop, which is a different mapping site from the "stop" case | | 294 | + // above and was still gated on `stream === true` after #4127 (#4149). | | 295 | + test.each([true, false])("an exhausted combo classifies a hopping 413 (stream=%s)", async stream => { | | 296 | + let firstHits = 0; | | 297 | + let secondHits = 0; | | 298 | + const first = freePromptCap413(() => { firstHits += 1; }); | | 299 | + const second = freePromptCap413(() => { secondHits += 1; }); | | 300 | + const next = config({ | | 301 | + first: provider("openai-chat", first), | | 302 | + second: provider("openai-chat", second), | | 303 | + }); | | 304 | + next.combos = { | | 305 | + fallback: { | | 306 | + strategy: "failover", | | 307 | + targets: [ | | 308 | + { provider: "first", model: "kimi-k3" }, | | 309 | + { provider: "second", model: "kimi-k3" }, | | 310 | + ], | | 311 | + }, | | 312 | + }; | | 313 | + saveConfig(next); | | 314 | + const server = startServer(0); | | 315 | + try { | | 316 | + const response = await request(String(server.url), "combo/fallback", stream); | | 317 | + if (stream) { | | 318 | + const failed = await responseFailed(response); | | 319 | + expect((failed.error as { code?: string }).code).toBe("context_length_exceeded"); | | 320 | + } else { | | 321 | + expect(response.status).toBe(413); | | 322 | + expect(response.headers.get("content-type")).toContain("application/json"); | | 323 | + expect(await response.json()).toEqual({ error: { | | 324 | + message: PROVIDER_INPUT_TOO_LARGE_MESSAGE, | | 325 | + type: "invalid_request_error", | | 326 | + code: "context_length_exceeded", | | 327 | + } }); | | 328 | + } | | 329 | + // Both targets were tried: this is the exhausted path, not the stop path. | | 330 | + expect(firstHits).toBe(1); | | 331 | + expect(secondHits).toBe(1); | | 332 | + } finally { | | 333 | + await server.stop(true); | | 334 | + } | | 335 | + }); | 271 | 336 | }); |
|