#!/bin/bash # Test script to verify agents use execute_code pattern # Usage: ./test-code-execution.sh set -e NAMESPACE=$(namespace) if [ -z "$NAMESPACE" ]; then echo "Error: No namespace found. Is anvillm running?" exit 1 fi AGENT_MOUNT="agent" echo "=== Testing Code Execution Pattern Adoption ===" echo "" # Create test agent with Taskmaster template echo "Creating test agent..." echo "new kiro-cli ." | 9p write $AGENT_MOUNT/ctl TEST_AGENT_ID=$(9p read $AGENT_MOUNT/list | head -1 | awk '{print $1}') echo "test-agent" | 9p write $AGENT_MOUNT/$TEST_AGENT_ID/alias # Load Taskmaster context cat ./bot-templates/Taskmaster | grep -A 1000 "^cat </dev/null || echo "") if echo "$TOOL_USAGE" | grep -q "execute_code"; then echo "✓ Agent used execute_code" else echo "✗ Agent did not use execute_code" fi echo "" echo "Test 2: Batch operation (should use execute_code for loop)" echo "Update all priority 1 beads to priority 2. Show progress." | 9p write $AGENT_MOUNT/$TEST_AGENT_ID/prompt sleep 5 echo "" echo "Agent response:" 9p read $AGENT_MOUNT/$TEST_AGENT_ID/response echo "" # Cleanup echo "Cleaning up test agent..." echo "stop $TEST_AGENT_ID" | 9p write $AGENT_MOUNT/ctl echo "" echo "=== Test Complete ===" echo "" echo "Manual verification steps:" echo "1. Check if agent used execute_code instead of multiple beads.list calls" echo "2. Verify filtering happened in sandbox (minimal context usage)" echo "3. Compare token usage to baseline (should be 80-99% reduction)"