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