Repository navigation
fix(connections): each named lane runs as its own row's agent, never the legacy one it inherited - #5978
Merged
Conversation
…the legacy one it inherited start_gateway_lanes loads the legacy channel env with `set -a`, so AGENT_ID / AGENT_MXID reach every named lane launched after it. launch_env copied the environment unchanged, and the bridge's identity chain (agent_identity.resolve) prefers the process env, so a lane on another homeserver ran as the legacy agent: its delivery check refused its own rooms, it stamped the wrong receiving instance and advertised the wrong agent id. launch_env now pins a named entry's identity to its row's agent_mxid through agent_identity.launch_environ (the helper the desktop launch path uses) and drops AG2_DEVICE_ENV, the legacy row's credential file. The plan entry carries the row's agent_mxid. A row with none learns it from a verified preview of its own token before launch (env-only: in memory); one still without is refused as `no_identity` rather than inheriting. The legacy row's environment is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Coverage Gate✅ Diff coverage PASSES the 95% bar. Whole-tree (informational): 94%. Diff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
|
Contributor
|
@cla-assistant check |
This was referenced Oct 28, 2026
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.
What changed, and why
After an install moves from ag2.space to s.space, the s.space lane's bridge runs as the ag2.space agent.
src/startup-runtime.shstart_gateway_lanes(L459-464 on main) sources the legacy channel env underset -a, so itsAGENT_ID/AGENT_MXIDare exported to every named lane launched after it.src/connections.pylaunch_env(L1841-1860 on main) copies that environment unchanged; it clears neither the identity variables norAG2_DEVICE_ENV.ag2_sparrow.agent_identity.resolve, reads the process env first.The lane on the other homeserver therefore reports the legacy agent. Its delivery check refuses its own rooms (proactive posts strand or park), it stamps the wrong receiving instance, and it advertises the worker-pool profile under the wrong id.
Fix (the policy lives in
launch_env):agent_mxidthroughagent_identity.launch_environ, the helper the desktop (Hatch) launch path already uses. It drops the inheritedAGENT_IDand setsAG2_IDENTITY_PINNED+AGENT_MXID, so the bridge reads no identity from channel files or the host binding.AG2_DEVICE_ENV(the legacy row's credential file) is dropped for named entries.agent_mxid. Nothing names a server; each row brings its own agent, so any number of homeservers (ag2.space + s.space + dev.s.space) select correctly.reconnectdoes). An env-only launch takes it from that preview in memory. A lane still without an agent is refused (NoIdentity, launch recordreason: no_identity, named inremote-gateway-bridge.log), never started under the inherited identity.Behavior change to note: a named lane whose gateway cannot confirm an agent (unreachable, or a host the DotSpace resolver does not register, since a preview only establishes identity on a verified listing) no longer starts. It used to start under whatever identity it inherited. Reconnecting it once its gateway answers brings it up.
Look first
src/connections.py:launch_env,_learn_missing_identity/_verified_agent, and the two new lines inlaunch.Docs
docs/connections.mdStartup section: the identity pinning and theno_identitylaunch reason (catalog.jsonalready shows today'slast_verified).Before / after
A repro that builds
launch_envfor an s.space row while a legacy identity is in the environment:The new
LaneIdentitytests run against main'sconnections.py:At HEAD:
Ran 268 tests ... OKfortests/connections.test.py.Tests
tests/connections.test.py, newLaneIdentityclass:AGENT_ID/AGENT_MXID/AG2_DEVICE_ENV, withlaunch_envbuilt for an s.space row and for a dev.s.space row: each gets its ownAGENT_MXID,AGENT_IDandAG2_DEVICE_ENVare absent, andagent_identity.resolveanswers with the row's agent even when a channel file names the legacy oneNoIdentity, andlaunchrecordsno_identitywithout spawninglaunchlearns a missing agent from the row's own tokentests/startup-gateway-channel-dir.test.shdrives the realstart_gateway_lanesblock. It now exports a legacy identity and device env and asserts that the lane runs as its row's agent without them, and that an env token with no recorded agent is refused and reported.tests/connections-cli.test.py(env-only and rotation without a named agent now refuse) andtests/connections-no-cloud-trust.test.py(records an agent for its unregistered fixture gateway).connections,connections-cli,connections-no-cloud-trust,agent-api-connections,runtime-api-connections-view,health-check-supervised-bridge-restart,ag2-sparrow-agent-identity, and the shell testsstartup-gateway-channel-dir,startup-runtime-connections-launch-plan,gateway-bridge-wrapper-primary-room,gateway-bridge-wrapper-self-heal.tests/health-check-fix-down-bridges.test.pycase f fails identically on origin/main on this host. It is environment-dependent (a live slack bridge) and unrelated.ruff check,scripts/lint-hermetic-bridge-tests.py,scripts/lint-workspace-resolution.sh --diff: clean. Diff coverage ofsrc/connections.py(diff-cover vs origin/main): 100%.Live path
This is the startup launch path. No post-restart round trip has been captured yet, because restarting the owner's live lanes from this session was out of scope. The real launcher block is exercised by
startup-gateway-channel-dir.test.sh. A round trip on a host with both an ag2.space and an s.space lane is still owed before approval.Overlap
#5911 also edits
launch_env: it clears the URL keys in place ofREMOTE_TASK_URL. The two changes are adjacent and should merge mechanically. This PR stays out of the shared room-tool connection resolver work.🤖 Generated with Claude Code