fix: Add automatic removal of test agents in health check

- Add remove-test-agents.sh script
- Integrate test agent removal into db-health-check.sh
- Prevents test agents (ag_atlas, ag_oracle, ag_builder, ag_greeter) from reappearing
This commit is contained in:
Apple
2025-12-02 13:57:28 -08:00
parent d128caacf6
commit 6a76cffb88
2 changed files with 43 additions and 0 deletions

34
scripts/remove-test-agents.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
# Remove test agents that should not exist
# Run this script after migrations or when test agents appear
set -e
echo "🧹 Removing test agents..."
# Database connection
DATABASE_URL="${DATABASE_URL:-postgresql://postgres:postgres@localhost:5432/daarion}"
# Test agent IDs that should never exist
TEST_AGENT_IDS=("ag_atlas" "ag_oracle" "ag_builder" "ag_greeter")
# Delete test agents
for agent_id in "${TEST_AGENT_IDS[@]}"; do
echo " Checking for: $agent_id"
docker exec daarion-postgres psql -U postgres -d daarion -c \
"DELETE FROM agents WHERE id = '$agent_id';" 2>&1 | grep -E "DELETE|0" || true
done
echo "✅ Test agents removed"
# Verify
COUNT=$(docker exec daarion-postgres psql -U postgres -d daarion -t -c \
"SELECT COUNT(*) FROM agents WHERE id IN ('ag_atlas', 'ag_oracle', 'ag_builder', 'ag_greeter');" 2>&1 | tr -d ' ')
if [ "$COUNT" -eq 0 ]; then
echo "✅ No test agents found"
else
echo "⚠️ Warning: $COUNT test agents still exist"
exit 1
fi