Repository navigation
Conversation
…on record (#1347) run --format json carries no model on any event, and free-tier gateway models do not reliably self-report, so every critic and the planner were discarded. Read the assistant message's providerID/modelID from `opencode export <sessionID>` (an engine-observed fact, never argv) before falling back to self-report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
…w and plan compile through the real child path (#1347) - engine record beats a disagreeing self-report; the user message (the request) is never read; an ambiguous record does not pick; no record falls back to self-report - spec review / plan compile tests via $AMICO_CRITIC_BIN, RED on the pre-fix code with the issue's exact symptoms - comments no longer claim self-report is the only channel Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jacktrnr
marked this pull request as ready for review
November 23, 2026 22:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On the free tier,
amico spec reviewdiscarded every judgment critic andamico plan compileexited 64, both with "the child did not report the model it ran as".opencode run --format jsoncarries no model on any event (confirmed again here: onlystep_start/text/step_finish). That left the child's self-report as the only source, and free gateway models (e.g.opencode/nemotron-3.5-lightning-free) don't reliably name themselves.runAgentfails closed, so every free-tier critic and planner was lost.Fix: read the model from the engine's session record
After the child exits,
runAgenttakes thesessionIDfrom the event stream (every event carries one) and runsopencode export <sessionID>in the child's cwd with the child's allowlisted env. It then reads the assistant message'sproviderID/modelID. The engine writes those fields for the provider call it actually made. They are the same fields as themessage.updatedevents that json mode suppresses.The order of evidence is now:
Guards:
modelis the request (argv). A record with no assistant message fails closed.^ses_[A-Za-z0-9]+$) before it goes on argv.spec reviewandplan compileboth go throughrunAgent, so this one change fixes both symptoms.Why not the engine-overlay change the issue suggested
I weighed two options:
runemitproviderID/modelIDin--format json.Within (2), taking the model from the
--modelthe parent passed is ruled out. That is exactly what the check forbids: the ledger'scritics[].modelmust be a verified fact, never the request ("a request masquerading as a fact"). The session record is the other form of (2), and it doesn't weaken that guarantee. It is the engine's record of the call it made, the same data (1) would put into the stream.I chose the session record over the overlay for three reasons:
$AMICO_CRITIC_BIN, elseopencodeon PATH, which is often stock upstream opencode. An overlay change only helps when the child happens to be the vendored Amicode engine.opencode exportworks with both: verified on stock opencode 1.19.6.run.tsin the overlay, a manifest refresh, a binary rebuild, and a release before anyone benefits. This change is about 60 lines inagent_spawn.tsand touches no overlay files.Tradeoff: each child that answers costs one extra local
exportprocess (a database read, no model call).The
REPORT_RULEprompt text still asks the child to name itself. It is still the fallback, so I left it alone to avoid changing model behavior. Only the code comments that said self-report was "the only channel" were updated.Tests (written first, RED on
origin/main)agent_spawn.test.ts, newdescribe(deliberate tooling: spec review critics + plan compile fail — child 'did not report the model it ran as' #1347). The fixture now emitssessionIDlike the real stream and answersexport <sessionID>. Cases:export <sid>in the child's cwdA mutation check confirmed these fail when the precedence, the ambiguity rule, or the assistant-only rule is broken.
spec_review.test.tsandplan_compile.test.tsdrive the real child path ($AMICO_CRITIC_BIN→runAgent→ spawn) through a small wrapper script,test/fixtures/fake_agent_bin.ts. On the pre-fixagent_spawn.tsthey fail with the issue's exact symptoms:critics: [], andplan compilereturningexit_code: 64.All existing tests are kept, including "DISCARDS a critic that will not name itself", which still holds with no engine record.
Results:
pnpm --filter @amicode/amico-run typecheck: clean.vitest:agent_spawn/spec_review/plan_compileall green (113 tests).upgrade-*tests under full parallel load; those tests pass alone and don't touch this code.drift_gate: PASS (no overlay change).Live verification (darwin-arm64, real
opencode1.19.6,AMICO_CRITIC_MODEL=opencode/nemotron-3.5-lightning-free)amico spec review <spec> --jsonreturnedreview_verdict: "approved".hidden-failure,decompositionandinterface-boundaryall ran, and every critic was stampedopencode/nemotron-3.5-lightning-free.amico plan compile <spec> --jsonreturnedok: trueand wrote a plan, withcompiled_by.model = opencode/nemotron-3.5-lightning-free.Across 3 live reviews, two still lost one critic to unrelated causes:
database is lockedfrom the shared engine DBI couldn't reproduce the lock with overlapping
export+runchildren: 0 locks in 21 processes. Those failures still show up asdegraded, as designed.Closes #1347
🤖 Generated with Claude Code