Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(agent): pass sessionId to tools for sub-agent session tracking

Jiayuan Zhangd162ba98a9b6
diff --git a/packages/core/src/agent/runner.ts b/packages/core/src/agent/runner.ts
index c9f81f032f..48bc355d1a 100644
--- a/packages/core/src/agent/runner.ts
+++ b/packages/core/src/agent/runner.ts
@@ -393,9 +393,12 @@ export class Agent {
const profileToolsConfig = this.profile?.getToolsConfig();
const mergedToolsConfig = mergeToolsConfig(profileToolsConfig, options.tools);
const profileDir = this.profile?.getProfileDir();
+ // Use this.sessionId (which may be auto-generated) instead of options.sessionId
+ // (which may be undefined). Without this, sessions_list and sessions_spawn
+ // can't find sub-agent runs because they have no session context.
this.toolsOptions = mergedToolsConfig
- ? { ...options, cwd: effectiveCwd, tools: mergedToolsConfig, profileDir, provider: this.resolvedProvider }
- : { ...options, cwd: effectiveCwd, profileDir, provider: this.resolvedProvider };
+ ? { ...options, sessionId: this.sessionId, cwd: effectiveCwd, tools: mergedToolsConfig, profileDir, provider: this.resolvedProvider }
+ : { ...options, sessionId: this.sessionId, cwd: effectiveCwd, profileDir, provider: this.resolvedProvider };
const tools = resolveTools(this.toolsOptions);
if (this.debug) {