Add fork-session lane, /kill command, and auto-routing#20
Add fork-session lane, /kill command, and auto-routing#201872-svg wants to merge 3 commits intomoazbuilds:masterfrom
Conversation
- /fork <prompt>: spawns a parallel lightweight watcher agent outside the main serial queue. Uses a dedicated system prompt that hard-denies long-running tasks (compilation, downloads, fuzzing) to keep it responsive for monitoring the main agent. - /kill: sends SIGTERM to the active claude subprocess immediately. - activeProc tracking in runClaudeOnce() enables kill to work from any handler without exposing the proc externally. - Fork agent is given the session JSONL path so it can peek at main agent progress mid-task.
When the main serial queue is processing a task, new incoming messages are automatically handled by the fork agent instead of queuing behind it. This makes fork behavior transparent — users just chat normally without needing to type /fork manually. - Add mainRunning flag + isMainBusy() export in runner.ts - telegram.ts checks isMainBusy() before dispatching and routes to runFork() if main is occupied
Hardcode FORK_MODEL to claude-haiku-4-5-20251001 — forks are meant to be fast watchers, not reasoning agents. Add explicit speed instructions to the system prompt: 1-3 sentences, no preamble, no over-analysis.
8bb7ab8 to
0f1f920
Compare
… and /kill command From upstream PR moazbuilds#21 by 1872-svg (streaming + verbose) and PR moazbuilds#20 (fork agent). - Streaming output via editMessageText for real-time response display - /verbose command to show tool calls in Telegram - /fork command for parallel lightweight agent using Haiku - /kill command to terminate active agent - Auto-routing to fork when main agent is busy - Merged with additionalDirs (moazbuilds#13) and session corruption fix (moazbuilds#26) Co-Authored-By: 1872-svg <1872-svg@users.noreply.github.com>
- 新增 tests/runner.test.ts(buildChildEnv、rate limit、security args、queue、timeout) - 新增 tests/config.test.ts(resolvePrompt、parseSettings、Discord snowflake、exclude windows) - 新增 tests/sessions.test.ts(session CRUD、turnCount、compactWarned、backup) - package.json 新增 test script - README 新增 Testing section(測試覆蓋範圍表格) - 全部 178 tests 通過
|
Vision: PARTIAL — fork agent is lightweight but auto-routing silently switches to Haiku without user awareness, violating the "no hidden implicit behaviors" principle. Overlapping PRs: #76 (modifies Code reviewFound 3 issues:
Lines 109 to 117 in 0f1f920
claudeclaw/src/commands/telegram.ts Lines 630 to 636 in 0f1f920
claudeclaw/src/commands/telegram.ts Lines 630 to 636 in 0f1f920 Closing in favour of #76. The fork agent idea is interesting, but this implementation has two blockers: (1) auto-routing silently switches to Haiku with no user notification — violates the "no hidden implicit behaviors" principle; (2) the feature is always-on with no - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Summary
/fork <prompt>spawns a parallel Claude session that doesn't touch the main session or queue. Useful for checking progress or asking quick questions while the main agent is running a long task./killcommand: Terminates the currently running Claude subprocess immediately.How it works
runner.tsexportskillActive(),isMainBusy(), andrunFork(). The fork agent runs with--output-format jsonin a separate subprocess, bypassing the serial queue used by the main session.In
telegram.ts,handleMessagechecksisMainBusy()before dispatching — busy → fork, idle → main session.Test plan
/fork what are you doing?— should get a fast response without interrupting the main task/killwhile a task is running — should terminate and confirm/killwith nothing running — should report "No active agent running"