feat(agent-core): add session management tools - #456
Merged
WinterYukky merged 1 commit intoAug 25, 2026
Merged
Conversation
Adds five session-management tools to the agent-core tool registry: - completeSession(sessionId) — mark a session complete and stop its worker, with a confirmation guard for top-level self-completion - confirmCompleteSession — confirm a guarded completeSession call - listSessions — list sessions by scope (children / descendants / all) with an optional status filter and permission checks - reparentSession — move a session under a new parent, with cycle detection and permission checks - exportSessionDiagnostics — dump session metadata + message history to local JSON for debugging, optionally across the descendant tree completeSession/confirmCompleteSession set agentStatus='completed', emit an agentStatusUpdate webapp event, and stop the worker instance. Tools are registered in requiredTools (confirmCompleteSession) and optionalTools (the rest).
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.
Summary
Adds five session-management tools to the agent-core tool registry, giving
agents first-class control over the session lifecycle and hierarchy.
Motivation
Multi-agent workflows need to inspect and manage the session tree at runtime:
complete a finished session, list children/descendants, move a session under
a new parent, and export diagnostics for debugging. These tools expose that
capability to the model with appropriate permission checks.
Changes
Top-level self-completion is guarded by a confirmation prompt; child sessions
may only complete themselves.
as a required tool).
children/descendants/all)with an optional status filter (
all/active/completed) andparent/self/top-level permission checks.
and permission checks.
local JSON for debugging, optionally across the descendant tree.
tools/index.ts(confirmCompleteSession in requiredTools;the rest in optionalTools).
completeSession / confirmCompleteSession set
agentStatus='completed', emit anagentStatusUpdatewebapp event, and stop the worker instance.Testing
npm run build -w packages/agent-core(tsc) — passvitest runfor the new tools — 31 passed (completeSession 9, confirmCompleteSession 5, listSessions 17)format:check(agent-core) — passNotes
helpers already in
lib/sessions(getChildSessions, getDescendantSessions,reparentSessions, getAllSessionsIncludingChildren).
confirmCreateAgentgate is intentionally left for a follow-up PR:it depends on the sub-agent (
parentAgentId) evolution of the agent-managementtools, which is not yet upstream.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.