Skip to content

fix(opencode-go): register model catalog to fix context window detection#92913

Merged
steipete merged 2 commits into
openclaw:mainfrom
kumaxs:fix/opencode-go-model-context-window
Jun 14, 2026
Merged

fix(opencode-go): register model catalog to fix context window detection#92913
steipete merged 2 commits into
openclaw:mainfrom
kumaxs:fix/opencode-go-model-context-window

Conversation

@kumaxs

@kumaxs kumaxs commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix OpenCode Go context-window metadata for existing and newly onboarded installations without writing the plugin catalog into user config.

  • Register a lightweight providerCatalogEntry for the plugin's complete offline 18-model catalog.
  • Keep onboarding config-neutral so built-in routing, mixed model APIs, and future catalog updates remain provider-owned.
  • Warm opencode-go/deepseek-v4-pro as a 1,000,000-token model before synchronous memory-flush/compaction checks.

Closes #92912.

Why this shape

The original patch copied all catalog rows into models.providers.opencode-go during onboarding. That only fixed newly configured installations and persisted a stale duplicate provider override. Core already has a lifecycle-owned static-catalog warmup seam; the missing piece was the plugin's lightweight discovery entry.

Real behavior proof

  • Behavior addressed: OpenCode Go models fell back to the 200,000-token compaction budget because their provider-owned catalog was absent from lifecycle cache warmup.
  • Real environment tested: Current OpenClaw source checkout on macOS, using the real bundled plugin manifest, provider discovery loader, context cache, and memory-flush resolver.
  • Exact steps or command run after this patch: node --import tsx --input-type=module -e '<refresh context cache and resolve opencode-go/deepseek-v4-pro memory-flush context>'
  • Evidence after fix: Copied console output from the production-path probe: {"contextWindowTokens":1000000,"wroteModelConfig":false}
  • Observed result after fix: The synchronous compaction path receives the provider's 1,000,000-token window, and onboarding/runtime config remains unmodified.
  • What was not tested: None for the changed behavior; the focused credentialed OpenCode Go gateway smoke passed at https://github.com/openclaw/openclaw/actions/runs/27508944084.

Verification

  • node scripts/run-vitest.mjs extensions/opencode-go/index.test.ts extensions/opencode-go/onboard.test.ts src/agents/context.opencode-go.test.ts src/agents/embedded-agent-runner/model.static-catalog.test.ts src/agents/context.lookup.test.ts — 5 files, 52 tests passed.
  • pnpm tsgo:extensions — passed.
  • pnpm check:test-types — passed.
  • Production-path probe after cache refresh: contextWindowTokens: 1000000, wroteModelConfig: false.
  • Testbox changed gate: tbx_01kv3q8mwzxsfz01eftsym4kr0 — passed.
  • Testbox production build: tbx_01kv3qsfkdpddjaerr3ghprjn1 — passed.
  • Fresh autoreview: clean, no actionable findings (0.96 confidence).
  • Focused live OpenCode Go gateway smoke: passed at https://github.com/openclaw/openclaw/actions/runs/27508944084

@openclaw-barnacle openclaw-barnacle Bot added extensions: opencode-go size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 14, 2026
@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 14, 2026, 3:53 AM ET / 07:53 UTC.

Summary
Registers the opencode-go static model catalog during provider onboarding by exporting catalog constants and passing them to applyProviderConfigWithModelCatalog.

PR surface: Source +10. Total +10 across 2 files.

Reproducibility: yes. at source level: current opencode-go onboarding is a no-op, while memory flush resolves context with async loading disabled and falls back to the default when no config/cache metadata is available. I did not run a live gateway reproduction in this read-only review.

Review metrics: 1 noteworthy metric.

  • Provider config registration: 1 added. The PR changes opencode-go onboarding from no-op to writing provider model metadata into config, which affects upgrade/provider behavior before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Change the new local import to ./provider-catalog.js.
  • Update the opencode-go onboarding coverage to assert catalog registration/context windows instead of the old no-op identity behavior.
  • [P1] Add redacted real after-fix proof for openclaw models list or the compaction threshold path, then update the PR body so ClawSweeper re-reviews automatically.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The body includes copied before/after terminal snippets, but it does not include an accepted Real behavior proof section and the repository proof check failed; add redacted terminal output/logs/screenshots or linked artifacts from a real OpenClaw setup and update the PR body to trigger re-review.

Risk before merge

  • [P1] External contributor proof is still insufficient: the PR body has before/after snippets, but the repository's real behavior proof gate rejected it because it lacks the required after-fix Real behavior proof section from a real setup.
  • [P1] Once the import is fixed, onboarding will start writing opencode-go provider api/baseUrl/model metadata into user config; that repairs context windows but needs upgrade proof for existing custom opencode-go provider blocks and model entries.

Maintainer options:

  1. Prove config-preserving onboarding (recommended)
    Keep the catalog-registration shape only if the PR adds proof or focused coverage showing existing opencode-go apiKey/custom model entries are preserved while the missing context windows register.
  2. Move the fix to prepared metadata
    If maintainers do not want onboarding to persist the full catalog, repair the context-window cache or prepared provider metadata path instead of writing the provider catalog into config.
  3. Accept onboarding normalization
    Maintainers may intentionally accept provider config normalization on re-onboarding because this is a P1 long-context bug, but that should be an explicit upgrade choice.

Next step before merge

  • [P1] Manual review is needed because automation can repair the import, but it cannot supply the external contributor's real setup proof or decide the provider-config persistence tradeoff.

Security
Cleared: The diff only exports local constants and imports local provider catalog data; no dependency, workflow, lockfile, script, credential, or external code-execution surface changed.

Review findings

  • [P1] Use the NodeNext import extension — extensions/opencode-go/onboard.ts:7
Review details

Best possible solution:

Land a corrected provider-owned fix that compiles under NodeNext, proves opencode-go context-window resolution after onboarding, and preserves or intentionally normalizes existing provider config during upgrade.

Do we have a high-confidence way to reproduce the issue?

Yes at source level: current opencode-go onboarding is a no-op, while memory flush resolves context with async loading disabled and falls back to the default when no config/cache metadata is available. I did not run a live gateway reproduction in this read-only review.

Is this the best way to solve the issue?

No, not as submitted: the catalog-registration direction is plausible and matches sibling providers, but the patch is not mergeable until the NodeNext import, proof, and upgrade/config evidence are fixed. Maintainers should also confirm whether onboarding persistence is the intended layer versus a prepared metadata/cache repair.

Full review comments:

  • [P1] Use the NodeNext import extension — extensions/opencode-go/onboard.ts:7
    This new relative import omits .js, so prod/test type checks and the extension package boundary fail with TS2835. Change it to ./provider-catalog.js; otherwise opencode-go cannot typecheck.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against e99ab385cfe1.

Label changes

Label changes:

  • add P1: The PR targets a linked P1 bug where opencode-go sessions can compact far too early because 1M-window models fall back to the 200K default.
  • add merge-risk: 🚨 compatibility: The diff changes onboarding to write provider model catalog data into user config, which can affect existing opencode-go configurations during re-onboarding.
  • add merge-risk: 🚨 auth-provider: The written provider api/baseUrl/model metadata affects provider routing and model selection for opencode-go.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The body includes copied before/after terminal snippets, but it does not include an accepted Real behavior proof section and the repository proof check failed; add redacted terminal output/logs/screenshots or linked artifacts from a real OpenClaw setup and update the PR body to trigger re-review.

Label justifications:

  • P1: The PR targets a linked P1 bug where opencode-go sessions can compact far too early because 1M-window models fall back to the 200K default.
  • merge-risk: 🚨 compatibility: The diff changes onboarding to write provider model catalog data into user config, which can affect existing opencode-go configurations during re-onboarding.
  • merge-risk: 🚨 auth-provider: The written provider api/baseUrl/model metadata affects provider routing and model selection for opencode-go.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The body includes copied before/after terminal snippets, but it does not include an accepted Real behavior proof section and the repository proof check failed; add redacted terminal output/logs/screenshots or linked artifacts from a real OpenClaw setup and update the PR body to trigger re-review.
Evidence reviewed

PR surface:

Source +10. Total +10 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 13 3 +10
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 13 3 +10

What I checked:

Likely related people:

  • ImLukeF: Live PR metadata shows Providers: add Opencode Go support #42313 added Opencode Go support and onboarding, authored by ImLukeF and merged in March 2026. (role: introduced opencode-go provider support; confidence: medium; commits: 7761e7626ffe; files: src/commands/onboard-auth.config-opencode-go.ts, src/commands/opencode-go-model-default.ts, docs/providers/opencode-go.md)
  • vincentkoc: Vincent merged the original Opencode Go support PR and authored follow-up commits in that PR plus later opencode-go/doc history. (role: merger and follow-up contributor; confidence: medium; commits: 7761e7626ffe, 8c802aa68351; files: extensions/opencode-go/onboard.ts, extensions/opencode-go/provider-catalog.ts, docs/providers/opencode-go.md)
  • steipete: Current blame and log history attribute the present opencode-go onboarding/catalog files and memory-flush helper lines in this checkout to Peter's recent refactor/base commits. (role: recent area contributor; confidence: high; commits: 1d9b9ef48f84, 763eff8b3268; files: extensions/opencode-go/onboard.ts, extensions/opencode-go/provider-catalog.ts, src/auto-reply/reply/memory-flush.ts)
  • xdanger: Commit 399f5bc records Kros Dai as co-author on the recent context metadata/cache refresh that changed the resolver surface implicated by this bug. (role: adjacent context-metadata contributor; confidence: medium; commits: 399f5bc99351; files: src/agents/context.ts, src/agents/context-resolution.ts, src/agents/embedded-agent-runner/model.static-catalog.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 14, 2026
kumaxs and others added 2 commits June 14, 2026 19:43
…odelCatalog

Previously, applyOpencodeGoProviderConfig was an empty no-op that returned
cfg unchanged. This meant the opencode-go plugin's static model catalog
(including correct contextWindow values like deepseek-v4-pro: 1M) was
never registered into the runtime model context window cache.

As a result, resolveContextTokensForModel() failed to look up any
opencode-go model and fell back to the hardcoded 200K default, causing
premature compaction (threshold 156K instead of 956K).

Changes:
- Export OPENCODE_GO_MODELS and OPENCODE_GO_OPENAI_BASE_URL from
  extensions/opencode-go/provider-catalog.ts
- Implement applyOpencodeGoProviderConfig to call
  applyProviderConfigWithModelCatalog with the full static model catalog,
  matching the pattern used by deepseek and other built-in providers.

Fixes: agent compaction triggering at ~156K tokens on 1M context models
Refs: openclaw#92912
@steipete
steipete force-pushed the fix/opencode-go-model-context-window branch from 996d7b7 to 8255227 Compare June 14, 2026 18:58
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S proof: supplied External PR includes structured after-fix real behavior proof. and removed size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 14, 2026
@steipete

Copy link
Copy Markdown
Contributor

Land-ready proof for exact head 82552270b9b7015140ffc562fa812b2fd8388fd3:

The implementation uses the plugin-owned static catalog discovery seam; it does not persist the provider catalog into user config. OpenAI and Anthropic tool-calling paths are untouched.

@steipete
steipete merged commit 3563850 into openclaw:main Jun 14, 2026
206 of 216 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 15, 2026
…aw#92913)

Register OpenCode Go's provider-owned static catalog so lifecycle cache warmup supplies the correct context window to memory flush and compaction without persisting catalog rows in user config.

Fixes openclaw#92912.

Co-authored-by: kumaxs <[email protected]>
wangmiao0668000666 pushed a commit to wangmiao0668000666/openclaw that referenced this pull request Jun 17, 2026
…aw#92913)

Register OpenCode Go's provider-owned static catalog so lifecycle cache warmup supplies the correct context window to memory flush and compaction without persisting catalog rows in user config.

Fixes openclaw#92912.

Co-authored-by: kumaxs <[email protected]>
crh-code pushed a commit to crh-code/openclaw that referenced this pull request Jun 18, 2026
…aw#92913)

Register OpenCode Go's provider-owned static catalog so lifecycle cache warmup supplies the correct context window to memory flush and compaction without persisting catalog rows in user config.

Fixes openclaw#92912.

Co-authored-by: kumaxs <[email protected]>
badgerbees pushed a commit to badgerbees/openclaw that referenced this pull request Jul 8, 2026
…aw#92913)

Register OpenCode Go's provider-owned static catalog so lifecycle cache warmup supplies the correct context window to memory flush and compaction without persisting catalog rows in user config.

Fixes openclaw#92912.

Co-authored-by: kumaxs <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: opencode-go merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode-go plugin: model contextWindow not loaded, all models fall back to 200K

2 participants