GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(core): time-based model availability with fallback by ooaklee · Pull Request #64222 · anomalyco/opencode

Conversation

@ooaklee

@ooaklee ooaklee commented Nov 16, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Related to #63712. Replaces #63728, automatically closed for an incomplete PR template.

Closes #63712

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds opt-in model availability windows and configured fallbacks, evaluated before each LLM step. Windows use an IANA timezone and include the start but exclude the end. Equal endpoints cover the whole local calendar day; overnight windows retain the starting day's filter.

Blocked models follow fallback chains, including across providers with the target provider's credentials. Invalid chains return a no-route error, and plugin overrides are availability-checked.

The prompt footer and model picker retain the configured selection; the assistant message footer and cost accounting reflect the serving fallback. No UI changes are introduced. Behavior is enabled by model-level availability; there is no separate experimental flag.

How did you verify your code works?

Validated d128a51e4b, including the merge of dev at 26f2522e60:

  • 20 focused tests passed across ten randomized runs (200 executions), plus 378 wider session/resolver regressions.
  • Boundary tests fail against the previous evaluator and pass with the fix.
  • The session suite now uses real services for five core cases, reduced from 328 to 122 lines.
  • Root bun run check, core bun run typecheck:tsc, protocol bun run check:generated, and site bun typecheck / bun run build passed.

No live-provider end-to-end test was run for this update.

Screenshots / recordings

Not applicable; no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #63712, #48991

Public API: adds optional availability to model config and Model.Info/OpenAPI, plus two new session error types; blocked models returned by experimental.model.resolve are now ignored (backwards compatible)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ooaklee and others added 5 commits November 13, 2026 09:46
@ooaklee
feat(core): time-based model availability with fallback
4acc61f
Closes anomalyco#63712
@ooaklee
fix(core): distinct fallback diagnostics and per-test availability la…
7c6eb3e
…yers

- ModelBlockedByAvailabilityError now carries a reason code (no-fallback,
  fallback-not-found, cycle-detected, depth-exceeded, malformed-fallback)
  and the offending fallback ref, with a message per case
- detect fallback cycles explicitly via a visited set instead of only
  relying on the three-hop depth cap
- rebuild session-model-availability tests on a per-test layer factory so
  agent/resolver stub state is no longer shared between tests
- document that fallback substitution is logged server-side but not
  surfaced in the UI, and note chain limits and cycle reporting
- regenerate the OpenAPI spec for the new availability schemas
@ooaklee
fix(core): shared fallback hop-limit constant and typed reason assert…
db73e8d
…ion in tests

- extract FALLBACK_HOP_LIMIT so the depth-exceeded message prints the
  actual limit instead of undefined
- read the blocked reason via Cause.findErrorOption + instanceof instead
  of parsing the serialized error, and assert the depth-exceeded message
@ooaklee
fix(core): availability-gate plugin model resolution and harden schemas
c0c06cf
- gate the experimental.model.resolve hook: a hook-chosen model that a
  window currently blocks is ignored and the availability-approved
  selection (or its fallback) is used, with a log line; same-provider
  restriction and unchanged-model fast path preserved
- bound the per-timezone Intl.DateTimeFormat cache (32 entries,
  evict-oldest with recency refresh) so catalog input cannot grow it
- validate Model.Availability start/end against the HH:mm pattern in the
  schema (defense in depth) and regenerate the OpenAPI spec
- drop the unreachable malformed-fallback branch after Model.Ref.parse
- keep the provider overlay's days array copy in spread style
- docs: start === end matches one minute; windows evaluate as wall-clock
  in the named zone with DST per its rules; model-level availability
  replaces catalog/plugin-provided availability; cost accounting uses
  the effective (fallback) model while the display stays configured
- tests: hook override blocked -> fallback wins, hook override allowed ->
  honored, #variant fallback ref through the runner, and a wrapping
  window with only its head day listed
@ooaklee
fix(core): availability-check hidden hook override targets
8eec5e0
The experimental.model.resolve hook's availability gate looked the
override model up only in the picker list; a same-provider target hidden
from that list passed as 'unknown' and the resolver could still load it
from the broader catalog, letting a hidden model with a blocking window
serve the request. Look the override up through Model.Service.get (the
full catalog) and availability-check that instead; a blocked override
still falls back to the availability-approved selection.

Tests: same-provider hook override to a blocked (picker-listed) model,
a blocked model hidden from the picker, and an allowed model hidden
from the picker; the layer now stubs Model.Service with a catalog
option.
@ooaklee
ooaklee marked this pull request as ready for review November 16, 2026 12:57
@ooaklee
chore: merge latest dev into availability branch
bb32a9d
opencodejr[bot]
opencodejr Bot reviewed Nov 16, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The feature works as described: while a window blocks a model, its configured fallback serves the request. I ran OpenCode from source on the base and on this branch with a simulated model blocked all day and a fallback set. On the base the availability key is ignored. With this change the request goes to the fallback, and the message footer shows the fallback model. The new tests, the wider packages/core session and runner suites, a tsc -b type check of core and check:generated all pass.

Public API (all additive, backwards compatible):

  • Config: optional providers.<id>.models.<id>.availability with mode, windows[] (days, start, end), timezone and fallback.
  • Model.Info: optional availability field, also in the OpenAPI spec (Model.Availability, Config.Model.Availability.Window).
  • New session errors: ModelBlockedByAvailabilityError and ModelAvailability.TimezoneError.
  • Plugin hook: models returned by experimental.model.resolve are now ignored while a window blocks them.

Concerns, details inline:

  • The window end is inclusive by minute. This is worth settling before it becomes a config contract.
  • The docs say the UI keeps showing the configured model, but the message footer shows the fallback.
  • test/session-model-availability.test.ts is 328 lines of mostly stubs (resolver, agents, hooks and catalog, with as never casts). Please cut it down to a few core cases: a fallback, a chain of fallbacks, a cycle, no fallback, and a hook override that is blocked.

Related: #63712, #48991

Before

After

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/model-availability.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread services/site/src/docs/content/config.mdx Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ooaklee
fix(core): clarify availability windows and simplify coverage
d128a51
opencodejr[bot]
opencodejr Bot reviewed Nov 16, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Both earlier points are fixed. Windows now include start and exclude end, and equal endpoints cover the whole local day. The docs now say which parts of the UI show the configured model and which show the fallback. The session test is now small and uses real services. I re-ran the new tests, the core type check, check:generated, and the TUI with a blocked simulated model, and the fallback still served the request. The public API is the same as in my last review: optional availability on model config and on Model.Info (with its OpenAPI entries), two new session errors, and availability checks on experimental.model.resolve overrides. All of it is backwards compatible. No new concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ooaklee

ooaklee commented Nov 16, 2026

Copy link
Copy Markdown
Author

Addressed the remaining test-simplification point from the review in d128a51. The session suite is now 122 lines with the five requested cases: fallback, fallback chain, cycle, no fallback, and blocked hook override. It uses the real runner, resolver, catalog and hooks through existing fixtures, without local service stubs or as never casts. The hidden-hook case also verifies that the same hook succeeds once its target is unblocked.

Validation passed: 20 focused tests across ten randomized runs, 378 wider regressions, repository checks, core TypeScript, generated API checks and the full site build. The reduction intentionally removes direct tests for some additional fallback/selection cases; it does not change those production paths. The two inline points are addressed in their respective threads.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ooaklee
chore: merge dev and reconcile model availability contracts
34c37fa
@cepice cepice mentioned this pull request Nov 28, 2026
[FEATURE]: Configurable model fallback on transient errors and timeouts #48991
Open
1 task done

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Time-based model availability with fallback

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@ooaklee
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.