Repository navigation
fix(peer): resolve InstanceRef before any session-scoped call in sidecar delivery - #93
Merged
Merged
Conversation
…car delivery Every inbound A2A peer message to an idle session died with "InstanceRef not provided", 100% of the time, before ever reaching the target session — a chicken-and-egg ordering bug, not an idle/busy or default-runtime issue. deliver() called session.get(id) to discover the target's directory (needed to resolve InstanceRef via instanceStore.load), but Session.Service.get itself requires an ambient InstanceRef (session.ts:549, InstanceState.context) to know which project's session store to query. It died on the very first Session-service call, before instanceStore.load was ever reached. Confirmed live: 48 occurrences in one day's log, including against a session idle for 4+ hours (ruling out a startup race), and all four peer review requests sent during this investigation. Fix: the sidecar manager already knows the owning session's directory from when ensureSidecar was called for it. Expose it (sidecarDirectoryFor) and resolve InstanceRef from that before touching any session-scoped service, using the canonical instanceStore.provide() helper instead of a one-off provideService wrap that only covered the final prompt call. Added a real end-to-end regression test (spawns the actual sidecar child process, sends a real socket frame, asserts an assistant reply actually lands) — confirmed it fails on the prior code and passes with this fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
4 tasks done
androidand
added a commit
that referenced
this pull request
Sep 20, 2026
…ost default (#94) * fix(placement): remove subagent model allowlist, prefer loaded then host default A subagent delegated to a host with a model already loaded got evicted for a different model, because local_subagent_placement_models acted as an eligibility filter that ran before the "prefer already loaded" scoring bonus could ever apply — a resident model not on the (manually maintained, undiscoverable) allowlist lost to an allowlisted cold one, paying a multi-second model swap for no real benefit. Remove the allowlist entirely: it required hand-curating every model ever installed with no config surface, docs, or warning when it silently evicted a resident model, and for a self-curated local fleet the failure it guarded against (a model flubbing tool-call JSON) is a one-time visible bad turn, not silent corruption. New priority in bestModel(): loaded > host's own configured default model (GET /api/config/info, already exposed by llama-skein but never consulted here) > parent's own model > plain fit/speed scoring. Every registered, tool-call-capable model is now eligible; residency and the host's default decide ties instead of a global allowlist. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * chore(fork): register lifecycle-inject.test.ts as an owned fork file Omitted from the fork manifest when it was added in #93 (the InstanceRef sidecar-delivery fix) — fork:verify only caught it on the next push, since it runs pre-push, not pre-commit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
deliver()calledsession.get(id)to discover the target's directory (needed to resolveInstanceRef), butSession.Service.getitself requires an ambientInstanceRef— a chicken-and-egg ordering bug, not an idle/busy or default-runtime issue.ensureSidecarregistration. Expose it (sidecarDirectoryFor) and resolveInstanceReffrom that before touching any session-scoped service, using the existinginstanceStore.provide()helper instead of a narrower one-off wrap.Test plan
lifecycle-inject.test.ts: spawns the real sidecar subprocess, sends a real socket frame, asserts an assistant reply actually lands (not just "no error").bun test test/peer/— 125 pass, 0 fail.tsc --noEmitclean.🤖 Generated with Claude Code