fix(kanban): kanban_create inherits the spawning worker's task workspace (#37182)

When a dispatcher-spawned worker (HERMES_KANBAN_TASK set) calls
kanban_create without an explicit workspace, the new child now inherits
the worker's own running-task workspace_kind/workspace_path instead of
defaulting to scratch. A worker editing a dir:/worktree project that
spawns a follow-up child keeps it in that project.

Orchestrators (kanban toolset, no HERMES_KANBAN_TASK) and CLI/dashboard
callers still default to scratch. An explicit workspace arg always wins.
This commit is contained in:
Teknium
2026-06-01 21:26:29 -07:00
committed by GitHub
parent bd8e2ec1a6
commit 272c2f30aa
2 changed files with 97 additions and 1 deletions
+20 -1
View File
@@ -743,8 +743,18 @@ def _handle_create(args: dict, **kw) -> str:
# CLI / dashboard paths and on legacy hosts that don't set the env.
session_id = args.get("session_id") or os.environ.get("HERMES_SESSION_ID")
priority = args.get("priority")
workspace_kind = args.get("workspace_kind") or "scratch"
# Resolve workspace. If the caller passed one explicitly, honor it.
# Otherwise, a dispatcher-spawned worker (HERMES_KANBAN_TASK set)
# inherits its own running task's workspace, so a worker editing a
# dir:/worktree project that spawns a follow-up child keeps the child
# in that project instead of a throwaway scratch dir. Orchestrators
# (kanban toolset, no HERMES_KANBAN_TASK) and CLI/dashboard callers
# fall back to scratch as before. Explicit None path stays None.
workspace_kind = args.get("workspace_kind")
workspace_path = args.get("workspace_path")
_inherit_workspace = workspace_kind is None and workspace_path is None
if workspace_kind is None:
workspace_kind = "scratch"
triage, bool_error = _parse_bool_arg(args, "triage")
if bool_error:
return tool_error(bool_error)
@@ -773,6 +783,15 @@ def _handle_create(args: dict, **kw) -> str:
try:
kb, conn = _connect(board=board)
try:
# Inherit the spawning worker's own task workspace when the
# caller didn't specify one (see resolution note above).
if _inherit_workspace:
_self_tid = os.environ.get("HERMES_KANBAN_TASK")
if _self_tid:
_self_task = kb.get_task(conn, _self_tid)
if _self_task is not None and _self_task.workspace_kind:
workspace_kind = _self_task.workspace_kind
workspace_path = _self_task.workspace_path
new_tid = kb.create_task(
conn,
title=str(title).strip(),