Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.
Shell agent-teamsai-agentai-automationanthropicautonomous-agentawsbusiness-operationsclaudeclaude-codeclaude-code-plugindevopsecommerceinbox-zeroklaviyomarketingmcpmorning-briefingpr-automationshopifyterminal
fix(hooks): count ops-task-reminder per session and agent
Aurora Capitalfcde8920f49a
diff --git a/claude-ops/bin/ops-task-reminder b/claude-ops/bin/ops-task-reminderindex 6c0720b2..3781e99a 100755--- a/claude-ops/bin/ops-task-reminder+++ b/claude-ops/bin/ops-task-reminder@@ -26,7 +26,13 @@ THRESHOLD=$(config task_reminder_threshold 10)INPUT=$(cat)sid=$(printf '%s' "$INPUT" | jq -r '.session_id // "default"' 2>/dev/null)tool=$(printf '%s' "$INPUT" | jq -r '.tool_name // ""' 2>/dev/null)-state_file="$STATE_DIR/task-reminder-${sid}"+# Subagents share the parent's session_id; Claude Code sets agent_id only for+# them. Count each agent separately so subagent calls never fill (or reset) the+# main thread's counter. Async hook output from a subagent is delivered to the+# parent's context, where TaskCreate may just have been used, so subagents+# count but never print the reminder.+aid=$(printf '%s' "$INPUT" | jq -r '.agent_id // ""' 2>/dev/null | tr -cd 'A-Za-z0-9_-')+state_file="$STATE_DIR/task-reminder-${sid}${aid:+-agent-$aid}"# ── per-session lock ───────────────────────────────────────────────────────LOCK_TIMEOUT_S="${OPS_TASK_REMINDER_LOCK_TIMEOUT:-2}"@@ -75,7 +81,9 @@ esaccount=$(cat "$state_file" 2>/dev/null || echo 0)count=$((count + 1))-if [ "$count" -ge "$THRESHOLD" ]; then+if [ "$count" -ge "$THRESHOLD" ] && [ -n "$aid" ]; then+ echo 0 > "$state_file"+elif [ "$count" -ge "$THRESHOLD" ]; thenecho 0 > "$state_file"cat <<JSON{diff --git a/claude-ops/tests/test-task-reminder-concurrency.sh b/claude-ops/tests/test-task-reminder-concurrency.shindex 967946f2..4c8a0f6f 100755--- a/claude-ops/tests/test-task-reminder-concurrency.sh+++ b/claude-ops/tests/test-task-reminder-concurrency.sh@@ -36,9 +36,11 @@ SID="concurrency-test"# real 2s default.LOCK_TIMEOUT=60-# run_hook <impl> <threshold> <state_dir> <out_file> [tool]+# run_hook <impl> <threshold> <state_dir> <out_file> [tool] [agent_id]run_hook() {- printf '{"session_id":"%s","tool_name":"%s"}' "$SID" "${5:-Bash}" |+ local agent=""+ [ -n "${6:-}" ] && agent=",\"agent_id\":\"$6\""+ printf '{"session_id":"%s","tool_name":"%s"%s}' "$SID" "${5:-Bash}" "$agent" |HOME="$TMP/home" \CLAUDE_PLUGIN_ROOT="$ROOT" \OPS_DEPLOY_FIX_STATE="$3" \@@ -159,6 +161,40 @@ elsefail "stale mkdir lock not reclaimed (counter $(cat "$state/task-reminder-$SID"))"fi+# 9. Subagents share the parent's session_id but carry agent_id. Their calls+# must not fill the main thread's counter, never print a reminder, and a+# subagent Task* call must not reset the main thread's counter.+state="$TMP/state-agent"+out="$TMP/out-agent"+mkdir -p "$state" "$out"+for i in $(seq 1 31); do+ run_hook mkdir 30 "$state" "$out/a$i" Bash agent-test-1 || true+done+run_hook mkdir 30 "$state" "$out/main" Bash || true+reminders="$(cat "$out"/* | grep -c 'ops-task-reminder\]' || true)"+main="$(cat "$state/task-reminder-$SID" 2>/dev/null || echo missing)"+if [ "$reminders" = "0" ] && [ "$main" = "1" ]; then+ pass "31 subagent calls + 1 main call, threshold 30 -> no reminder, main counter 1"+else+ fail "subagent calls leaked: $reminders reminders, main counter $main (want 0, 1)"+fi+echo 7 >"$state/task-reminder-$SID"+run_hook mkdir 30 "$state" "$out/reset" TaskUpdate agent-test-1 || true+main="$(cat "$state/task-reminder-$SID")"+if [ "$main" = "7" ]; then+ pass "subagent TaskUpdate leaves the main counter alone (7)"+else+ fail "subagent TaskUpdate changed the main counter to $main (want 7)"+fi+# The main thread still gets its reminder at the threshold.+echo 29 >"$state/task-reminder-$SID"+run_hook mkdir 30 "$state" "$out/main-thr" Bash || true+if grep -q 'ops-task-reminder\]' "$out/main-thr"; then+ pass "main thread still reminded at threshold 30"+else+ fail "main thread not reminded at threshold 30"+fi+# 8. Wiring: hooks.json must route Task* PostToolUse events to this hook,# otherwise the reset above is unreachable in production. Matcher# semantics follow Claude Code: "*"/"" match all; a value of only