feat(kanban): stamp originating ACP session_id on tasks

Salvages #23208 by @awizemann. Tracks which chat session created a
kanban task so clients can render a per-session board without falling
back to tenant + time-window heuristics.

- Schema: tasks gains nullable session_id TEXT column with index
  (additive migration in _migrate_add_optional_columns).
- ACP: server.py exposes the originating session id via HERMES_SESSION_ID
  with save/restore around the agent loop.
- Tool: kanban_create reads HERMES_SESSION_ID (with explicit override).
- CLI: 'hermes kanban list --session <id>' filter; JSON output exposes
  session_id.
This commit is contained in:
awizemann
2026-05-18 21:15:15 -07:00
committed by Teknium
parent 8e193cf05c
commit 31fe229039
8 changed files with 321 additions and 5 deletions

View File

@@ -654,6 +654,10 @@ def _handle_create(args: dict, **kw) -> str:
body = args.get("body")
parents = args.get("parents") or []
tenant = args.get("tenant") or os.environ.get("HERMES_TENANT")
# Stamp the originating session id when the agent loop runs under
# ACP (which sets HERMES_SESSION_ID before invoking tools). NULL on
# 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"
workspace_path = args.get("workspace_path")
@@ -700,6 +704,7 @@ def _handle_create(args: dict, **kw) -> str:
skills=skills,
initial_status=str(initial_status),
created_by=os.environ.get("HERMES_PROFILE") or "worker",
session_id=session_id,
)
new_task = kb.get_task(conn, new_tid)
return _ok(