Files
temp/tests/scripts/test_multi_agent_paper_writer_langgraph.sh

141 lines
4.4 KiB
Bash

#!/bin/bash
# End-to-End Test: Multi-Agent Paper Writer (LangGraph)
# Tests the complete workflow with file saving
# Change to project root
cd "$(dirname "$0")/../.."
# Check for API key
if [ -z "$OPENAI_API_KEY" ]; then
echo "Error: OPENAI_API_KEY environment variable not set"
echo "Usage: export OPENAI_API_KEY='your-key-here'"
exit 1
fi
echo "=========================================="
echo "Multi-Agent Paper Writer Test (LangGraph)"
echo "=========================================="
echo ""
echo "Testing complete workflow:"
echo " 1. Coordinator routes requests"
echo " 2. Researcher gathers information"
echo " 3. Writer creates the paper"
echo " 4. Reviewer provides feedback"
echo " 5. Writer applies suggestions"
echo " 6. File Manager saves to file"
echo ""
# Clean up any previous test files
rm -f quantum_test_paper.txt ai_paper.txt 2>/dev/null
echo "Starting test..."
echo ""
# Run the interactive session with incremental commands
cat << 'EOF' | python -m cleveragents interactive -c examples/multi_agent_paper_writer_langgraph.yaml --unsafe 2>&1 | tee /tmp/paper_writer_test.log
/graph paper_writing_workflow hello, who are you and how can you help me?
/graph paper_writing_workflow I want to write a paper about quantum computing advantages. First, research the key advantages of quantum computing including speed, parallelism, and applications.
/graph paper_writing_workflow Now write a brief 250 word paper on quantum computing advantages covering: computational speed, quantum parallelism, and real-world applications. Target audience is general tech professionals.
/graph paper_writing_workflow please review the paper that was just written
/graph paper_writing_workflow apply the reviewer's suggestions and improve the paper
/graph paper_writing_workflow save the final paper to quantum_test_paper.txt
exit
EOF
EXIT_CODE=$?
echo ""
echo "=========================================="
echo "Test Results"
echo "=========================================="
echo ""
# Check exit code
if [ $EXIT_CODE -eq 124 ]; then
echo "⚠ WARNING: Test timed out after 240 seconds"
elif [ $EXIT_CODE -ne 0 ]; then
echo "✗ FAILED: Test exited with code $EXIT_CODE"
exit 1
fi
# Check if file was created
if [ -f "quantum_test_paper.txt" ]; then
echo "✓ SUCCESS: Paper file was created!"
echo ""
echo "File: quantum_test_paper.txt"
echo "Size: $(wc -c < quantum_test_paper.txt) bytes"
echo "Lines: $(wc -l < quantum_test_paper.txt) lines"
echo ""
echo "First 20 lines:"
echo "----------------------------------------"
head -20 quantum_test_paper.txt
echo "----------------------------------------"
# Verify content quality
if grep -qi "quantum" quantum_test_paper.txt && \
grep -qi "computing" quantum_test_paper.txt; then
echo ""
echo "✓ Content verification: Paper contains expected keywords"
else
echo ""
echo "✗ WARNING: Paper may not contain expected content"
fi
else
echo "✗ FAILED: Paper file was not created"
echo ""
echo "Checking test log for errors..."
if grep -i "error" /tmp/paper_writer_test.log | tail -5; then
echo ""
echo "Errors found in log (showing last 5)"
fi
exit 1
fi
# Check log for all agent participation
echo ""
echo "Agent Participation Check:"
echo "----------------------------------------"
agents_found=0
if grep -q "RESEARCHER" /tmp/paper_writer_test.log; then
echo "✓ RESEARCHER agent participated"
agents_found=$((agents_found + 1))
fi
if grep -q "WRITER" /tmp/paper_writer_test.log; then
echo "✓ WRITER agent participated"
agents_found=$((agents_found + 1))
fi
if grep -q "REVIEWER" /tmp/paper_writer_test.log; then
echo "✓ REVIEWER agent participated"
agents_found=$((agents_found + 1))
fi
if grep -q "Successfully wrote" /tmp/paper_writer_test.log; then
echo "✓ FILE MANAGER executed file write"
agents_found=$((agents_found + 1))
fi
echo ""
if [ $agents_found -ge 3 ]; then
echo "✓ Multi-agent collaboration verified ($agents_found/4 agents active)"
else
echo "⚠ WARNING: Limited agent participation detected ($agents_found/4 agents)"
fi
echo ""
echo "=========================================="
echo "Test Complete!"
echo "=========================================="
echo ""
echo "Summary:"
echo " • Paper generated: ✓"
echo " • File saved: ✓"
echo " • Multi-agent workflow: ✓"
echo ""
echo "Full log saved to: /tmp/paper_writer_test.log"
exit 0