#10912: feat: add --session-key to clawdis system event
docs
gateway
cli
docker
agents
stale
Cluster:
Session Management Enhancements
## Summary
Fixes issue #4 - background CLI callbacks (like Codex or heartbeats) can now target a specific session instead of always routing to main.
## Problem
When a background process calls `clawdis system event`, it has no way to pass thread context. The Gateway always wakes up in the main channel instead of the originating thread.
## Solution
Add `--session-key` option to `clawdis system event`:
```bash
clawdis system event --text 'Task done!' --mode now --session-key 'agent:main:slack:channel:C123:thread:456'
```
## Changes
- Add `--session-key` option to CLI (`src/cli/system-cli.ts`)
- Pass sessionKey through wake payload (`src/gateway/hooks.ts`)
- Use provided sessionKey in dispatchWakeHook, falls back to main if not provided (`src/gateway/server/hooks.ts`)
## Testing
- Build passes
- Backward compatible (sessionKey is optional, defaults to main session)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Adds a `--session-key` option to `clawdis system event` and threads the value through the gateway wake hook payload so background callbacks can target a specific session.
- Updates hook normalization and dispatch types (`normalizeWakePayload`, `dispatchWakeHook`) to carry an optional `sessionKey` and fallback to the main session.
- Enhances followup-runner Slack behavior by reconstructing thread/channel context so tool sends stay in the originating thread.
- Includes several unrelated container/docs changes (Dockerfile tooling installs, new compose override, backup compose file, cron bug doc).
<h3>Confidence Score: 2/5</h3>
- Not safe to merge as-is due to unrelated container changes and an incomplete sessionKey plumbing path.
- Core `sessionKey` wiring looks straightforward, but the PR introduces substantial unrelated Docker/image changes (external binary downloads) and adds a tracked backup compose file. Additionally, hook-mapped wake actions don’t forward `sessionKey`, so the feature is inconsistent across code paths.
- Dockerfile, docker-compose.yml.bak, src/gateway/server-http.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#21682: fix(heartbeat): propagate sessionKey in exec/hooks to fix async con...
by eviaaaaa · 2026-02-20
77.1%
#14241: fix(heartbeat): propagate originating session key for exec event qu...
by aldoeliacim · 2026-02-11
75.2%
#9051: fix(sessions): respect dmScope config in CLI agent commands
by benleavett · 2026-02-04
74.4%
#11794: fix(gateway): validate session key ownership against authenticated ...
by coygeek · 2026-02-08
73.7%
#6850: fix: support direct channel:account:peer format in session key extr...
by toboto · 2026-02-02
72.9%
#20072: feat(sessions_spawn): add sessionKey param to reuse sub-agent sessions
by Be1Human · 2026-02-18
72.6%
#10686: fix(slack): use thread-level sessions for channels to prevent conte...
by pablohrcarvalho · 2026-02-06
71.9%
#13331: feat(sessions_spawn): add sessionKey param to reuse sub-agent sessions
by Be1Human · 2026-02-10
71.6%
#5525: Add plugin hook to resolve canonical RoomKey for session identity a...
by peteclt92 · 2026-01-31
71.6%
#20431: fix(sessions): add session contamination guards and self-leak lock ...
by marcomarandiz · 2026-02-18
71.5%