from agno.agent import Agentfrom agno.models.openai import OpenAIChatfrom agno.tools.e2b import E2BToolse2b_tools = E2BTools( timeout=600, # 10 minutes timeout (in seconds) filesystem=True, internet_access=True, sandbox_management=True, command_execution=True,)agent = Agent( name="Code Execution Sandbox", agent_id="e2b-sandbox", model=OpenAIChat(id="gpt-4o"), tools=[e2b_tools], markdown=True, show_tool_calls=True, instructions=[ "You are an expert at writing and validating Python code using a secure E2B sandbox environment.", "Your primary purpose is to:", "1. Write clear, efficient Python code based on user requests", "2. Execute and verify the code in the E2B sandbox", "3. Share the complete code with the user, as this is the main use case", "4. Provide thorough explanations of how the code works", ],)# Example: Generate Fibonacci numbersagent.print_response( "Write Python code to generate the first 10 Fibonacci numbers and calculate their sum and average")# Example: Data visualizationagent.print_response( "Write a Python script that creates a sample dataset of sales by region and visualize it with matplotlib")# Example: Run a web serveragent.print_response( "Create a simple FastAPI web server that displays 'Hello from E2B Sandbox!' and run it to get a public URL")# Example: Sandbox managementagent.print_response("What's the current status of our sandbox and how much time is left before timeout?")# Example: File operationsagent.print_response("Create a text file with the current date and time, then read it back")
from agno.agent import Agentfrom agno.models.openai import OpenAIChatfrom agno.tools.e2b import E2BToolse2b_tools = E2BTools( timeout=600, # 10 minutes timeout (in seconds) filesystem=True, internet_access=True, sandbox_management=True, command_execution=True,)agent = Agent( name="Code Execution Sandbox", agent_id="e2b-sandbox", model=OpenAIChat(id="gpt-4o"), tools=[e2b_tools], markdown=True, show_tool_calls=True, instructions=[ "You are an expert at writing and validating Python code using a secure E2B sandbox environment.", "Your primary purpose is to:", "1. Write clear, efficient Python code based on user requests", "2. Execute and verify the code in the E2B sandbox", "3. Share the complete code with the user, as this is the main use case", "4. Provide thorough explanations of how the code works", ],)# Example: Generate Fibonacci numbersagent.print_response( "Write Python code to generate the first 10 Fibonacci numbers and calculate their sum and average")# Example: Data visualizationagent.print_response( "Write a Python script that creates a sample dataset of sales by region and visualize it with matplotlib")# Example: Run a web serveragent.print_response( "Create a simple FastAPI web server that displays 'Hello from E2B Sandbox!' and run it to get a public URL")# Example: Sandbox managementagent.print_response("What's the current status of our sandbox and how much time is left before timeout?")# Example: File operationsagent.print_response("Create a text file with the current date and time, then read it back")