Skip to content

Fix interrupted managed responses and safe recovery - #4471

Merged
reachjalil merged 3 commits into
devfrom
codex/reliable-managed-inference
Sep 8, 2026
Merged

reachjalil merged 3 commits into
devfrom
codex/reliable-managed-inference

Conversation

@reachjalil

@reachjalil reachjalil commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

Purpose

An interrupted managed AI response must not appear complete. Preserve partial work,
propagate cancellation and return safe diagnostics without changing accounting or
model settings.

Current scope and conflict resolution

Rebased on dev@0857e81d897b97bc7b10b35c0b2193ec3328dab3 at signed head
49b985e3d109bfac8be4f8f0e97eb625ad3b154e.

  • Preserve current dev's DPA managed-model denial both before request preparation
    and immediately before dispatch. A late policy denial cleans up the timeout,
    cancellation listener and optional analytics without contacting the provider.
  • Retain bounded SSE/JSON handling, first-frame fragmentation, cancellation, safe
    errors, completion-aware analytics and preserved provider usage/terminal reasons.
  • Tool validity belongs to the consumer. Terminal length responses keep partial
    arguments; requested choice counts work consistently. No gateway replay, model
    substitution, forced reasoning settings or hidden-output deadline.
  • Remove full-payload logging and raw provider-error snippets from routine
    diagnostics. Existing role/count/correlation information remains available.
  • Current dev already contains the recovery-warning UI, so duplicate renderer and
    UI test-hook changes were dropped. This PR now changes 13 files, with no
    schema, ledger, catalog, provider-materialization or SDK changes.

Verification — Passed

Passed on the exact head: pnpm evals:pr specs/managed-inference.test.ts —
1 real gateway/server/OpenCode journey, 11 assertion records, 0 failures, 0 skips,
exit 0. The explicit PR runner is local and does not print the E2E placement banner.
The updated journey verifies a freshly DPA-blocked organization produces no upstream
request, alongside completion, fragmentation, timeouts, cancellation, request
preservation and transcript readback. Generation is a controlled loopback fixture.

Supporting checks: 67 proxy tests passed after conflict resolution, including
the current DPA tests and response/analytics tests. Existing model-maintenance
validation and prior inference build/Desktop type checks passed. Exact-head CI is
green, including core tests, packaged Desktop smoke, service builds and required
checks; GitHub reports MERGEABLE / CLEAN and approved. Conditional unselected jobs
are not counted as passes.

Historical UI and packaging checks passed on an earlier reduced revision. They are
not relabeled as current-head proof; the production recovery renderer is now
unchanged from dev. Live provider performance, production provisioning and broadcasts
remain unverified. No merge, release or deployment is performed.

Follow-ups

The earlier broad proposal at 0617f87a is superseded:

Strict-budget work is excluded at the requester's direction. Neither follow-up is
required to land this transport fix. Shared proxy surfaces must be reconciled when
the accounting follow-up lands.

Details: docs/managed-response-reliability.md.

@vercel

vercel Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 8, 2026 8:22pm UTC
openwork-den Ready Ready Preview Sep 8, 2026 8:22pm UTC
openwork-diagnostics Ready Ready Preview Sep 8, 2026 8:22pm UTC
openwork-landing Ready Ready Preview, v0 Sep 8, 2026 8:22pm UTC

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Deploying openwork with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0617f87
Status: ✅  Deploy successful!
Preview URL: https://1a8628d3.openwork.pages.dev
Branch Preview URL: https://codex-reliable-managed-infer.openwork.pages.dev

View logs

Comment thread evals/specs/managed-inference.test.ts Resolved
Comment thread evals/specs/managed-inference.test.ts Resolved
diff-warden[bot]
diff-warden Bot previously approved these changes Sep 5, 2026

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (28e5b32191030198cbd04f17a5a950b931226a6d). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

Comment thread evals/specs/managed-inference.test.ts Resolved
Comment thread evals/specs/managed-inference.test.ts Resolved

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (491104223666c717af335d54b96ae35895888ea3). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

diff-warden[bot]
diff-warden Bot previously approved these changes Sep 8, 2026

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (82bfcf9393109062d6c0d9b80c31f6bad5e60787). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@reachjalil

Copy link
Copy Markdown
Member Author

Test evidence — managed-responses-preserve-completion-partial-work-and-cancellation — ✅ passed

SHA 49b985e · engine v1

✅ passed · 11 expectations passed · 0 failed · 0 pending

screenshots not attached (gh < 2.99; run brew upgrade gh)

verdict passed · 0 user observations · 0 probes · steps 0/0

ℹ️ ASSERTION — 1. Successful responses retain text and final usage once

The real gateway preserves fragmented UTF-8, final usage including a repeated terminal choice, one completion marker, and the server-assigned request identity.

  • ✅ PASS Successful responses retain text and final usage once — The real gateway preserves fragmented UTF-8, final usage including a repeated terminal choice, one completion marker, and the server-assigned request identity.

ℹ️ ASSERTION — 2. The first response frame survives arbitrary transport splits

Heartbeat-free JSON, UTF-8, delimiter and bytewise splits match the unsplit response: text, reasoning, tool fragments and usage remain intact, with one attempt and one DONE.

  • ✅ PASS The first response frame survives arbitrary transport splits — Heartbeat-free JSON, UTF-8, delimiter and bytewise splits match the unsplit response: text, reasoning, tool fragments and usage remain intact, with one attempt and one DONE.

ℹ️ ASSERTION — 3. Request settings and tool-error history are not rewritten

The gateway retains the chosen model, reasoning, routing preferences, transforms and output limits, including malformed historical arguments followed by their matching tool error. It does not substitute defaults or impose a new request contract.

  • ✅ PASS Request settings and tool-error history are not rewritten — The gateway retains the chosen model, reasoning, routing preferences, transforms and output limits, including malformed historical arguments followed by their matching tool error. It does not substitute defaults or impose a new request contract.

ℹ️ ASSERTION — 4. Token-limit endings are not confused with broken transport

Streaming and JSON length endings retain incomplete tool arguments, the provider's terminal reason and usage. The tool consumer, not the transport relay, decides whether a tool can execute.

  • ✅ PASS Token-limit endings are not confused with broken transport — Streaming and JSON length endings retain incomplete tool arguments, the provider's terminal reason and usage. The tool consumer, not the transport relay, decides whether a tool can execute.

ℹ️ ASSERTION — 5. Requested completion choices are preserved in both protocols

A controlled provider honoring n=2 returns both choices through JSON and SSE, including interleaved terminal choices, without retries. This proves relay compatibility, not live-provider support for n.

  • ✅ PASS Requested completion choices are preserved in both protocols — A controlled provider honoring n=2 returns both choices through JSON and SSE, including interleaved terminal choices, without retries. This proves relay compatibility, not live-provider support for n.

ℹ️ ASSERTION — 6. Broken and idle streams preserve only valid partial output

Premature EOF, malformed frames and unrequested choices emit an error without DONE. Idle streams time out at the gateway before the independent client deadline, including a first frame with no complete output.

  • ✅ PASS Broken and idle streams preserve only valid partial output — Premature EOF, malformed frames and unrequested choices emit an error without DONE. Idle streams time out at the gateway before the independent client deadline, including a first frame with no complete output.

ℹ️ ASSERTION — 7. Transport progress does not require visible model output

A provider sending heartbeats continues beyond three idle periods and then completes; only lack of transport progress triggers the stream-idle timeout.

  • ✅ PASS Transport progress does not require visible model output — A provider sending heartbeats continues beyond three idle periods and then completes; only lack of transport progress triggers the stream-idle timeout.

ℹ️ ASSERTION — 8. Cancellation closes upstream before idle expiry

Client abort closes the real provider connection within 700 ms of the abort instant, before the 1000 ms idle deadline, both before any downstream bytes and after partial text. No completion or second attempt is produced.

  • ✅ PASS Cancellation closes upstream before idle expiry — Client abort closes the real provider connection within 700 ms of the abort instant, before the 1000 ms idle deadline, both before any downstream bytes and after partial text. No completion or second attempt is produced.

ℹ️ ASSERTION — 9. Timeout and provider failures remain safe and distinguishable

Real slow headers and JSON bodies produce upstream_timeout, malformed/unfinished JSON has separate categories, provider failures preserve HTTP status and Retry-After, and every case makes one generation attempt.

  • ✅ PASS Timeout and provider failures remain safe and distinguishable — Real slow headers and JSON bodies produce upstream_timeout, malformed/unfinished JSON has separate categories, provider failures preserve HTTP status and Retry-After, and every case makes one generation attempt.

ℹ️ ASSERTION — 10. The real engine persists successful tools and interrupted work

With a baseline model configuration, OpenCode executes Read once and persists its result. Premature provider EOF persists a session error beside partial text, verified by transcript readback, and leaves the busy state. This is not catalog-delivery or billing proof.

  • ✅ PASS The real engine persists successful tools and interrupted work — With a baseline model configuration, OpenCode executes Read once and persists its result. Premature provider EOF persists a session error beside partial text, verified by transcript readback, and leaves the busy state. This is not catalog-delivery or billing proof.

ℹ️ ASSERTION — 11. The existing routing boundary and content-free diagnostics remain intact

Invalid credentials, unknown models, alternate-model selection and a freshly DPA-blocked organization do not reach upstream. Real service stdout/stderr excludes fixture prompt, private provider error, member bearer and provider credential sentinels; structured reporter behavior has separate supporting tests.

  • ✅ PASS The existing routing boundary and content-free diagnostics remain intact — Invalid credentials, unknown models, alternate-model selection and a freshly DPA-blocked organization do not reach upstream. Real service stdout/stderr excludes fixture prompt, private provider error, member bearer and provider credential sentinels; structured reporter behavior has separate supporting tests.

Test run created 2026-09-08T20:16:33.937Z · Source: evals/results/test-runs/2026-09-08T20-16-33-936Z-managed-responses-preserve-completion-partial-work-and-cancellation/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4471 --test-run 2026-09-08T20-16-33-936Z-managed-responses-preserve-completion-partial-work-and-cancellation

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (49b985e3d109bfac8be4f8f0e97eb625ad3b154e). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@reachjalil
reachjalil merged commit 54a7f0f into dev Sep 8, 2026
36 checks passed

This branch was successfully deployed

4 active deployments
Preview – openwork-den — 49b985e3 Deployed Sep 8, 2026 by vercel[bot]
Preview – openwork-landing — 49b985e3 Deployed Sep 8, 2026 by vercel[bot]
Preview – openwork-app — 49b985e3 Deployed Sep 8, 2026 by vercel[bot]
Preview – openwork-diagnostics — 49b985e3 Deployed Sep 8, 2026 by vercel[bot]
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