From 75325aaf0309a93e20ed550de06975a57ed9450b Mon Sep 17 00:00:00 2001 From: KeiSei84 <2206745@gmail.com> Date: Tue, 26 May 2026 18:53:24 +0800 Subject: [PATCH] fix(hooks): clean up .task-*.start marker on agent_done (forgot in prev commit) --- hooks/agent-event-done.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hooks/agent-event-done.sh b/hooks/agent-event-done.sh index 3508135..b3ab8de 100755 --- a/hooks/agent-event-done.sh +++ b/hooks/agent-event-done.sh @@ -65,4 +65,14 @@ if [ -n "$TOOL_USE_ID" ] && [ -f "$ACTIVE_FILE" ]; then mv "$ACTIVE_FILE.tmp" "$ACTIVE_FILE" 2>/dev/null || true fi +# v0.40 root-cause fix: remove the .task-${id}.start marker that task-timer.sh +# wrote on agent_spawn. Without this, completed sub-agents leave stale markers +# in ~/.claude/memory/time-metrics/ which inflate the pet's running-agent +# counter (🤖N). Previously task-timer was the only writer + the 2h stale +# filter in keisei-pet.sh was the only cleanup; that left up-to-2h dead +# markers visible on every status refresh. +if [ -n "$TOOL_USE_ID" ] && [ "$TOOL_USE_ID" != "unknown" ]; then + rm -f "$HOME/.claude/memory/time-metrics/.task-${TOOL_USE_ID}.start" 2>/dev/null || true +fi + exit 0