-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_simple_api.py
More file actions
67 lines (52 loc) · 1.99 KB
/
test_simple_api.py
File metadata and controls
67 lines (52 loc) · 1.99 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
#!/usr/bin/env python3
"""
Test simple API call without tools to isolate the issue
"""
import asyncio
import sys
import os
from pathlib import Path
# Add current directory to path
sys.path.insert(0, str(Path(__file__).parent))
from python_agent.agent import create_agent_from_config_file
async def test_simple_api():
"""Test simple API call without any tools"""
print("=== Simple API Test (No Tools) ===")
# Create agent
agent = create_agent_from_config_file('python_agent/mcp_config.yaml')
# Disable MCP servers to avoid delay
agent.config.mcp_servers = {}
try:
await agent.start()
print("✅ Agent started (no MCP servers)")
# Simple task without tools
task = "Hello, please just say hello back to me without using any tools"
print(f"\n📝 Testing simple API call: {task}")
print("=" * 50)
# Execute task
response_count = 0
async for result in agent.execute_task(task):
response_count += 1
result_type = result.get('type', 'unknown')
print(f"Response {response_count}: {result_type}")
if result_type == 'assistant_message':
print(f"✅ Got response: {result.get('content', '')}")
break
elif result_type == 'tool_use':
print(f"❌ Unexpected tool use: {result.get('name')}")
elif result_type == 'error':
print(f"❌ Error: {result.get('error')}")
break
# Safety limit
if response_count > 10:
print("❌ Too many responses, breaking")
break
print(f"\n✅ Test completed with {response_count} responses")
except Exception as e:
print(f"❌ Test failed: {e}")
import traceback
traceback.print_exc()
finally:
await agent.stop()
if __name__ == "__main__":
asyncio.run(test_simple_api())