fix: persist agent name on sub-session nodes across a delivery-order race (v6.7.4) - #83
Closed
Diego Colombo (colombod) wants to merge 1 commit into
Closed
Conversation
Diego Colombo (colombod)
force-pushed
the
stack/pr70-on-pr78
branch
from
August 26, 2026 10:58
8c82734 to
fc1fc0f
Compare
…rder race (#484) ensure_session_node's Tier-2 (node-already-exists) branch dropped the `agent` value carried by the parent's delegate:agent_spawned event when the child's own session:start created the node first. Apply the same populate-if-missing rule already used for working_dir so the agent name is backfilled onto the existing node without ever clobbering an already-set value. Fixes the empty :Session.agent that silently undercounted `WHERE s.agent = ...` queries on the shared server. Also bump server version 6.7.3 -> 6.7.4. Tests (RED before fix, GREEN after): - unit: in-memory two-writer reproduction of the child-first ordering - E2E: isolated throwaway Neo4j, real Session/Delegation handlers, child session:start before parent delegate:agent_spawned; asserts agent persisted 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Diego Colombo (colombod)
force-pushed
the
fix/issue-484-agent-field-on-79
branch
from
August 26, 2026 11:01
5ab7ba8 to
943e87c
Compare
Diego Colombo (colombod)
marked this pull request as draft
August 26, 2026 11:56
Collaborator
Author
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 this fixes
A spawned sub-session's agent name was silently lost whenever the child's event landed before the parent's — leaving
:Session.agentempty and undercounting everyWHERE s.agent = ...query on the shared server. This restores correct per-agent attribution. Fixesmicrosoft-amplifier/amplifier-support#484. Bumps server version 6.7.3 → 6.7.4.Root cause (verified against shipped source)
The
agentname for a spawned sub-session arrives only on the parent'sdelegate:agent_spawnedevent (top-levelagent); the child's ownsession:startcarries none. Both flow throughensure_session_node(pipeline step 2). Its Tier-2 "node already exists" branch upserted only{labels, status, session_id}, so when the child'ssession:startcreated the node first, the parent's lateragentvalue was dropped. (upsert_nodeuses key-present mergeSET n += props, so it was never the culprit — the branch simply never includedagent.)The fix (surgical — one branch)
A populate-if-missing rule for
agent, alongside theworking_dirone #79 introduced:Writes only when the event supplies
agentand the node still lacks it, so an already-set value is never clobbered. No SessionHandler/bundle changes (out of scope).Verification — RED before, GREEN after (real, no mocks at the gate)
tests/test_services.py::TestEnsureSessionNodeAgentField) — two writers sharing oneGraphStatereproduce the child-first ordering: RED without the fix, GREEN with it. Full file: 60 passed.tests/neo4j/test_agent_field_ordering_race.py) — a throwawayneo4j:5.26.22-communitycontainer drives the realSessionHandler+DelegationHandleracross two stores sharing one Neo4j, childsession:startbefore parentdelegate:agent_spawned, and asserts:Session.agentpersisted. RED without the fix (agent=None), GREEN with it (~24s).SERVER_VERSIONverified reporting6.7.4from package metadata.Stack
Base is #79's head, not
main— merge after #79. The fix slots directly into thestub_datapopulate-if-missing block #79 introduced, so there is no conflict with #79 (an independent merge ontomainwould conflict on that same hunk).🤖 Generated with Amplifier
Co-Authored-By: Amplifier 240397093+microsoft-amplifier@users.noreply.github.com