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:
@@ -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