The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: attach the branching viewer to its new child before it submits
Tekniumcfaa45ee258c
diff --git a/gateway/session_controls.py b/gateway/session_controls.pyindex 1a165b4d4c1..8425991df15 100644--- a/gateway/session_controls.py+++ b/gateway/session_controls.py@@ -202,7 +202,13 @@ class AuthorityConnection:async def mutate(self, ref, params):from gateway.session_mutations import mutate_session- return await mutate_session(self.authority, self.actor, ref, params)+ result = await mutate_session(self.authority, self.actor, ref, params)+ # The branching viewer navigates straight into its new child; attach it+ # here (create parity) so the first submit is not refused as a stranger.+ child = result.get('branched_session_id') if isinstance(result, dict) else None+ if child and child not in self.subscriptions:+ await self.resume(SessionRef(ref.profile_id, child), {})+ return resultasync def receipt(self, ref, params):return asdict(await self.authority.receipt(self.actor, ref, params.get('admission_id')))diff --git a/tests/gateway/test_session_mutation_branch.py b/tests/gateway/test_session_mutation_branch.pyindex 2192a818433..6ad46290223 100644--- a/tests/gateway/test_session_mutation_branch.py+++ b/tests/gateway/test_session_mutation_branch.py@@ -31,6 +31,11 @@ async def branch_round(home, descriptor, previous=None):receipt = response['result']child = receipt['branched_session_id']assert child != params['session_id']+ if previous is None:+ # The branching viewer owns the child it just created: a submit on the+ # same connection is admitted without an explicit resume first (create parity).+ admitted = await rpc('prompt.submit', session_id=child, input_id='first-child-input', text='FIRST_CHILD_INPUT')+ assert admitted.get('result', {}).get('status') == 'queued', admittedfor sid in (child, params['session_id']):resumed = await rpc('session.resume', session_id=sid)assert 'result' in resumed, resumed