forked from HAL9000/cleveragents-core
180 lines
5.8 KiB
Bash
180 lines
5.8 KiB
Bash
#!/bin/bash
|
|
# End-to-End Test: Multi-Agent Paper Writer - Section by Section Mode
|
|
# Tests incremental paper writing with file append capabilities
|
|
|
|
# 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 "Paper Writer - Section by Section Test"
|
|
echo "=========================================="
|
|
echo ""
|
|
echo "Testing incremental workflow:"
|
|
echo " 1. Write abstract section"
|
|
echo " 2. Save abstract to file"
|
|
echo " 3. Write introduction section"
|
|
echo " 4. Append introduction to file"
|
|
echo " 5. Read file to verify content"
|
|
echo " 6. Write methodology section"
|
|
echo " 7. Append methodology to file"
|
|
echo ""
|
|
|
|
# Clean up any previous test files
|
|
rm -f ai_ethics_paper.txt 2>/dev/null
|
|
|
|
echo "Starting test..."
|
|
echo ""
|
|
|
|
# Run the interactive session with section-by-section commands
|
|
cat << 'EOF' | python -m cleveragents interactive -c examples/multi_agent_paper_writer_langgraph.yaml --unsafe 2>&1 | tee /tmp/paper_section_test.log
|
|
/graph paper_writing_workflow hello, I want to write a paper about AI ethics section by section
|
|
/graph paper_writing_workflow write the abstract section for an AI ethics paper
|
|
/graph paper_writing_workflow save the abstract to ai_ethics_paper.txt
|
|
/graph paper_writing_workflow now write the introduction section
|
|
/graph paper_writing_workflow append the introduction to ai_ethics_paper.txt
|
|
/graph paper_writing_workflow read ai_ethics_paper.txt so we can see what we have so far
|
|
/graph paper_writing_workflow now write the methodology section
|
|
/graph paper_writing_workflow append the methodology section to ai_ethics_paper.txt
|
|
/graph paper_writing_workflow thank you, that's perfect!
|
|
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 300 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 "ai_ethics_paper.txt" ]; then
|
|
echo "✓ SUCCESS: Paper file was created!"
|
|
echo ""
|
|
echo "File: ai_ethics_paper.txt"
|
|
echo "Size: $(wc -c < ai_ethics_paper.txt) bytes"
|
|
echo "Lines: $(wc -l < ai_ethics_paper.txt) lines"
|
|
echo ""
|
|
echo "File content preview:"
|
|
echo "----------------------------------------"
|
|
head -30 ai_ethics_paper.txt
|
|
echo "..."
|
|
echo "----------------------------------------"
|
|
|
|
# Verify sections are present
|
|
sections_found=0
|
|
if grep -qi "abstract" ai_ethics_paper.txt; then
|
|
echo "✓ Abstract section found"
|
|
sections_found=$((sections_found + 1))
|
|
fi
|
|
if grep -qi "introduction" ai_ethics_paper.txt; then
|
|
echo "✓ Introduction section found"
|
|
sections_found=$((sections_found + 1))
|
|
fi
|
|
if grep -qi "methodology" ai_ethics_paper.txt; then
|
|
echo "✓ Methodology section found"
|
|
sections_found=$((sections_found + 1))
|
|
fi
|
|
|
|
echo ""
|
|
if [ $sections_found -ge 3 ]; then
|
|
echo "✓ All sections successfully appended ($sections_found/3)"
|
|
else
|
|
echo "⚠ WARNING: Some sections may be missing ($sections_found/3)"
|
|
fi
|
|
else
|
|
echo "✗ FAILED: Paper file was not created"
|
|
exit 1
|
|
fi
|
|
|
|
# Check log for operations
|
|
echo ""
|
|
echo "Operation Verification:"
|
|
echo "----------------------------------------"
|
|
operations_found=0
|
|
|
|
if grep -q "WRITER" /tmp/paper_section_test.log; then
|
|
echo "✓ WRITER agent executed"
|
|
operations_found=$((operations_found + 1))
|
|
fi
|
|
|
|
if grep -qi "successfully wrote\|successfully appended" /tmp/paper_section_test.log; then
|
|
echo "✓ File write/append operations executed"
|
|
operations_found=$((operations_found + 1))
|
|
fi
|
|
|
|
if grep -q "FILE_READ_SUCCESS\|📄" /tmp/paper_section_test.log; then
|
|
echo "✓ File read operation executed with clean output"
|
|
operations_found=$((operations_found + 1))
|
|
fi
|
|
|
|
if grep -q "FILE_CONTENT_START" /tmp/paper_section_test.log; then
|
|
echo "✓ File content preserved in context"
|
|
operations_found=$((operations_found + 1))
|
|
fi
|
|
|
|
echo ""
|
|
if [ $operations_found -ge 3 ]; then
|
|
echo "✓ Section-by-section workflow verified ($operations_found/4 operations)"
|
|
else
|
|
echo "⚠ WARNING: Incomplete workflow ($operations_found/4 operations)"
|
|
fi
|
|
|
|
# Check that file read output is clean (not dumping entire content to terminal)
|
|
echo ""
|
|
echo "Clean Output Verification:"
|
|
echo "----------------------------------------"
|
|
# Count how many times full content sections appear vs clean indicators
|
|
full_dumps=$(grep -c "FILE_CONTENT_START" /tmp/paper_section_test.log || echo "0")
|
|
clean_indicators=$(grep -c "📄" /tmp/paper_section_test.log || echo "0")
|
|
|
|
if [ $clean_indicators -gt 0 ]; then
|
|
echo "✓ Clean file read indicators detected ($clean_indicators instances)"
|
|
echo "✓ File content still preserved for agent context"
|
|
else
|
|
echo "⚠ Clean indicators not found (may need UI enhancement)"
|
|
fi
|
|
|
|
echo ""
|
|
echo "=========================================="
|
|
echo "Test Complete!"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
# Final summary
|
|
if [ -f "ai_ethics_paper.txt" ] && [ $sections_found -ge 3 ] && [ $operations_found -ge 3 ]; then
|
|
echo "✓ SUCCESS: All tests passed!"
|
|
echo ""
|
|
echo "Summary:"
|
|
echo " • Section-by-section writing: ✓"
|
|
echo " • File append operations: ✓"
|
|
echo " • File read with clean output: ✓"
|
|
echo " • Content preservation: ✓"
|
|
exit_status=0
|
|
else
|
|
echo "⚠ PARTIAL SUCCESS: Some tests failed"
|
|
exit_status=1
|
|
fi
|
|
|
|
echo ""
|
|
echo "Full log saved to: /tmp/paper_section_test.log"
|
|
echo "Paper saved to: ai_ethics_paper.txt"
|
|
|
|
exit $exit_status
|
|
|