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

Function main

examples/autogen/MathAgent.py:70–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68
69
70async def main():
71 assistant = AssistantAgent(
72 name="Assistant",
73 system_message="You are a helpful AI assistant. You can help with simple calculations. Return 'TERMINATE' when the task is done.",
74 model_client=model_client,
75 tools=[calculator],
76 reflect_on_tool_use=True,
77 )
78
79 initial_task_message = "What is (1423 - 123) / 3 + (32 + 23) * 5?"
80 print(f"User Task: {initial_task_message}")
81
82 try:
83 from autogen_core import CancellationToken
84
85 response = await assistant.on_messages(
86 [TextMessage(content=initial_task_message, source="user")], CancellationToken()
87 )
88
89 final_response_message = response.chat_message
90 if final_response_message:
91 print(f"Assistant: {final_response_message.to_text()}")
92 else:
93 print("Assistant did not provide a final message.")
94
95 agentops.end_trace(tracer, end_state="Success")
96
97 except Exception as e:
98 print(f"An error occurred: {e}")
99 agentops.end_trace(tracer, end_state="Error")
100 finally:
101 await model_client.close()
102
103 # Let's check programmatically that spans were recorded in AgentOps
104 print("\n" + "=" * 50)
105 print("Now let's verify that our LLM calls were tracked properly...")
106 try:
107 agentops.validate_trace_spans(trace_context=tracer)
108 print("\n✅ Success! All LLM spans were properly recorded in AgentOps.")
109 except agentops.ValidationError as e:
110 print(f"\n❌ Error validating spans: {e}")
111 raise
112
113
114if __name__ == "__main__":

Callers 1

MathAgent.pyFile · 0.70

Calls 2

end_traceMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…