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 — fix(schema): ModelAlias throws AliasMaxDepthError for a chain that settles exactly at the limit — 9-hop chain rejected, effective limit is 8 · Issue #399 · developing-today-forks/opencode

fix(schema): ModelAlias throws AliasMaxDepthError for a chain that settles exactly at the limit — 9-hop chain rejected, effective limit is 8 #399

New issue
Copy link
New issue
Copy link
Closed
Closed
fix(schema): ModelAlias throws AliasMaxDepthError for a chain that settles exactly at the limit — 9-hop chain rejected, effective limit is 8#399
Copy link
Labels
app/schemaPackage: schema (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)

Description

@dezren39
dezren39
opened on Oct 24, 2026
Issue body actions

Problem

ModelAlias.resolveRef throws AliasMaxDepthError for an alias chain that successfully settles exactly on the depth limit. The post-loop check cannot distinguish "the loop settled and broke out" from "the loop ran out of depth", so a legitimate chain one hop shorter than the apparent limit already fails.

Evidence (verified 2026-10-24 on main 58dd3fb)

File: packages/schema/src/model-alias.ts

  • MAX_DEPTH = 10 (line 32); loop is while (depth < MAX_DEPTH) (line 61), incrementing depth at the top of every iteration — including the final iteration that merely confirms the settled provider/model and breaks.
  • After the loop, line 153 unconditionally throws when depth >= MAX_DEPTH, even when the loop exited via break with a fully resolved reference.

Reproduction (Bun, importing packages/core/src/model-alias.ts; global model aliases a0 -> a1 -> ... -> a(n-1) -> openai/gpt-4o, i.e. n expansion hops):

Hops Result
5 "openai/gpt-4o"
8 "openai/gpt-4o"
9 THROWS AliasMaxDepthError: Max alias resolution depth exceeded for: a0
10, 11 THROWS AliasMaxDepthError (expected for 10+; the 9-hop case is the defect)

A 9-hop chain needs 9 expansion iterations plus 1 settling iteration = depth 10, hits the post-loop check, and is rejected despite having resolved. The effective usable limit is therefore 8 hops, not the documented-by-constant 10, and the error message misreports a resolved chain as a runaway one.

Why it matters

Alias chains are how users layer naming (team alias -> provider alias -> concrete model). A chain that is within the intended limit fails with an error that claims the opposite, and the failure boundary (8 usable hops) matches neither the constant nor any documented limit, so users cannot predict whether a config will work without counting loop iterations including the invisible settling pass.

Acceptance criteria

  • A chain that settles within MAX_DEPTH total loop iterations resolves instead of throwing — in particular the verified 9-hop chain above returns openai/gpt-4o.
  • A chain that genuinely never settles within the limit (cycle-free but longer than the limit, and cycles longer than the visited-set catches) still throws AliasMaxDepthError; cycle detection (AliasCycleError) is unchanged.
  • The fix distinguishes settled-vs-exhausted loop exit (e.g. track settlement explicitly) rather than just raising MAX_DEPTH, so the boundary stays exactly at the constant.
  • New tests in packages/core/test/model-alias.test.ts cover the boundary: the largest chain that should resolve, and the smallest that should throw. Existing tests (including test 13, chained expansion) still pass.
  • Dedup checked 2026-10-24: no open or closed issue mentions AliasMaxDepth / max-depth alias behaviour.

Single-repo: ModelAlias lives only in this repo's schema/core packages.

Activity

  1. dezren39 commented on Oct 24, 2026

    @dezren39
    dezren39
    on Oct 24, 2026
    Author
    More actions

    Fixed by PR #403 (merged, squash bca2f2e), which carried the #398 and #399 fixes as one set — GitHub auto-closed only #398 from the Fixes #398 and #399 line, so closing this manually. The fix tracks loop settlement explicitly in packages/schema/src/model-alias.ts and throws AliasMaxDepthError only on an unsettled exit; boundary verified by new tests 18/19 in packages/core/test/model-alias.test.ts (9-hop chain resolves, 10-hop throws; suite 19/19 pass).

  2. dezren39
    closed this as completedon Oct 24, 2026
  3. dezren39
    added a commit that references this issue on Oct 24, 2026

    docs: record the #397, #389 and #398/#399 completions in ROADMAP Done (…

    c45147f
  4. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    app/schemaPackage: schema (pkgs/ or apps/ in this repo)
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/schemaPackage: schema (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.