Metadata
| Status | done |
|---|---|
| Assigned | agent-951 |
| Agent identity | f51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e |
| Created | 2026-04-28T21:49:09.755490041+00:00 |
| Started | 2026-04-28T21:51:39.427928513+00:00 |
| Completed | 2026-04-28T22:20:46.356974839+00:00 |
| Tags | eval-scheduled |
| Tokens | 20286885 in / 59787 out |
| Eval score | 0.88 |
| └ blocking impact | 0.85 |
| └ completeness | 0.95 |
| └ constraint fidelity | 0.85 |
| └ coordination overhead | 0.90 |
| └ correctness | 0.87 |
| └ downstream usability | 0.85 |
| └ efficiency | 0.80 |
| └ intent fidelity | 0.84 |
| └ style adherence | 0.90 |
Description
Description
Today (2026-04-28) the user ran wg service purge-chats to clean up 22 test chats spawned by a runaway worker agent. The command obediently archived ALL chats — including .chat-5 which was the user's actual active chat session.
User quote: 'lol you archived this chat too lol lol'
The current behavior is correct in the literal sense (purge-chats does what it says), but unsafe by default — you should not be able to silently nuke the chat you are currently sitting in.
What to change
wg service purge-chatsdetects which chats are 'active' and skips them by default. Definitions of active, in priority order:- The chat session whose handler is the parent process of the calling
wginvocation (if reachable via env var likeWG_CHAT_REFor process tree walk) - Chats whose handler subprocess is alive AND whose last consumer ping was within N seconds (e.g. 60s)
- Chats that have a TUI attached (the
tui-cannot-retirework added a TUI-attach signal — reuse that)
- The chat session whose handler is the parent process of the calling
- New flag
--include-active(or--all/--force— pick whatever fits existing wg verb conventions) that opts back in to the current full-nuke behavior. Without it, active chats are skipped. - The output should be explicit:
Purged 22 chat(s), skipped 1 active chat (.chat-5). Pass --include-active to override.so the user knows what happened.
Behavior matrix
| Invocation | active chat .chat-5 | inactive chats .chat-6..27 |
|---|---|---|
wg service purge-chats | skipped + reported | archived |
wg service purge-chats --include-active | archived | archived |
Out of scope
- Renaming the command (keep
purge-chats) - Changing the chat archival format / history preservation (already correct)
- Fancy interactive confirmation — single line of stderr output is enough
Validation
-
Failing test first: with one chat marked as 'active' (live handler + recent consumer ping),
purge-chatsarchives the others but leaves the active one open -
Failing test:
purge-chats --include-activearchives ALL chats including active (current behavior preserved under explicit flag) -
Failing test:
purge-chatson a graph with zero active chats works the same as today (no false positives blocking cleanup) - Output line clearly reports skipped count and how to override
-
Manual smoke: open a TUI, attach to a chat, run
wg service purge-chatsfrom a different terminal — the attached chat survives, others die - cargo build + cargo test pass
Depends on
Required by
- (none)
Log
- 2026-04-28T21:49:09.738133416+00:00 Task paused
- 2026-04-28T21:49:15.138555915+00:00 Task published
- 2026-04-28T21:49:42.090154673+00:00 Lightweight assignment: agent=Careful Programmer (f5143935), exec_mode=full, context_scope=task, reason=Careful Programmer's TDD-first approach and focus on correctness are ideal for this safety-critical feature requiring multi-scenario testing and explicit user-facing messaging to prevent accidental session destruction.
- 2026-04-28T21:49:43.509806847+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-28T21:49:50.654833228+00:00 Starting work — investigating purge-chats implementation
- 2026-04-28T21:51:30.854702705+00:00 Task unclaimed: agent 'agent-948' (PID 672100) process exited
- 2026-04-28T21:51:39.427934484+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-28T21:54:49.777384479+00:00 Plan: add include_active flag + caller_chat_id to IpcRequest::PurgeChats; reuse chat::chat_session_is_idle to detect active chats; CLI auto-detects WG_CHAT_REF env
- 2026-04-28T22:18:12.000951412+00:00 Implementation done — adding include_active flag, caller_chat_id IPC field, active-chat detection via chat_session_is_idle, smoke scenario, +5 service tests, +5 ipc tests
- 2026-04-28T22:18:40.276009492+00:00 Committed 8ea42b2a2
- 2026-04-28T22:19:01.551753386+00:00 Validated: 5 direct_purge_chats tests pass, 6 handle_purge_chats tests pass, smoke scenario passes locally, manual smoke (3 chats, .chat-5 active) confirms expected output. cargo build clean.
- 2026-04-28T22:20:46.356978796+00:00 Task pending eval (agent reported done; awaiting `.evaluate-*` to score)
- 2026-04-28T22:23:30.792354519+00:00 PendingEval → Done (evaluator passed; downstream unblocks)