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

Function run_code_interpreter_demo

examples/openai_agents/agents_tools.py:74–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72
73
74async def run_code_interpreter_demo():
75 agent = Agent(
76 name="Code interpreter",
77 instructions="You love doing math.",
78 tools=[
79 CodeInterpreterTool(
80 tool_config={"type": "code_interpreter", "container": {"type": "auto"}},
81 )
82 ],
83 )
84
85 with trace("Code interpreter example"):
86 print("Solving math problem...")
87 result = Runner.run_streamed(agent, "What is the square root of 273 * 312821 plus 1782?")
88 async for event in result.stream_events():
89 if (
90 event.type == "run_item_stream_event"
91 and event.item.type == "tool_call_item"
92 and event.item.raw_item.type == "code_interpreter_call"
93 ):
94 print(f"Code interpreter code:\n```\n{event.item.raw_item.code}\n```\n")
95 elif event.type == "run_item_stream_event":
96 print(f"Other event: {event.item.type}")
97
98 print(f"Final output: {result.final_output}")
99
100
101# Run the demo

Callers 1

agents_tools.pyFile · 0.85

Calls 1

AgentClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…