Skip to content

feat(engine): let a child store admit each child it publishes - #2912

Merged
rdimitrov merged 3 commits into
feat/per-agent-registrationfrom
feat/helper-create-seam
Nov 20, 2026
Merged

rdimitrov merged 3 commits into
feat/per-agent-registrationfrom
feat/helper-create-seam

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Stacked on #2883. The base is feat/per-agent-registration; this PR rebases onto main once #2883 merges. Only the three feat(engine) commits are new here.

#2555 registers each helper agent (subagent, parallel branch, team member) with the identity broker before it runs. The host needs a synchronous point where it can do that, and refuse, for every kind of child, and it needs to know which definition the child runs. No such seam exists: engine events are notifications, and the child-store Create the engine already calls carries no definition. #2555 asks for an engine seam to land first, as its own PR.

  • port.ChildSessionCreator: an optional SessionStore capability. When a child store implements it, the engine calls CreateChild instead of Create to first publish a subagent, parallel-branch, or team-member session.
  • port.ChildSessionInfo{DefinitionName}: the definition the child runs. For a subagent it is the call's agent argument. For a team member it is the new agent.MemberBuild.DefinitionName, the definition the factory actually built the member from: the factory falls back to a generic member when the roster's agent type is unknown, so the roster entry is not always what runs. It is empty for a def-less child: the default explorer, a parallel branch, or a generic member.
  • What happens on an error. An error from CreateChild stops the child before its first turn, exactly like a failed Create, and the parent sees the same creation-failure result.
  • port.ChildSessionResumer: an optional store capability the engine calls with ResumeChild before a resumed subagent runs again. It is not a new publication; the host uses it to admit the resumed child, and an error stops the resume. Without it, a child whose admission was refused or lost could be resumed and run.
  • Decorator rule. On child stores the engine uses only Save, Load, Create, SupportsSessionCreate, CreateChild, and ResumeChild. The port doc and docs/architecture/ports.md now say a decorator of such a store may forward just those, as long as it advertises nothing else.
  • No change elsewhere. Stores without the capabilities behave as before.

Issue relationship

Part of #2555.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

Baseline checks

  • Linting (task lint)
  • Pre-review race suite (task test:race)
  • Markdown changed: docs generation/link checks (task docs): no Markdown beyond the changelog
  • User docs/user-facing behavior changed: site build (task site:build): not applicable
  • Guarded engine API affected: compatibility check (task api:check)
  • Intentional engine API change: task api:update + engine/CHANGELOG.md

Tests (engine/agent/child_session_creator_test.go)

  • Each child kind (default subagent, named subagent, background subagent, parallel branch, team member) calls CreateChild exactly once with its kind, parent, and definition, and never Create. A member passes the factory's definition, which is empty when the factory fell back from the roster's agent type.
  • A CreateChild error stops each kind before its model is called. The subagent and team tools return the refusal; the branch fails with it.
  • Resuming a subagent, in the foreground and the background, calls ResumeChild once with no definition, and does not publish the child again. A refused resume never calls the child's model. Disabling the call fails these cases.
  • The background-refusal case waits for the child to end before checking its model was not called.
  • Mutation check: passing "" for team members fails the team case.

Changes

File Change
engine/port/store.go ChildSessionCreator, ChildSessionResumer, ChildSessionInfo
docs/architecture/ports.md Child-store decorators forward what the engine uses
engine/agent/subagent.go, parallel.go, teamsupervisor.go Child publication goes through createChildSession with the definition; MemberBuild.DefinitionName
engine/api/port.txt, agent.txt, engine/CHANGELOG.md API snapshots; "Added" entry
engine/agent/child_session_creator_test.go Tests above

API compatibility

  • Assessment: additive engine Go API (minor, "Added"). No wire change and no behavior change for existing stores.
  • Major/feature changes: none.
  • Upgrade implications: none.

Special notes for reviewers

  • I put the seam on the store rather than adding a new Deps field or tool options. The four child-publication sites already receive their store through host-set options (WithSubagentStore, WithParallelStore, WithTeamToolStore, WithMemberStore), so the host wraps those stores and needs no new plumbing.
  • A decorator that adds CreateChild must still follow the SessionCapabilitySupport rule. The doc comment says so.

🤖 Generated with Claude Code

rdimitrov and others added 3 commits November 20, 2026 15:34
Add port.ChildSessionCreator, an optional SessionStore capability. When
the engine first publishes a subagent, parallel-branch, or team-member
session, it calls CreateChild instead of Create, passing the definition
the child runs. An error stops the child before its first turn, like a
failed Create. Stores without the capability behave as before.

mecak8s uses this to register each helper agent with the identity
broker before it runs (#2555).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A member's factory falls back to a generic member when the roster's
agent type is unknown, so the agent type is not always what runs.
MemberBuild.DefinitionName reports the definition the factory adopted,
and the supervisor passes it to CreateChild instead of the agent type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A resumed subagent was never published again, so a host could not
admit it: a child whose admission was refused, or whose admission was
lost, could be resumed and run. port.ChildSessionResumer gives the
host ResumeChild before a resumed subagent runs again; an error stops
the resume.

The child-store decorator rule is narrowed to what the engine uses on
child stores, and the background refusal test now waits for the child
to end before checking that its model was not called.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdimitrov
rdimitrov force-pushed the feat/helper-create-seam branch from 2656979 to 3977775 Compare November 20, 2026 13:38
@rdimitrov
rdimitrov merged commit 0855bac into feat/per-agent-registration Nov 20, 2026
41 checks passed
@rdimitrov
rdimitrov deleted the feat/helper-create-seam branch November 20, 2026 14:30
rdimitrov added a commit that referenced this pull request Nov 20, 2026
#2912 and #2913 were squash-merged into the base. Their trees match the
commits this branch was built on, so every conflict resolves to this
branch's side and the merged tree is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants