openclaw - ✅(Solved) Fix subagent session label: add {agentId} auto-prefix template [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72074Fetched 2026-04-27 05:35:17
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
closed ×1commented ×1cross-referenced ×1

Fix Action

Fix / Workaround

Workaround (方案1 — implemented separately)

PR fix notes

PR #72128: feat: implemented configurable label templates for spawned agent sess…

Description (problem / solution / changelog)

Summary

  • Problem: sessions_spawn accepted a plain label param with no convention or auto-prefix mechanism; in multi-agent pipelines (Manager / Extractor / Scorer / Reporter), the sessions list shows raw
    user-supplied labels with no way to filter or identify which agent spawned a session.
  • Why it matters: Operators running multi-agent workflows must manually prefix every sessions_spawn call — fragile, discipline-dependent, and breaks when callers omit it.
  • What changed: Added a labelTemplate config field (string with {agentId} and {taskPreview} tokens) to both agents.defaults.subagents and per-agent agents.list[].subagents. When sessions_spawn is called
    without an explicit label, the template fires as fallback. Per-agent config overrides defaults. Explicit label always wins.
  • What did NOT change: No change to spawn behavior, session lifecycle, registry, ACP path, or any existing config keys. Fully additive and backwards-compatible.

Change Type

  • Feature

Linked Issue/PR

  • Closes #72074
  • This PR fixes a bug or regression

Root Cause (if applicable)

N/A — feature addition, not a bug.

  • Root cause: N/A
  • Missing detection / guardrail: N/A
  • Contributing context: N/A

Regression Test Plan (if applicable)

N/A — no existing behavior changed.

  • Coverage level that should have caught this: N/A
  • Target test or file: N/A
  • If no new test is added, why not: Pure additive config + fallback path. No existing code path altered; template only fires when label is absent and labelTemplate is configured.

User-visible / Behavior Changes

New optional config field labelTemplate in agents.defaults.subagents and agents.list[].subagents. No change when field is absent (default behavior unchanged).

Example config:

{                                                         
  "agents": {
    "defaults": {
      "subagents": { "labelTemplate": "{agentId}-{taskPreview}" }                                                                                                                                            
    }                                                            
  }                                                                                                                                                                                                          
}

Tokens: {agentId} = target agent id, {taskPreview} = first 40 chars of task (newlines stripped).

Diagram

Before:
sessions_spawn(task, label?) -> label || "" (no template)

After:

sessions_spawn(task, label?) -> explicitLabel                                                                                                                                                                
                              ?? perAgentTemplate(agentId, task)
                              ?? defaultsTemplate(agentId, task)                                                                                                                                              
                              ?? ""

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: macOS 25.0.0
  • Runtime: Node 22+
  • Relevant config: agents.defaults.subagents.labelTemplate: "{agentId}-{taskPreview}"

Steps

  1. Set agents.defaults.subagents.labelTemplate to "{agentId}-{taskPreview}" in config.
  2. Invoke sessions_spawn with agentId: "scorer", task: "Score all candidates", no label.
  3. Check sessions list.

Expected

  • Session label: scorer-Score all candidates

Actual

  • Before fix: label is empty string.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Code-reviewed manually; no runtime environment available for live verification (Node 18 on dev machine, repo requires Node 22+).

Human Verification

  • Verified scenarios: config type additions, zod schema additions (both defaults + per-agent), template substitution logic, explicit label precedence, per-agent-over-defaults precedence.
  • Edge cases checked: no labelTemplate configured (returns ""), no agentId provided (token replaced with ""), task longer than 40 chars (truncated), task with newlines (stripped).
  • What I did not verify: live runtime spawn with actual session list inspection.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? Yes — new optional fields added, no existing fields changed
  • Migration needed? No

Risks and Mitigations

  • Risk: Template with no tokens (e.g. "fixed-label") stamps every session with the same label.
    • Mitigation: Acceptable — user-configured, documented behavior. Could add a lint warning later.
  • Risk: opts?.config is snapshotted at tool-construction time, not call time.
    • Mitigation: Consistent with all other opts?.config usage in the same function; not a regression.

Changed files

  • src/agents/tools/sessions-spawn-tool.ts (modified, +15/-1)
  • src/config/types.agent-defaults.ts (modified, +2/-0)
  • src/config/types.agents.ts (modified, +2/-0)
  • src/config/zod-schema.agent-defaults.ts (modified, +1/-0)
  • src/config/zod-schema.agent-runtime.ts (modified, +1/-0)

Code Example

{
  "agents": {
    "defaults": {
      "subagents": {
        "labelTemplate": "{agentId}-{taskPreview}"
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Feature Request: subagent session label auto-prefix from agent name

Problem

When spawning subagents via sessions_spawn, the label parameter is user-provided text with no convention or auto-prefix mechanism. This makes it difficult to identify which agent a session belongs to when looking at the sessions list.

In multi-agent workflows (e.g., ff-hr skill with Manager / Extractor / Scorer / Reporter agents), operators frequently need to locate a specific agent's session window. A descriptive but unprefixed label like "孟艳HR六岗位match评估" makes filtering by agent type impossible in the sessions list.

Proposed Solution

Add a configurable labelTemplate field to agents.defaults.subagents (and optionally agents.list[].subagents) that auto-prefixes the session label with the agent's id or role name.

{
  "agents": {
    "defaults": {
      "subagents": {
        "labelTemplate": "{agentId}-{taskPreview}"
      }
    }
  }
}
  • {agentId} — the agent id being invoked (e.g., scorer, reporter)
  • {taskPreview} — truncated first ~40 chars of the task/prompt, sanitized
  • If the user already provides an explicit label via sessions_spawn's label param, that takes precedence; the template fires as fallback when label is omitted

Workaround (方案1 — implemented separately)

Currently working around this via workspace convention in TOOLS.md: every sessions_spawn call must prefix the label with the agent name manually. This is fragile and relies on human discipline.

Priority

Medium — workflow quality-of-life improvement for operators running multi-agent pipelines.

extent analysis

TL;DR

Implement a labelTemplate field in agents.defaults.subagents to auto-prefix session labels with the agent's id or role name.

Guidance

  • Consider adding the proposed labelTemplate field to agents.defaults.subagents with a template like {agentId}-{taskPreview} to auto-prefix session labels.
  • If implementing the labelTemplate field, ensure it only applies when the user does not provide an explicit label parameter via sessions_spawn.
  • Review the current workaround in TOOLS.md and assess whether the proposed solution addresses the fragility and discipline issues associated with manual label prefixing.
  • Evaluate the potential impact of this change on existing workflows and operator habits.

Example

{
  "agents": {
    "defaults": {
      "subagents": {
        "labelTemplate": "{agentId}-{taskPreview}"
      }
    }
  }
}

Notes

The proposed solution relies on the ability to configure and apply a labelTemplate field, which may require updates to the underlying system or API.

Recommendation

Apply the proposed solution by implementing the labelTemplate field, as it addresses the core issue of inconsistent and unidentifiable session labels in multi-agent workflows.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix subagent session label: add {agentId} auto-prefix template [1 pull requests, 1 comments, 2 participants]