(MOT-3925) fix(harness): inherit parent provider only when the spawn model is inherited too - #461
Conversation
…herited too
seed_child resolved the child's model and provider from different sources:
an explicit spawn model still picked up the parent turn's provider. A parent
running zai::glm-5.2 spawning a child with model=claude-sonnet-4-6 produced
the incoherent pair zai::claude-sonnet-4-6; the router honors an explicit
provider without catalog checks (by design), so Z.AI answered
{"error":{"code":"1211","message":"Unknown Model, please check the model
code."}} and the child session died with it.
The child's provider now stays a coherent pair with the model: an explicit
request wins; otherwise the parent's provider is inherited only when the
model is inherited too. A spawn that names its own model gets no provider,
letting the router route the model by catalog.
Claude-Session: https://claude.ai/code/session_0155foth69LSS75ebk2gjZ8U
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
skill-check — worker0 verified, 41 skipped (no docs/).
Four for four. Nicely done. |
📝 WalkthroughWalkthroughThe provider derivation logic in seed_child was refactored into a new child_provider helper that enforces coherent model+provider pairing rules: explicit provider always wins, explicit model without provider prevents inheritance, and unset model/provider inherits the parent's provider. Tests were added to validate this matrix. ChangesProvider Inheritance Rule
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant SeedChild
participant ChildProvider
participant ParentRecord
Caller->>SeedChild: spawn request (model?, provider?)
SeedChild->>ChildProvider: child_provider(req, parent_record)
ChildProvider->>ParentRecord: read parent provider
alt provider explicitly set
ChildProvider-->>SeedChild: use request provider
else model set, provider unset
ChildProvider-->>SeedChild: return None (router resolves)
else model and provider unset
ChildProvider-->>SeedChild: inherit parent provider
end
SeedChild-->>Caller: child session with resolved provider
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
harness::spawnwith an explicitmodelbut noprovidersilently attached the parent turn's provider to the child. A parent runningzai::glm-5.2spawningmodel=claude-sonnet-4-6produced the incoherent pairzai::claude-sonnet-4-6. The router honors an explicit provider without catalog membership checks (documented intent —decide()step 1 is cold-catalog tolerant), so provider-zai sent the claude model to Z.AI, which rejected it upstream:The child session died with the raw error as its result, and the parent could not recover by picking another Anthropic model — the retry inherited
zaiagain.Observed in a live multi-agent run: children spawned in-turn (
fact-extractor-b4k9,summarizer-b4k9) inheritedprovider=zaiand failed, while children spawned through the parentless reactive path gotprovider=Noneand ran the same model successfully via catalog routing to anthropic. Reproducible withiii trigger router::complete model=claude-sonnet-4-6 provider=zai messages=[…].Fix
seed_childnow resolves the provider throughchild_provider(): an explicit request wins; otherwise the parent's provider is inherited only when the model is inherited too — model and provider stay a coherent pair. A spawn that names its own model gets no provider and the router routes it by catalog.harness::send'sinjectpath already reuses the last turn's options as one bundle, so spawn was the only place the pair could split.Test
provider_is_inherited_only_together_with_the_modelinsubagent.rscovers the failing case, coherent-pair inheritance, explicit-provider-wins, and parentless spawns. Full harness lib suite: 194 passed.https://claude.ai/code/session_0155foth69LSS75ebk2gjZ8U
Summary by CodeRabbit