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)"
|
description: "Max diff size in bytes before truncation (0 = unlimited)"
|
||||||
required: false
|
required: false
|
||||||
default: "80000"
|
default: "80000"
|
||||||
|
debug:
|
||||||
|
description: "Include agent tool log in the review comment (shows which files were read)"
|
||||||
|
required: false
|
||||||
|
default: "false"
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "docker"
|
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_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_MAX_DIFF="${INPUT_MAX_DIFF_BYTES:-80000}"
|
||||||
export PI_TOKEN="${INPUT_TOKEN}"
|
export PI_TOKEN="${INPUT_TOKEN}"
|
||||||
|
export PI_DEBUG="${INPUT_DEBUG:-false}"
|
||||||
|
|
||||||
# The calling repo is mounted at GITHUB_WORKSPACE by both GitHub and Gitea.
|
# The calling repo is mounted at GITHUB_WORKSPACE by both GitHub and Gitea.
|
||||||
# cd into it so git commands work against the right repo.
|
# 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."
|
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)
|
# 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 \
|
pi --no-session \
|
||||||
${PROVIDER_FLAG} \
|
${PROVIDER_FLAG} \
|
||||||
--model "${PI_MODEL}" \
|
--model "${PI_MODEL}" \
|
||||||
--tools "${PI_TOOLS}" \
|
--tools "${PI_TOOLS}" \
|
||||||
-p "${PROMPT}" \
|
-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
|
if [ ! -s /tmp/pi-review.md ]; then
|
||||||
echo "::error::Pi generated no output"
|
echo "::error::Pi generated no output"
|
||||||
|
echo "Agent log (last 30 lines):"
|
||||||
|
tail -30 /tmp/pi-agent.log
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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 "Review generated successfully."
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user