@@ -31,10 +31,12 @@ Scanned 15 commits from the past 2 days. No security vulnerabilities were identi
3131EOF
3232
3333# Extract using the primary method
34- if grep -q ' ^```cagent-output' " $TEST_DIR /output1.log" ; then
35- awk ' /^```cagent-output$/,/^```$/ {
36- if (!/^```cagent-output$/ && !/^```$/) print
37- }' " $TEST_DIR /output1.log" > " $TEST_DIR /output1.clean"
34+ if grep -q ' ```cagent-output' " $TEST_DIR /output1.log" ; then
35+ awk '
36+ /```cagent-output/ { capturing=1; next }
37+ capturing && /^```/ { capturing=0; next }
38+ capturing { print }
39+ ' " $TEST_DIR /output1.log" > " $TEST_DIR /output1.clean"
3840 echo " ✅ Extraction successful"
3941else
4042 echo " ❌ cagent-output block not found"
@@ -44,6 +46,52 @@ echo "Cleaned output:"
4446cat " $TEST_DIR /output1.clean"
4547echo " "
4648
49+ # Test Case 1b: Code fence NOT at start of line (agent emits thoughts before it)
50+ echo " "
51+ echo " Test 1b: Extracting cagent-output when code fence is mid-line"
52+ echo " ---"
53+ cat > " $TEST_DIR /output1b.log" << 'EOF '
54+ For any feedback, please visit: https://docker.qualtrics.com/jfe/form/SV_cNsCIg92nQemlfw
55+
56+ time=2025-11-05T21:22:35.664Z level=WARN msg="rootSessionID not set"
57+
58+ --- Agent: root ---
59+
60+ I'll analyze the PR by reading the actual diff and related files to generate a comprehensive description.```cagent-output
61+ ## Summary
62+
63+ Implements automated PR review functionality.
64+
65+ ## Changes
66+
67+ ### Added
68+ - New workflow file
69+ ```
70+ EOF
71+
72+ if grep -q ' ```cagent-output' " $TEST_DIR /output1b.log" ; then
73+ awk '
74+ /```cagent-output/ { capturing=1; next }
75+ capturing && /^```/ { capturing=0; next }
76+ capturing { print }
77+ ' " $TEST_DIR /output1b.log" > " $TEST_DIR /output1b.clean"
78+ echo " ✅ Extraction successful"
79+ else
80+ echo " ❌ cagent-output block not found"
81+ fi
82+
83+ echo " Cleaned output:"
84+ cat " $TEST_DIR /output1b.clean"
85+ echo " "
86+
87+ # Verify no agent thoughts leaked through
88+ if grep -q " I'll analyze" " $TEST_DIR /output1b.clean" ; then
89+ echo " ❌ FAIL: Agent thoughts leaked into clean output"
90+ exit 1
91+ else
92+ echo " ✅ Agent thoughts correctly excluded"
93+ fi
94+
4795# Test Case 2: Fallback - Extract after agent marker
4896echo " "
4997echo " Test 2: Fallback extraction after agent marker"
0 commit comments