Skip to content

Commit 0dc6bb3

Browse files
Craig ShoemakerCraig Shoemaker
authored andcommitted
updates
1 parent 20e960c commit 0dc6bb3

1 file changed

Lines changed: 38 additions & 38 deletions

File tree

articles/sre-agent/code-interpreter.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.topic: how-to
1010
ms.date: 01/17/2026
1111
---
1212

13-
# Run code with Code Interpreter in Azure SRE Agent
13+
# Run code by using Code Interpreter in Azure SRE Agent
1414

1515
Code Interpreter enables you to execute Python code and shell commands in a secure, isolated sandbox environment. Use Code Interpreter to analyze data, create visualizations, generate PDF reports, and automate file operations without leaving your SRE Agent conversation.
1616

@@ -30,25 +30,25 @@ In this article, you learn how to:
3030

3131
Code Interpreter runs in an isolated Azure Container Apps session with the following characteristics:
3232

33-
- **No network access**: The sandbox can't make outbound HTTP/HTTPS requests
34-
- **No process spawning**: Commands like `subprocess` and `os.system` are blocked
35-
- **No package installation**: `pip install` and `conda install` aren't available
36-
- **Isolated file system**: All files must be saved to `/mnt/data/`
33+
- **No network access**: The sandbox can't make outbound HTTP or HTTPS requests.
34+
- **No process spawning**: Commands like `subprocess` and `os.system` are blocked.
35+
- **No package installation**: `pip install` and `conda install` aren't available.
36+
- **Isolated file system**: All files must be saved to `/mnt/data/`.
3737

3838
These restrictions ensure that code execution is secure and predictable. Common data science libraries like pandas, matplotlib, and seaborn are preinstalled.
3939

4040
## Get started with Code Interpreter
4141

42-
Code Interpreter tools are automatically available in your SRE Agent conversations. Ask the agent to perform tasks using natural language.
42+
Code Interpreter tools are automatically available in your SRE Agent conversations. Ask the agent to perform tasks by using natural language.
4343

4444
### Example prompts
4545

4646
Try these prompts to get started:
4747

48-
- "Analyze this CSV data and create a chart showing incidents by category"
49-
- "Generate a PDF summary of today's incidents"
50-
- "Parse this JSON file and extract the error patterns"
51-
- "List all files in the session and show their sizes"
48+
- "Analyze this CSV data and create a chart showing incidents by category."
49+
- "Generate a PDF summary of today's incidents."
50+
- "Parse this JSON file and extract the error patterns."
51+
- "List all files in the session and show their sizes."
5252

5353
### Your first Python script
5454

@@ -98,7 +98,7 @@ print(summary)
9898

9999
### Create visualizations
100100

101-
Generate charts to communicate insights:
101+
Generate charts to communicate insights.
102102

103103
```python
104104
import matplotlib.pyplot as plt
@@ -118,7 +118,7 @@ plt.savefig('/mnt/data/category_chart.png', dpi=150)
118118

119119
### Generate PDF reports
120120

121-
Create formatted PDF documents for stakeholders:
121+
Create formatted PDF documents for stakeholders.
122122

123123
```python
124124
from reportlab.pdfgen import canvas
@@ -144,7 +144,7 @@ The agent returns a download link for the generated PDF.
144144

145145
### Process log files
146146

147-
Search and analyze log files using shell commands:
147+
Search and analyze log files by using shell commands.
148148

149149
```bash
150150
# Count error occurrences by type
@@ -162,49 +162,49 @@ Code Interpreter provides the following tools:
162162

163163
### ExecutePythonCode
164164

165-
Execute Python code in the isolated sandbox.
165+
Runs Python code in an isolated sandbox.
166166

167167
| Parameter | Type | Required | Description |
168168
|-----------|------|----------|-------------|
169-
| `pythonCode` | string | Yes | Python code to execute (max 20,000 characters) |
170-
| `timeoutSeconds` | integer | No | Execution timeout (default: 120, max: 900) |
169+
| `pythonCode` | string | Yes | Python code to run (up to 20,000 characters) |
170+
| `timeoutSeconds` | integer | No | Execution timeout in seconds (default: 120, maximum: 900) |
171171

172-
**Output**: Images display inline as markdown. Data files return as download links.
172+
**Output**: Images show inline as markdown. Data files return as download links.
173173

174174
### GeneratePdfReport
175175

176-
Generate PDF documents from Python code.
176+
Creates PDF documents from Python code.
177177

178178
| Parameter | Type | Required | Description |
179179
|-----------|------|----------|-------------|
180180
| `pythonCode` | string | Yes | Python code that creates a PDF file |
181181
| `expectedOutputFilename` | string | Yes | Path where the PDF is saved (for example, `report.pdf`) |
182182
| `saveAsFilename` | string | Yes | Download filename (for example, `daily_summary.pdf`) |
183-
| `timeoutSeconds` | integer | No | Execution timeout (default: 180, max: 900) |
183+
| `timeoutSeconds` | integer | No | Execution timeout in seconds (default: 180, maximum: 900) |
184184

185185
### RunShellCommand
186186

187-
Execute shell commands in the sandbox.
187+
Runs shell commands in the sandbox.
188188

189189
| Parameter | Type | Required | Description |
190190
|-----------|------|----------|-------------|
191-
| `command` | string | Yes | Shell command to execute |
192-
| `explanation` | string | No | Description logged with the command |
191+
| `command` | string | Yes | Shell command to run |
192+
| `explanation` | string | No | Description to log with the command |
193193
| `isBackground` | boolean | No | Must be `false` (background jobs aren't supported) |
194194
| `timeoutSeconds` | integer | No | Execution timeout (default: 120, max: 240) |
195195

196196
> [!NOTE]
197-
> Commands run from `/mnt/data/`. Use relative paths and chain commands with `;` instead of `&&`.
197+
> The commands run from `/mnt/data/`. Use relative paths and chain commands by using `;` instead of `&&`.
198198
199199
### File operations
200200

201201
| Tool | Description |
202202
|------|-------------|
203-
| `ReadSessionFile` | Read contents of a file from `/mnt/data/` |
204-
| `SearchSessionFiles` | Search for text within files using grep-style patterns |
205-
| `ListSessionFiles` | List all files in the session with metadata |
206-
| `GetSessionFile` | Download a file from the session |
207-
| `UploadFileToSession` | Upload a file for further processing |
203+
| `ReadSessionFile` | Reads the contents of a file from `/mnt/data/`. |
204+
| `SearchSessionFiles` | Searches for text within files using grep-style patterns. |
205+
| `ListSessionFiles` | Lists all files in the session with metadata. |
206+
| `GetSessionFile` | Downloads a file from the session. |
207+
| `UploadFileToSession` | Uploads a file for further processing. |
208208

209209
#### Supported file types
210210

@@ -216,7 +216,7 @@ Execute shell commands in the sandbox.
216216

217217
## Limitations
218218

219-
The following operations are blocked for security:
219+
For security reasons, the system blocks the following operations:
220220

221221
| Category | Blocked operations |
222222
|----------|-------------------|
@@ -229,21 +229,21 @@ The following operations are blocked for security:
229229

230230
### Code execution fails
231231

232-
- Verify your code doesn't use blocked operations like subprocess or network calls
233-
- Check that all file paths point to `/mnt/data/`
234-
- Ensure your code is under 20,000 characters
232+
- Verify your code doesn't use blocked operations like `subprocess` or network calls.
233+
- Check that all file paths point to `/mnt/data/`.
234+
- Ensure your code is under 20,000 characters.
235235

236236
### Files don't appear in output
237237

238-
- Confirm files are saved to `/mnt/data/`
239-
- Use `ListSessionFiles` to verify file creation
240-
- Check that the file extension is supported
238+
- Confirm you save files to `/mnt/data/`.
239+
- Use `ListSessionFiles` to verify file creation.
240+
- Check that the file extension is supported.
241241

242242
### Timeout errors
243243

244-
- Increase the `timeoutSeconds` parameter (maximum 900 seconds)
245-
- Optimize your code to reduce execution time
246-
- Split large operations into smaller chunks
244+
- Increase the `timeoutSeconds` parameter (maximum 900 seconds).
245+
- Optimize your code to reduce execution time.
246+
- Split large operations into smaller chunks.
247247

248248
## Related content
249249

0 commit comments

Comments
 (0)