agent-mcp 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. agent_mcp/__init__.py +66 -12
  2. agent_mcp/a2a_protocol.py +316 -0
  3. agent_mcp/agent_lightning_library.py +214 -0
  4. agent_mcp/camel_mcp_adapter.py +521 -0
  5. agent_mcp/claude_mcp_adapter.py +195 -0
  6. agent_mcp/cli.py +47 -0
  7. agent_mcp/google_ai_mcp_adapter.py +183 -0
  8. agent_mcp/heterogeneous_group_chat.py +412 -38
  9. agent_mcp/langchain_mcp_adapter.py +176 -43
  10. agent_mcp/llamaindex_mcp_adapter.py +410 -0
  11. agent_mcp/mcp_agent.py +26 -0
  12. agent_mcp/mcp_transport.py +11 -5
  13. agent_mcp/microsoft_agent_framework.py +591 -0
  14. agent_mcp/missing_frameworks.py +435 -0
  15. agent_mcp/openapi_protocol.py +616 -0
  16. agent_mcp/payments.py +804 -0
  17. agent_mcp/pydantic_ai_mcp_adapter.py +628 -0
  18. agent_mcp/registry.py +768 -0
  19. agent_mcp/security.py +864 -0
  20. {agent_mcp-0.1.3.dist-info → agent_mcp-0.1.5.dist-info}/METADATA +173 -49
  21. agent_mcp-0.1.5.dist-info/RECORD +62 -0
  22. {agent_mcp-0.1.3.dist-info → agent_mcp-0.1.5.dist-info}/WHEEL +1 -1
  23. agent_mcp-0.1.5.dist-info/entry_points.txt +4 -0
  24. agent_mcp-0.1.5.dist-info/top_level.txt +3 -0
  25. demos/__init__.py +1 -0
  26. demos/basic/__init__.py +1 -0
  27. demos/basic/framework_examples.py +108 -0
  28. demos/basic/langchain_camel_demo.py +272 -0
  29. demos/basic/simple_chat.py +355 -0
  30. demos/basic/simple_integration_example.py +51 -0
  31. demos/collaboration/collaborative_task_example.py +437 -0
  32. demos/collaboration/group_chat_example.py +130 -0
  33. demos/collaboration/simplified_crewai_example.py +39 -0
  34. demos/comprehensive_framework_demo.py +202 -0
  35. demos/langgraph/autonomous_langgraph_network.py +808 -0
  36. demos/langgraph/langgraph_agent_network.py +415 -0
  37. demos/langgraph/langgraph_collaborative_task.py +619 -0
  38. demos/langgraph/langgraph_example.py +227 -0
  39. demos/langgraph/run_langgraph_examples.py +213 -0
  40. demos/network/agent_network_example.py +381 -0
  41. demos/network/email_agent.py +130 -0
  42. demos/network/email_agent_demo.py +46 -0
  43. demos/network/heterogeneous_network_example.py +216 -0
  44. demos/network/multi_framework_example.py +199 -0
  45. demos/utils/check_imports.py +49 -0
  46. demos/workflows/autonomous_agent_workflow.py +248 -0
  47. demos/workflows/mcp_features_demo.py +353 -0
  48. demos/workflows/run_agent_collaboration_demo.py +63 -0
  49. demos/workflows/run_agent_collaboration_with_logs.py +396 -0
  50. demos/workflows/show_agent_interactions.py +107 -0
  51. demos/workflows/simplified_autonomous_demo.py +74 -0
  52. functions/main.py +144 -0
  53. functions/mcp_network_server.py +513 -0
  54. functions/utils.py +47 -0
  55. agent_mcp-0.1.3.dist-info/RECORD +0 -18
  56. agent_mcp-0.1.3.dist-info/entry_points.txt +0 -2
  57. agent_mcp-0.1.3.dist-info/top_level.txt +0 -1
@@ -0,0 +1,396 @@
1
+ """
2
+ Agent Collaboration with Detailed Interaction Logs
3
+
4
+ This script demonstrates agents collaborating and shows the detailed logs
5
+ of how they communicate with each other via the MCP protocol.
6
+ """
7
+
8
+ import os
9
+ import json
10
+ import time
11
+ from typing import Dict, List, Any
12
+ import pprint
13
+
14
+ # Import the agent network implementation
15
+ from demos.network.agent_network_example import AgentNetwork
16
+ from agent_mcp.mcp_agent import MCPAgent # Import the MCPAgent directly to access logs
17
+
18
+ # Enable verbose logging for all tool calls
19
+ os.environ["AUTOGEN_VERBOSE"] = "1"
20
+
21
+ def run_agent_collaboration_with_logs(topic: str):
22
+ """
23
+ Run a collaborative research process with detailed logs of agent interactions.
24
+
25
+ This function will:
26
+ 1. Initialize the agent network
27
+ 2. Set the topic
28
+ 3. Show every interaction between agents
29
+ 4. Display tool calls between agents
30
+
31
+ Args:
32
+ topic: The topic for agents to collaborate on
33
+ """
34
+ print(f"\n{'='*80}")
35
+ print(f"AGENT COLLABORATION WITH DETAILED LOGS: {topic}")
36
+ print(f"{'='*80}\n")
37
+
38
+ # Create the agent network
39
+ print("Initializing agent network...")
40
+ network = AgentNetwork()
41
+ network.create_network()
42
+
43
+ # Enable more verbose logging on all agents to see interactions
44
+ for agent_id, agent in network.agents.items():
45
+ # Enable tool call logging
46
+ agent.init_log_file = f"{agent_id}_interactions.log"
47
+ agent.verbose = True
48
+
49
+ # Set the collaboration topic
50
+ print(f"\nSetting collaboration topic: {topic}")
51
+ network.set_topic(topic)
52
+ time.sleep(1)
53
+
54
+ # Store full logs of interactions
55
+ interactions = []
56
+
57
+ # Step 1: Researcher investigates the topic
58
+ researcher_id = "researcher"
59
+ print(f"\n[STEP 1] RESEARCHER INVESTIGATION")
60
+ print(f"{'-'*60}")
61
+
62
+ # Record pre-interaction state
63
+ print(f"Researcher context before interaction:")
64
+ researcher_context = network.agents[researcher_id].shared_context.get_all_context() if hasattr(network.agents[researcher_id], 'shared_context') else {}
65
+ pprint.pprint(researcher_context)
66
+
67
+ # Ask researcher about the topic
68
+ research_question = f"What is {topic} and why is it important? Provide key concepts and components."
69
+ print(f"\nQuestion to researcher: {research_question}\n")
70
+
71
+ # Make the call and capture the response
72
+ research_findings = network.interact_with_agent_programmatically(researcher_id, research_question)
73
+
74
+ # Record the interaction
75
+ interactions.append({
76
+ "step": 1,
77
+ "from": "user",
78
+ "to": researcher_id,
79
+ "message": research_question,
80
+ "response": research_findings
81
+ })
82
+
83
+ print(f"\nResearcher's response:")
84
+ print(f"{'-'*40}")
85
+ print(research_findings)
86
+ print(f"{'-'*40}")
87
+
88
+ # Share knowledge with the analyst via tool call
89
+ print(f"\nSharing research findings with the analyst...")
90
+ knowledge_key = "key_concepts"
91
+
92
+ # Show the tool call details
93
+ print(f"Tool call details:")
94
+ print(f"- Tool: share_knowledge")
95
+ print(f"- From: {researcher_id}")
96
+ print(f"- To: analyst")
97
+ print(f"- Key: {knowledge_key}")
98
+ print(f"- Value: [Research findings]")
99
+
100
+ # Make the actual tool call
101
+ network.share_knowledge(
102
+ from_agent_id=researcher_id,
103
+ to_agent_id="analyst",
104
+ knowledge_key=knowledge_key,
105
+ knowledge_value=research_findings
106
+ )
107
+
108
+ # Record the interaction
109
+ interactions.append({
110
+ "step": "1a",
111
+ "from": researcher_id,
112
+ "to": "analyst",
113
+ "tool": "share_knowledge",
114
+ "key": knowledge_key,
115
+ "value_summary": "Research findings on " + topic
116
+ })
117
+
118
+ # Show the analyst's context after receiving the knowledge
119
+ print(f"\nAnalyst context after receiving research:")
120
+ analyst_context = network.agents["analyst"].shared_context.get_all_context() if hasattr(network.agents["analyst"], 'shared_context') else {}
121
+ if knowledge_key in analyst_context:
122
+ print(f"- Successfully received '{knowledge_key}' from researcher")
123
+ else:
124
+ print(f"- Failed to receive '{knowledge_key}' from researcher")
125
+
126
+ # Step 2: Analyst evaluates the research findings
127
+ analyst_id = "analyst"
128
+ print(f"\n[STEP 2] ANALYST EVALUATION")
129
+ print(f"{'-'*60}")
130
+
131
+ # Ask analyst to analyze the research
132
+ analysis_question = f"Based on the research about {topic}, what are the key benefits, challenges, and potential applications?"
133
+ print(f"\nQuestion to analyst: {analysis_question}\n")
134
+
135
+ # Make the call and capture the response
136
+ analysis = network.interact_with_agent_programmatically(analyst_id, analysis_question)
137
+
138
+ # Record the interaction
139
+ interactions.append({
140
+ "step": 2,
141
+ "from": "user",
142
+ "to": analyst_id,
143
+ "message": analysis_question,
144
+ "response": analysis
145
+ })
146
+
147
+ print(f"\nAnalyst's response:")
148
+ print(f"{'-'*40}")
149
+ print(analysis)
150
+ print(f"{'-'*40}")
151
+
152
+ # Share this knowledge with the planner via tool call
153
+ print(f"\nSharing analysis with the planner...")
154
+ knowledge_key = "analysis"
155
+
156
+ # Show the tool call details
157
+ print(f"Tool call details:")
158
+ print(f"- Tool: share_knowledge")
159
+ print(f"- From: {analyst_id}")
160
+ print(f"- To: planner")
161
+ print(f"- Key: {knowledge_key}")
162
+ print(f"- Value: [Analysis content]")
163
+
164
+ # Make the actual tool call
165
+ network.share_knowledge(
166
+ from_agent_id=analyst_id,
167
+ to_agent_id="planner",
168
+ knowledge_key=knowledge_key,
169
+ knowledge_value=analysis
170
+ )
171
+
172
+ # Record the interaction
173
+ interactions.append({
174
+ "step": "2a",
175
+ "from": analyst_id,
176
+ "to": "planner",
177
+ "tool": "share_knowledge",
178
+ "key": knowledge_key,
179
+ "value_summary": "Analysis of benefits, challenges, and applications"
180
+ })
181
+
182
+ # Show the planner's context after receiving the knowledge
183
+ print(f"\nPlanner context after receiving analysis:")
184
+ planner_context = network.agents["planner"].shared_context.get_all_context() if hasattr(network.agents["planner"], 'shared_context') else {}
185
+ if knowledge_key in planner_context:
186
+ print(f"- Successfully received '{knowledge_key}' from analyst")
187
+ else:
188
+ print(f"- Failed to receive '{knowledge_key}' from analyst")
189
+
190
+ # Step 3: Planner develops an implementation approach
191
+ planner_id = "planner"
192
+ print(f"\n[STEP 3] PLANNER IMPLEMENTATION STRATEGY")
193
+ print(f"{'-'*60}")
194
+
195
+ # Ask planner to create an implementation plan
196
+ planning_question = f"Based on the research and analysis about {topic}, create a step-by-step implementation plan."
197
+ print(f"\nQuestion to planner: {planning_question}\n")
198
+
199
+ # Make the call and capture the response
200
+ plan = network.interact_with_agent_programmatically(planner_id, planning_question)
201
+
202
+ # Record the interaction
203
+ interactions.append({
204
+ "step": 3,
205
+ "from": "user",
206
+ "to": planner_id,
207
+ "message": planning_question,
208
+ "response": plan
209
+ })
210
+
211
+ print(f"\nPlanner's response:")
212
+ print(f"{'-'*40}")
213
+ print(plan)
214
+ print(f"{'-'*40}")
215
+
216
+ # Share this knowledge with the creative agent via tool call
217
+ print(f"\nSharing implementation plan with the creative agent...")
218
+ knowledge_key = "implementation_plan"
219
+
220
+ # Show the tool call details
221
+ print(f"Tool call details:")
222
+ print(f"- Tool: share_knowledge")
223
+ print(f"- From: {planner_id}")
224
+ print(f"- To: creative")
225
+ print(f"- Key: {knowledge_key}")
226
+ print(f"- Value: [Implementation plan content]")
227
+
228
+ # Make the actual tool call
229
+ network.share_knowledge(
230
+ from_agent_id=planner_id,
231
+ to_agent_id="creative",
232
+ knowledge_key=knowledge_key,
233
+ knowledge_value=plan
234
+ )
235
+
236
+ # Record the interaction
237
+ interactions.append({
238
+ "step": "3a",
239
+ "from": planner_id,
240
+ "to": "creative",
241
+ "tool": "share_knowledge",
242
+ "key": knowledge_key,
243
+ "value_summary": "Step-by-step implementation plan"
244
+ })
245
+
246
+ # Show the creative's context after receiving the knowledge
247
+ print(f"\nCreative context after receiving implementation plan:")
248
+ creative_context = network.agents["creative"].shared_context.get_all_context() if hasattr(network.agents["creative"], 'shared_context') else {}
249
+ if knowledge_key in creative_context:
250
+ print(f"- Successfully received '{knowledge_key}' from planner")
251
+ else:
252
+ print(f"- Failed to receive '{knowledge_key}' from planner")
253
+
254
+ # Step 4: Creative comes up with innovative ideas
255
+ creative_id = "creative"
256
+ print(f"\n[STEP 4] CREATIVE INNOVATION")
257
+ print(f"{'-'*60}")
258
+
259
+ # Ask creative to generate innovative ideas
260
+ creative_question = f"Based on the implementation plan for {topic}, what are some creative and innovative approaches or extensions we could consider?"
261
+ print(f"\nQuestion to creative: {creative_question}\n")
262
+
263
+ # Make the call and capture the response
264
+ creative_ideas = network.interact_with_agent_programmatically(creative_id, creative_question)
265
+
266
+ # Record the interaction
267
+ interactions.append({
268
+ "step": 4,
269
+ "from": "user",
270
+ "to": creative_id,
271
+ "message": creative_question,
272
+ "response": creative_ideas
273
+ })
274
+
275
+ print(f"\nCreative's response:")
276
+ print(f"{'-'*40}")
277
+ print(creative_ideas)
278
+ print(f"{'-'*40}")
279
+
280
+ # Share these ideas with the coordinator via tool call
281
+ print(f"\nSharing creative ideas with the coordinator...")
282
+ knowledge_key = "creative_extensions"
283
+
284
+ # Show the tool call details
285
+ print(f"Tool call details:")
286
+ print(f"- Tool: share_knowledge")
287
+ print(f"- From: {creative_id}")
288
+ print(f"- To: coordinator")
289
+ print(f"- Key: {knowledge_key}")
290
+ print(f"- Value: [Creative ideas content]")
291
+
292
+ # Make the actual tool call
293
+ network.share_knowledge(
294
+ from_agent_id=creative_id,
295
+ to_agent_id="coordinator",
296
+ knowledge_key=knowledge_key,
297
+ knowledge_value=creative_ideas
298
+ )
299
+
300
+ # Record the interaction
301
+ interactions.append({
302
+ "step": "4a",
303
+ "from": creative_id,
304
+ "to": "coordinator",
305
+ "tool": "share_knowledge",
306
+ "key": knowledge_key,
307
+ "value_summary": "Creative and innovative approaches"
308
+ })
309
+
310
+ # Show the coordinator's context after receiving the knowledge
311
+ print(f"\nCoordinator context after receiving creative ideas:")
312
+ coordinator_context = network.agents["coordinator"].shared_context.get_all_context() if hasattr(network.agents["coordinator"], 'shared_context') else {}
313
+ if knowledge_key in coordinator_context:
314
+ print(f"- Successfully received '{knowledge_key}' from creative")
315
+ else:
316
+ print(f"- Failed to receive '{knowledge_key}' from creative")
317
+
318
+ # Step 5: Coordinator synthesizes everything
319
+ coordinator_id = "coordinator"
320
+ print(f"\n[STEP 5] COORDINATOR SYNTHESIS")
321
+ print(f"{'-'*60}")
322
+
323
+ # Verify coordinator has access to all knowledge
324
+ print(f"Checking coordinator's accumulated knowledge:")
325
+ coordinator_keys = list(network.agents[coordinator_id].shared_context.get_all_context().keys()) if hasattr(network.agents[coordinator_id], 'shared_context') else []
326
+ print(f"Available knowledge keys: {coordinator_keys}")
327
+
328
+ # Ask coordinator to synthesize all information
329
+ synthesis_question = f"Synthesize all the information shared about {topic} into a comprehensive summary including key concepts, analysis, implementation plan, and creative extensions."
330
+ print(f"\nQuestion to coordinator: {synthesis_question}\n")
331
+
332
+ # Make the call and capture the response
333
+ final_synthesis = network.interact_with_agent_programmatically(coordinator_id, synthesis_question)
334
+
335
+ # Record the interaction
336
+ interactions.append({
337
+ "step": 5,
338
+ "from": "user",
339
+ "to": coordinator_id,
340
+ "message": synthesis_question,
341
+ "response": final_synthesis
342
+ })
343
+
344
+ print(f"\nCoordinator's response (final synthesis):")
345
+ print(f"{'-'*40}")
346
+ print(final_synthesis)
347
+ print(f"{'-'*40}")
348
+
349
+ # Broadcast final synthesis to all agents
350
+ print(f"\nBroadcasting final synthesis to all agents...")
351
+ broadcast_message = f"Final synthesis on {topic} is complete. Thank you all for your contributions!"
352
+
353
+ # Show the tool call details
354
+ print(f"Tool call details:")
355
+ print(f"- Tool: broadcast_message")
356
+ print(f"- From: {coordinator_id}")
357
+ print(f"- Message: '{broadcast_message}'")
358
+
359
+ # Make the actual tool call
360
+ network.broadcast_message(coordinator_id, broadcast_message)
361
+
362
+ # Record the interaction
363
+ interactions.append({
364
+ "step": "5a",
365
+ "from": coordinator_id,
366
+ "to": "all agents",
367
+ "tool": "broadcast_message",
368
+ "message": broadcast_message
369
+ })
370
+
371
+ # Present the final collaborative output
372
+ print(f"\n{'='*80}")
373
+ print(f"FINAL COLLABORATIVE OUTPUT ON: {topic}")
374
+ print(f"{'='*80}\n")
375
+ print(final_synthesis)
376
+ print(f"\n{'='*80}")
377
+
378
+ # Show the full interaction graph
379
+ print(f"\n{'='*80}")
380
+ print(f"AGENT INTERACTION SUMMARY")
381
+ print(f"{'='*80}")
382
+ for interaction in interactions:
383
+ if "tool" in interaction:
384
+ print(f"[Step {interaction['step']}] {interaction['from']} → {interaction['to']} "
385
+ f"(via {interaction['tool']}): {interaction.get('key', interaction.get('message', ''))}")
386
+ else:
387
+ print(f"[Step {interaction['step']}] {interaction['from']} → {interaction['to']}: "
388
+ f"{interaction['message'][:50]}..." if len(interaction['message']) > 50 else interaction['message'])
389
+
390
+ print(f"\nCollaboration demo with detailed logs complete!")
391
+ return final_synthesis
392
+
393
+
394
+ if __name__ == "__main__":
395
+ # Run the interaction with our specific topic
396
+ run_agent_collaboration_with_logs("MCP and future of agentic work")
@@ -0,0 +1,107 @@
1
+ """
2
+ Show Agent Interactions
3
+
4
+ This script demonstrates a simplified version of agent interactions,
5
+ making it clear how agents communicate with each other using MCP protocol
6
+ """
7
+
8
+ import os
9
+ import time
10
+ from demos.network.agent_network_example import AgentNetwork
11
+
12
+ # Enable verbose logging for all agent interactions
13
+ os.environ["AUTOGEN_VERBOSE"] = "1"
14
+
15
+ def main():
16
+ """Run a simplified agent interaction demo with clear visualization of messages."""
17
+ print("\n=== AGENT INTERACTIONS DEMONSTRATION ===\n")
18
+
19
+ # Create the agent network
20
+ print("1. Creating agent network with specialized agents...")
21
+ network = AgentNetwork()
22
+ network.create_network()
23
+ print(f" Network created with {len(network.agents)} agents:")
24
+ for agent_id, agent in network.agents.items():
25
+ print(f" - {agent.name} ({agent_id})")
26
+
27
+ # Set a topic for discussion
28
+ topic = "MCP and future of agentic work"
29
+ print(f"\n2. Setting collaboration topic: {topic}")
30
+ network.set_topic(topic)
31
+
32
+ # STEP 1: Direct agent-to-agent communication
33
+ print("\n3. DEMONSTRATING DIRECT AGENT COMMUNICATION")
34
+ print(" Researcher -> Analyst")
35
+ print(" ----------------------------------------")
36
+
37
+ # Researcher discovers information
38
+ research_question = f"What is {topic} and why is it important? Provide key concepts."
39
+ print(f" Question to researcher: {research_question}")
40
+ research_findings = network.interact_with_agent_programmatically("researcher", research_question)
41
+ print(f" Researcher's response: '{research_findings[:100]}...'")
42
+
43
+ # Researcher shares with analyst
44
+ print(f"\n Sharing knowledge from Researcher to Analyst...")
45
+ network.share_knowledge(
46
+ from_agent_id="researcher",
47
+ to_agent_id="analyst",
48
+ knowledge_key="research_findings",
49
+ knowledge_value=research_findings
50
+ )
51
+ print(f" ✓ Knowledge shared successfully")
52
+
53
+ # STEP 2: Tool-based communication
54
+ print("\n4. DEMONSTRATING TOOL-BASED COMMUNICATION")
55
+ print(" Analyst calls Planner as a tool")
56
+ print(" ----------------------------------------")
57
+
58
+ # Analyst uses the planner as a tool
59
+ analysis_request = f"Based on this research, create a short analysis of {topic} highlighting benefits and challenges."
60
+ print(f" Request to analyst: {analysis_request}")
61
+ analyst_response = network.interact_with_agent_programmatically("analyst", analysis_request)
62
+ print(f" Analyst's response (which includes calling the planner as a tool): '{analyst_response[:100]}...'")
63
+
64
+ # STEP 3: Multi-agent coordination
65
+ print("\n5. DEMONSTRATING MULTI-AGENT COORDINATION")
66
+ print(" Coordinator broadcasts to all agents")
67
+ print(" ----------------------------------------")
68
+
69
+ # Coordinator broadcasts to all agents
70
+ coordinator_message = f"Team, I need everyone's input on {topic}. Please share your specialized perspectives."
71
+ print(f" Broadcast message: {coordinator_message}")
72
+ network.broadcast_message("coordinator", coordinator_message)
73
+ print(f" ✓ Message broadcast to all agents in the network")
74
+
75
+ # STEP 4: Context sharing
76
+ print("\n6. DEMONSTRATING CONTEXT SHARING")
77
+ print(" Agents update and access shared context")
78
+ print(" ----------------------------------------")
79
+
80
+ # Planner updates the shared workspace with a plan
81
+ planning_request = f"Create a simple implementation plan for {topic}"
82
+ print(f" Request to planner: {planning_request}")
83
+ plan = network.interact_with_agent_programmatically("planner", planning_request)
84
+ print(f" Planner's response: '{plan[:100]}...'")
85
+
86
+ # Creative accesses the plan and builds upon it
87
+ creative_request = f"Based on the existing plan, suggest innovative extensions for {topic}"
88
+ print(f" Request to creative: {creative_request}")
89
+ creative_response = network.interact_with_agent_programmatically("creative", creative_request)
90
+ print(f" Creative's response (building on shared context): '{creative_response[:100]}...'")
91
+
92
+ # Show network context
93
+ print("\n=== AGENT NETWORK COLLABORATION SUMMARY ===")
94
+ print("During this demonstration:")
95
+ print("1. The Researcher investigated the topic and shared findings with the Analyst")
96
+ print("2. The Analyst evaluated the research, calling the Planner as a tool for help")
97
+ print("3. The Coordinator broadcast a message to all agents in the network")
98
+ print("4. The Planner created an implementation plan stored in shared context")
99
+ print("5. The Creative accessed the shared context to build upon the plan")
100
+ print("\nThis demonstrates how agents collaborate through:")
101
+ print("- Direct knowledge sharing (agent to agent)")
102
+ print("- Tool-based communication (using other agents as tools)")
103
+ print("- Broadcasting (one to many communication)")
104
+ print("- Context sharing (maintaining shared knowledge state)")
105
+
106
+ if __name__ == "__main__":
107
+ main()
@@ -0,0 +1,74 @@
1
+ """
2
+ Simplified autonomous agent collaboration demonstration
3
+ """
4
+
5
+ from demos.langgraph.autonomous_langgraph_network import AutonomousAgentNetwork
6
+ import sys
7
+ import time
8
+
9
+ def main():
10
+ """Run a simplified autonomous collaboration demo"""
11
+ print(f"\n{'='*80}")
12
+ print(f"SIMPLIFIED AUTONOMOUS AGENT COLLABORATION DEMO")
13
+ print(f"{'='*80}\n")
14
+
15
+ # Get topic from command line or use default
16
+ if len(sys.argv) > 1:
17
+ topic = " ".join(sys.argv[1:])
18
+ else:
19
+ topic = "Future of remote work"
20
+
21
+ print(f"Research topic: {topic}")
22
+ print(f"{'='*40}")
23
+
24
+ # Create the autonomous agent network
25
+ print("Creating autonomous agent network...")
26
+ network = AutonomousAgentNetwork()
27
+ network.create_network()
28
+
29
+ # Initialize the shared workspace
30
+ print("\nInitial workspace state:")
31
+ network.show_workspace()
32
+
33
+ # Set up a minimal autonomous collaboration
34
+ # We'll manually introduce messages between agents to see how they route
35
+ print("\nStarting autonomous collaboration...")
36
+
37
+ # Start with coordinator introducing the topic
38
+ coordinator_message = f"""
39
+ I need the team to collaboratively research the topic: "{topic}"
40
+
41
+ Each agent should contribute based on their specialty.
42
+ """
43
+
44
+ # Add initial message as if from "user"
45
+ initial_messages = [{"role": "user", "content": coordinator_message}]
46
+
47
+ # Set up research topic in context
48
+ network.context.set("research_topic", {
49
+ "title": topic,
50
+ "started_at": time.time()
51
+ })
52
+
53
+ # Create the initial message for the coordinator
54
+ initial_message = {
55
+ "role": "user",
56
+ "content": f"I need your help researching the topic: '{topic}'. Please work with the other agents to explore this topic collaboratively."
57
+ }
58
+
59
+ # Run a few steps of autonomous collaboration
60
+ print("\nStarting autonomous collaboration with 5 max steps...")
61
+
62
+ # Use the research_topic method with a limited number of steps
63
+ network.research_topic(topic, max_steps=5)
64
+
65
+ # Show the final workspace state
66
+ print("\nFinal workspace state after collaboration:")
67
+ network.show_workspace()
68
+
69
+ print(f"\n{'='*80}")
70
+ print(f"AUTONOMOUS COLLABORATION DEMO COMPLETE")
71
+ print(f"{'='*80}\n")
72
+
73
+ if __name__ == "__main__":
74
+ main()