MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / AutomatedUserProxyAgent

Class AutomatedUserProxyAgent

examples/ag2/ag2_async_agent.py:54–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53# Define a custom UserProxyAgent that simulates automated user responses
54class AutomatedUserProxyAgent(UserProxyAgent):
55 def __init__(self, name: str, **kwargs):
56 super().__init__(name, **kwargs)
57 self.response_count = 0
58 self.predefined_responses = [
59 "Yes, please generate interview questions for these topics.",
60 "The questions look good. Can you make them more specific to senior-level positions?",
61 "Perfect! These questions are exactly what we need. Thank you!",
62 ]
63
64 async def a_get_human_input(self, prompt: str) -> str:
65 # Simulate async processing before responding
66 await simulate_async_processing(f"Processing user input #{self.response_count + 1}")
67
68 if self.response_count < len(self.predefined_responses):
69 response = self.predefined_responses[self.response_count]
70 self.response_count += 1
71 print(f"👤 User: {response}")
72 return response
73 else:
74 print("👤 User: TERMINATE")
75 return "TERMINATE"
76
77 async def a_receive(
78 self,
79 message: Union[Dict, str],
80 sender,
81 request_reply: Optional[bool] = None,
82 silent: Optional[bool] = False,
83 ):
84 await super().a_receive(message, sender, request_reply, silent)
85
86
87# Define an AssistantAgent that simulates async processing before responding

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…