-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_demo.py
More file actions
111 lines (92 loc) · 3.41 KB
/
Copy pathrun_demo.py
File metadata and controls
111 lines (92 loc) · 3.41 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
#!/usr/bin/env python
"""
Task Manager Agent - Demo/Test Execution
This script demonstrates the Task Manager Agent with a sample objective.
"""
from task_manager import TaskManagerAgent
from task_manager.config import EnvConfig, AgentConfig
from datetime import datetime
def main():
"""Main entry point for the agent demo."""
print("=" * 70)
print("Task Manager Agent - Demo Execution")
print("=" * 70)
print()
# Load environment configuration
print("Step 1: Loading configuration from .env...")
EnvConfig.load_env_file()
print(" Configuration loaded successfully!")
print()
# Create agent config from environment
print("Step 2: Creating agent configuration...")
config = AgentConfig.from_env(prefix="AGENT_")
print(" Configuration:")
print(f" - LLM Provider: {config.llm.provider}")
print(f" - Model: {config.llm.model_name}")
print(f" - Temperature: {config.llm.temperature}")
print(f" - Max Iterations: {config.max_iterations}")
print(f" - Enable Search: {config.enable_search}")
print(f" - Log Level: {config.log_level}")
print()
# Set a demo objective
objective = "List the top 5 programming languages in 2026 and their primary use cases"
print("Step 3: Setting objective...")
print(f" Objective: {objective}")
print()
print("=" * 70)
print("Step 4: Starting Task Manager Agent...")
print("=" * 70)
print()
try:
# Create agent
agent = TaskManagerAgent(
objective=objective,
config=config,
metadata={
"demo": True,
"started_at": datetime.now().isoformat()
}
)
print("Agent initialized successfully!")
print("Running task execution workflow...")
print()
# Run the agent
final_state = agent.run(thread_id="demo-task-001")
# Print results
print()
print("=" * 70)
print("Task Execution Complete!")
print("=" * 70)
summary = agent.get_results_summary(final_state)
print()
print("Execution Summary:")
print(f" Objective: {summary['objective'][:60]}...")
print(f" Total Tasks Created: {summary['total_tasks']}")
print(f" Completed Tasks: {summary['completed_tasks']}")
print(f" Failed Tasks: {summary['failed_tasks']}")
print(f" Iterations Used: {summary['iterations_used']}")
print()
if summary['results']:
print("Results:")
for task_id, result in list(summary['results'].items())[:3]:
print(f" {task_id}: {str(result)[:50]}...")
print()
print("=" * 70)
print("Demo execution completed successfully!")
print("=" * 70)
except KeyboardInterrupt:
print()
print("Agent interrupted by user.")
except Exception as e:
print()
print(f"Error during execution: {str(e)}")
print()
print("Troubleshooting tips:")
print("1. Ensure .env file exists with valid API key")
print("2. Check internet connection for API calls")
print("3. Verify Google API key is active")
print()
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()