-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathtest-parallel-agents.sh
More file actions
executable file
·124 lines (108 loc) · 3.79 KB
/
test-parallel-agents.sh
File metadata and controls
executable file
·124 lines (108 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# Test parallel subagent execution
# This simulates a main agent spawning multiple Task tools in one response
echo "========================================="
echo "Testing Parallel Subagent Execution"
echo "========================================="
echo ""
# Create a test request with multiple Task tool calls
# Simulates the model returning 3 Task tool uses in a single response
cat > /tmp/parallel-test-request.json <<'EOF'
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 4096,
"messages": [
{
"role": "user",
"content": "I need you to perform three tasks in parallel: 1) Explore the src/config directory to understand configuration structure, 2) Find all test files in the project, and 3) Check what agents are available. Use the Task tool three times."
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "I'll execute these three tasks in parallel using subagents."
},
{
"type": "tool_use",
"id": "task1",
"name": "Task",
"input": {
"subagent_type": "Explore",
"description": "Explore config directory",
"prompt": "Explore the src/config directory and explain what configuration files exist and what they do."
}
},
{
"type": "tool_use",
"id": "task2",
"name": "Task",
"input": {
"subagent_type": "Explore",
"description": "Find test files",
"prompt": "Find all test files in the project (files ending in .test.js or .test.ts). List their locations."
}
},
{
"type": "tool_use",
"id": "task3",
"name": "Task",
"input": {
"subagent_type": "Explore",
"description": "List available agents",
"prompt": "Search the codebase to find what agent types are available. Look for agent definitions."
}
}
]
}
]
}
EOF
echo "Sending request with 3 parallel Task tool calls..."
echo ""
# Set tool execution mode to server so tools execute server-side
export TOOL_EXECUTION_MODE=server
# Make the request
start_time=$(date +%s)
curl -s -X POST http://localhost:8080/v1/messages \
-H "Content-Type: application/json" \
-d @/tmp/parallel-test-request.json \
> /tmp/parallel-test-response.json
end_time=$(date +%s)
duration=$((end_time - start_time))
echo "Request completed in ${duration} seconds"
echo ""
# Check the logs for parallel execution evidence
echo "========================================="
echo "Checking logs for parallel execution..."
echo "========================================="
echo ""
echo "Looking for 'Executing multiple Task tools in parallel':"
grep "Executing multiple Task tools in parallel" /tmp/lynkr.log | tail -1 | jq .
echo ""
echo "Looking for 'Completed parallel Task execution':"
grep "Completed parallel Task execution" /tmp/lynkr.log | tail -1 | jq .
echo ""
echo "========================================="
echo "Response Summary:"
echo "========================================="
# Show response structure
if [ -f /tmp/parallel-test-response.json ]; then
echo ""
echo "Response content blocks:"
cat /tmp/parallel-test-response.json | jq '.content | length'
echo " content blocks returned"
echo ""
echo "Tool result IDs:"
cat /tmp/parallel-test-response.json | jq -r '.content[] | select(.type=="tool_result") | .tool_use_id'
echo ""
echo "First 100 chars of each tool result:"
cat /tmp/parallel-test-response.json | jq -r '.content[] | select(.type=="tool_result") | .content' | head -c 300
echo ""
else
echo "ERROR: No response file found!"
fi
echo ""
echo "========================================="
echo "Test Complete!"
echo "========================================="