feat: add debug mode to capture agent tool log
When debug: true, the review comment includes a collapsible section showing which files the agent read, grep patterns used, etc. Also prints agent log on failure for easier troubleshooting.
This commit is contained in:
@@ -37,6 +37,10 @@ inputs:
|
||||
description: "Max diff size in bytes before truncation (0 = unlimited)"
|
||||
required: false
|
||||
default: "80000"
|
||||
debug:
|
||||
description: "Include agent tool log in the review comment (shows which files were read)"
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
runs:
|
||||
using: "docker"
|
||||
|
||||
@@ -16,6 +16,7 @@ export PI_REVIEW_PROMPT="${INPUT_REVIEW_PROMPT:-}"
|
||||
export PI_EXCLUDE="${INPUT_EXCLUDE_PATTERNS:-*.lock package-lock.json yarn.lock pnpm-lock.yaml *.min.js *.min.css *.map}"
|
||||
export PI_MAX_DIFF="${INPUT_MAX_DIFF_BYTES:-80000}"
|
||||
export PI_TOKEN="${INPUT_TOKEN}"
|
||||
export PI_DEBUG="${INPUT_DEBUG:-false}"
|
||||
|
||||
# The calling repo is mounted at GITHUB_WORKSPACE by both GitHub and Gitea.
|
||||
# cd into it so git commands work against the right repo.
|
||||
|
||||
@@ -125,18 +125,40 @@ PROMPT="${PROMPT}
|
||||
The git diff is at /tmp/pi-diff.txt. Start by reading it, then read any files you need for full context."
|
||||
|
||||
# Run Pi in print mode (non-interactive, no session persistence)
|
||||
# Capture stderr (tool call log) always — only show it when debug is on
|
||||
pi --no-session \
|
||||
${PROVIDER_FLAG} \
|
||||
--model "${PI_MODEL}" \
|
||||
--tools "${PI_TOOLS}" \
|
||||
-p "${PROMPT}" \
|
||||
> /tmp/pi-review.md 2>/dev/null
|
||||
> /tmp/pi-review.md 2>/tmp/pi-agent.log
|
||||
|
||||
if [ ! -s /tmp/pi-review.md ]; then
|
||||
echo "::error::Pi generated no output"
|
||||
echo "Agent log (last 30 lines):"
|
||||
tail -30 /tmp/pi-agent.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If debug mode, append the agent's tool log to the review
|
||||
if [ "${PI_DEBUG}" = "true" ]; then
|
||||
AGENT_LOG=$(sed 's/\x1b\[[0-9;]*m//g' /tmp/pi-agent.log | head -200)
|
||||
cat >> /tmp/pi-review.md << LOGEOF
|
||||
|
||||
---
|
||||
|
||||
<details>
|
||||
<summary>🔍 <strong>Agent Tool Log</strong> (debug)</summary>
|
||||
|
||||
\`\`\`
|
||||
${AGENT_LOG}
|
||||
\`\`\`
|
||||
|
||||
</details>
|
||||
LOGEOF
|
||||
echo "Debug: agent log appended to review"
|
||||
fi
|
||||
|
||||
echo "Review generated successfully."
|
||||
echo "::endgroup::"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user