#!/usr/bin/env bash # Build the activity log — the list of TOOL CALLS the agent made — into /tmp/activity_log.md. # Only dev agents (mode=pr) get an activity-log comment — comment-only roles (pm/qa) do no tool calls. # NOTE: we deliberately DO NOT include the agent's prose text parts. That final "here's what I did" # text is just a restatement of the PR description (already published as the PR body), not a tool # call — so it was noise in a section titled "tool calls". The log is the record of ACTIONS taken. # # Required env (provided by the workflow step): MODE set -u if [ "$MODE" != "pr" ]; then echo "skipping activity log for comment-mode agent"; : > /tmp/activity_log.md; exit 0 fi jq -r ' def trunc(n): if length > n then (.[0:n] + "…") else . end; select(.type=="tool_use") | (.part.tool // "?") as $t | ((.part.state.title // (.part.state.input | tojson | trunc(160)) // "")) as $title | "🔧 **" + $t + "**: `" + ($title | trunc(240)) + "`" ' /tmp/events.jsonl > /tmp/activity_log.md 2>/dev/null || true n=$(wc -l < /tmp/activity_log.md 2>/dev/null || echo 0) echo "activity log: $n tool calls" [ "$n" -eq 0 ] && : > /tmp/activity_log.md head -3 /tmp/activity_log.md