Skip to content

fix(peer): resolve InstanceRef before any session-scoped call in sidecar delivery - #93

Merged
androidand merged 1 commit into
devfrom
fix/a2a-instanceref-injection
Sep 20, 2026
Merged

androidand merged 1 commit into
devfrom
fix/a2a-instanceref-injection

Conversation

@androidand

Copy link
Copy Markdown
Owner

Summary

  • Every inbound A2A peer message to an idle session died with "InstanceRef not provided", 100% of the time, before ever reaching the target session.
  • deliver() called session.get(id) to discover the target's directory (needed to resolve InstanceRef), but Session.Service.get itself requires an ambient InstanceRef — a chicken-and-egg ordering bug, not an idle/busy or default-runtime issue.
  • Fix: the sidecar manager already knows the owning session's directory from ensureSidecar registration. Expose it (sidecarDirectoryFor) and resolve InstanceRef from that before touching any session-scoped service, using the existing instanceStore.provide() helper instead of a narrower one-off wrap.

Test plan

  • Added lifecycle-inject.test.ts: spawns the real sidecar subprocess, sends a real socket frame, asserts an assistant reply actually lands (not just "no error").
  • Confirmed it fails on the prior code (silent timeout) and passes with the fix.
  • bun test test/peer/ — 125 pass, 0 fail.
  • tsc --noEmit clean.

🤖 Generated with Claude Code

…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>
@github-actions

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@androidand
androidand merged commit 8a707c3 into dev Sep 20, 2026
3 of 9 checks passed
@androidand
androidand deleted the fix/a2a-instanceref-injection branch September 20, 2026 17:48
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant