Skip to main content

Overview

The Azure Container Apps dynamic sessions based code Interpreter tool is a tool that allows you to execute and run development environments using the AI Agents. The user sends code to run; the agent executes it in an Azure dynamic session and returns the output.
pip install langchain-azure-dynamic-sessions langchain-openai langchainhub langchain langchain-community
from praisonaiagents import Agent, AgentTeam
import getpass
from langchain_azure_dynamic_sessions import SessionsPythonREPLTool

POOL_MANAGEMENT_ENDPOINT = getpass.getpass()

coder_agent = Agent(instructions="""word = "strawberry"
                                    count = word.count("r")
                                    print(f"There are {count}'R's in the word 'Strawberry'")""", tools=[SessionsPythonREPLTool])

agents = AgentTeam(agents=[coder_agent])
agents.start()

Getting Started

1

Simple Usage

  1. Install dependencies (see Overview above)
  2. Set required API keys in your environment
  3. Run the agent example in Overview
2

With Configuration

Use the same tool with an agent — see the Overview example, or pass env vars from the sections above.

How It Works


Best Practices

Azure Container Apps dynamic sessions are ephemeral — treat each run as stateless and pass all inputs explicitly.
Only run code the agent generated from trusted instructions. Sandbox limits protect the host, not your data.
Long-running code can hit the session timeout. Wrap execution in error handling so the agent recovers gracefully.

Python

Run Python code

Shell

Shell commands

Bearly Code Interpreter

Cloud code execution