Skip to content

rewrite: bound OpenCode service discovery and model lookup by the rewrite deadline - #1442

Merged
thdxr merged 1 commit into
devfrom
fix/rewrite-deadline-lookups
Nov 6, 2026
Merged

thdxr merged 1 commit into
devfrom
fix/rewrite-deadline-lookups

Conversation

@thdxr

@thdxr thdxr commented Nov 6, 2026

Copy link
Copy Markdown
Member

ai rewrite and voice action generation applied their deadline and cancellation only to generation itself. opencode discovery (/api/info, fixed 2s per registration) and the uncached model catalog read (/api/model, fixed 10s) ignored both, so a stalled service could delay fallback well past the configured timeout.

now both lookups use min(remaining budget, existing cap) and honor the caller's cancel flag. other callers (settings catalog, availability checks) keep their fixed timeouts. a cancelled or timed-out catalog read caches nothing, same as any other catalog failure.

tests added:

  • a_service_search_is_bounded_by_the_callers_deadline
  • a_service_search_stops_when_the_caller_cancels
  • a_generation_without_time_or_after_cancellation_fails_promptly
  • a_cancelled_catalog_lookup_returns_nothing_and_caches_nothing

fixes #1435

credit to @0x00-sys for the detailed report and the suggested approach.

A rewrite's caller-supplied deadline and cancellation flag now cover
service discovery (/api/info) and the ranked catalog read (/api/model),
each still capped by its existing per-request timeout. Settings catalog
and availability checks keep their fixed timeouts. A cancelled or
timed-out catalog read caches nothing, like any other lookup failure.
@thdxr
thdxr merged commit 5efdf8f into dev Nov 6, 2026
5 checks passed
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.

AI rewrite timeout and cancellation do not cover service discovery or model lookup

1 participant