Skip to content

Commit 2f66c70

Browse files
whoiskatrinthreepointone
authored andcommitted
Agents changelog 0508 (#24177)
* agents sdk changelog * simplify examples Co-authored-by: Sunil Pai <[email protected]> * simplify examples Co-authored-by: Sunil Pai <[email protected]> * simplify examples Co-authored-by: Sunil Pai <[email protected]> * simplify examples Co-authored-by: Sunil Pai <[email protected]> * Update src/content/changelog/agents/2025-07-21-agents-queue-email-context-update.mdx Co-authored-by: Sunil Pai <[email protected]> * fixed trailing * small fixes and typos * draft new announcement * fix confirmation example * fix a typo * added sandboxes * fix title * small fixes * final fixes * final fixes --------- Co-authored-by: Sunil Pai <[email protected]>
1 parent dd191b3 commit 2f66c70

File tree

2 files changed

+287
-0
lines changed

2 files changed

+287
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
title: Agents SDK adds MCP Elicitation support, http-streamable suppport, task queues, email integration and more
3+
description: Major update brings MCP elicitation, enhanced transport options,auto transport selection, improved error handling, and reliable prop updates, task queues, and email support
4+
products:
5+
- agents
6+
- workers
7+
date: 2025-08-05
8+
---
9+
10+
The latest releases of [@cloudflare/agents](https://github.com/cloudflare/agents) brings major improvements to MCP transport protocols support and agents connectivity. Key updates include:
11+
12+
### MCP elicitation support
13+
14+
MCP servers can now request user input during tool execution, enabling interactive workflows like confirmations, forms, and multi-step processes. This feature uses durable storage to preserve elicitation state even during agent hibernation, ensuring seamless user interactions across agent lifecycle events.
15+
16+
```ts
17+
// Request user confirmation via elicitation
18+
const confirmation = await this.elicitInput({
19+
message: `Are you sure you want to increment the counter by ${amount}?`,
20+
requestedSchema: {
21+
type: "object",
22+
properties: {
23+
confirmed: {
24+
type: "boolean",
25+
title: "Confirm increment",
26+
description: "Check to confirm the increment",
27+
},
28+
},
29+
required: ["confirmed"],
30+
},
31+
});
32+
```
33+
34+
Check out our [demo](https://github.com/whoiskatrin/agents/tree/main/examples/mcp-elicitation-demo) to see elicitation in action.
35+
36+
### HTTP streamable transport for MCP
37+
38+
MCP now supports HTTP streamable transport which is recommended over SSE. This transport type offers:
39+
40+
- **Better performance**: More efficient data streaming and reduced overhead
41+
- **Improved reliability**: Enhanced connection stability and error recover- **Automatic fallback**: If streamable transport is not available, it gracefully falls back to SSE
42+
43+
```ts
44+
export default MyMCP.serve("/mcp", {
45+
binding: "MyMCP",
46+
});
47+
```
48+
49+
The SDK automatically selects the best available transport method, gracefully falling back from streamable-http to SSE when needed.
50+
51+
### Enhanced MCP connectivity
52+
53+
Significant improvements to MCP server connections and transport reliability:
54+
55+
- **Auto transport selection**: Automatically determines the best transport method, falling back from streamable-http to SSE as needed
56+
- **Improved error handling**: Better connection state management and error reporting for MCP servers
57+
- **Reliable prop updates**: Centralized agent property updates ensure consistency across different contexts
58+
59+
### Lightweight .queue for fast task deferral
60+
61+
You can use `.queue()` to enqueue background work — ideal for tasks like processing user messages, sending notifications etc.
62+
63+
```ts
64+
class MyAgent extends Agent {
65+
doSomethingExpensive(payload) {
66+
// a long running process that you want to run in the background
67+
}
68+
69+
queueSomething() {
70+
await this.queue("doSomethingExpensive", somePayload); // this will NOT block further execution, and runs in the background
71+
await this.queue("doSomethingExpensive", someOtherPayload); // the callback will NOT run until the previous callback is complete
72+
// ... call as many times as you want
73+
}
74+
}
75+
```
76+
77+
Want to try it yourself? Just define a method like processMessage in your agent, and you’re ready to scale.
78+
79+
### New email adapter
80+
81+
Want to build an AI agent that can receive and respond to emails automatically? With the new email adapter and onEmail lifecycle method, now you can.
82+
83+
```ts
84+
export class EmailAgent extends Agent {
85+
async onEmail(email: AgentEmail) {
86+
const raw = await email.getRaw();
87+
const parsed = await PostalMime.parse(raw);
88+
89+
// create a response based on the email contents
90+
// and then send a reply
91+
92+
await this.replyToEmail(email, {
93+
fromName: "Email Agent",
94+
body: `Thanks for your email! You've sent us "${parsed.subject}". We'll process it shortly.`,
95+
});
96+
}
97+
}
98+
```
99+
100+
You route incoming mail like this:
101+
102+
```ts
103+
export default {
104+
async email(email, env) {
105+
await routeAgentEmail(email, env, {
106+
resolver: createAddressBasedEmailResolver("EmailAgent"),
107+
});
108+
},
109+
};
110+
```
111+
112+
You can find a full example [here](https://github.com/cloudflare/agents/tree/main/examples/email-agent).
113+
114+
### Automatic context wrapping for custom methods
115+
116+
Custom methods are now automatically wrapped with the agent's context, so calling `getCurrentAgent()` should work regardless of where in an agent's lifecycle it's called. Previously this would not work on RPC calls, but now just works out of the box.
117+
118+
```ts
119+
export class MyAgent extends Agent {
120+
async suggestReply(message) {
121+
// getCurrentAgent() now correctly works, even when called inside an RPC method
122+
const { agent } = getCurrentAgent()!;
123+
return generateText({
124+
prompt: `Suggest a reply to: "${message}" from "${agent.name}"`,
125+
tools: [replyWithEmoji],
126+
});
127+
}
128+
}
129+
```
130+
131+
Try it out and tell us what you build!
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
title: Cloudflare Sandbox SDK adds streaming, code interpreter, Git support, process control and more
3+
description: The latest release transforms the Sandbox SDK into a full edge-native code execution platform, enabling secure, containerized runtimes with real-time streaming, language interpreters, Git integration, process lifecycle management, and port forwarding.
4+
products:
5+
- agents
6+
- workers
7+
date: 2025-08-05
8+
---
9+
10+
We’ve shipped a major release for the [@cloudflare/sandbox](https://github.com/cloudflare/sandbox-sdk) SDK, turning it into a full-featured, container-based execution platform that runs securely on Cloudflare Workers.
11+
12+
This update adds live streaming of output, persistent Python and JavaScript code interpreters with rich output support (charts, tables, HTML, JSON), file system access, Git operations, full background process control, and the ability to expose running services via public URLs.
13+
14+
This makes it ideal for building AI agents, CI runners, cloud REPLs, data analysis pipelines, or full developer tools — all without managing infrastructure.
15+
16+
### Code interpreter (Python, JS, TS)
17+
18+
Create persistent code contexts with support for rich visual + structured outputs.
19+
20+
#### createCodeContext(options)
21+
22+
Creates a new code execution context with persistent state.
23+
24+
```ts
25+
// Create a Python context
26+
const pythonCtx = await sandbox.createCodeContext({ language: "python" });
27+
28+
// Create a JavaScript context
29+
const jsCtx = await sandbox.createCodeContext({ language: "javascript" });
30+
```
31+
32+
Options:
33+
34+
- language: Programming language ('python' | 'javascript' | 'typescript')
35+
- cwd: Working directory (default: /workspace)
36+
- envVars: Environment variables for the context
37+
38+
#### runCode(code, options)
39+
40+
Executes code with optional streaming callbacks.
41+
42+
```ts
43+
// Simple execution
44+
const execution = await sandbox.runCode('print("Hello World")', {
45+
context: pythonCtx,
46+
});
47+
48+
// With streaming callbacks
49+
await sandbox.runCode(
50+
`
51+
for i in range(5):
52+
print(f"Step {i}")
53+
time.sleep(1)
54+
`,
55+
{
56+
context: pythonCtx,
57+
onStdout: (output) => console.log("Real-time:", output.text),
58+
onResult: (result) => console.log("Result:", result),
59+
},
60+
);
61+
```
62+
63+
Options:
64+
65+
- language: Programming language ('python' | 'javascript' | 'typescript')
66+
- cwd: Working directory (default: /workspace)
67+
- envVars: Environment variables for the context
68+
69+
#### Real-time streaming output
70+
71+
Returns a streaming response for real-time processing.
72+
73+
```ts
74+
const stream = await sandbox.runCodeStream(
75+
"import time; [print(i) for i in range(10)]",
76+
);
77+
// Process the stream as needed
78+
```
79+
80+
#### Rich output handling
81+
82+
Interpreter outputs are auto-formatted and returned in multiple formats:
83+
84+
- text
85+
- html (e.g., Pandas tables)
86+
- png, svg (e.g., Matplotlib charts)
87+
- json (structured data)
88+
- chart (parsed visualizations)
89+
90+
```ts
91+
const result = await sandbox.runCode(
92+
`
93+
import seaborn as sns
94+
import matplotlib.pyplot as plt
95+
96+
data = sns.load_dataset("flights")
97+
pivot = data.pivot("month", "year", "passengers")
98+
sns.heatmap(pivot, annot=True, fmt="d")
99+
plt.title("Flight Passengers")
100+
plt.show()
101+
102+
pivot.to_dict()
103+
`,
104+
{ context: pythonCtx },
105+
);
106+
107+
if (result.png) {
108+
console.log("Chart output:", result.png);
109+
}
110+
```
111+
112+
### Preview URLs from Exposed Ports
113+
114+
Start background processes and expose them with live URLs.
115+
116+
```ts
117+
await sandbox.startProcess("python -m http.server 8000");
118+
const preview = await sandbox.exposePort(8000);
119+
120+
console.log("Live preview at:", preview.url);
121+
```
122+
123+
### Full process lifecycle control
124+
125+
Start, inspect, and terminate long-running background processes.
126+
127+
```ts
128+
const process = await sandbox.startProcess("node server.js");
129+
console.log(`Started process ${process.id} with PID ${process.pid}`);
130+
131+
// Monitor the process
132+
const logStream = await sandbox.streamProcessLogs(process.id);
133+
for await (const log of parseSSEStream<LogEvent>(logStream)) {
134+
console.log(`Server: ${log.data}`);
135+
}
136+
```
137+
138+
- listProcesses() - List all running processes
139+
- getProcess(id) - Get detailed process status
140+
- killProcess(id, signal) - Terminate specific processes
141+
- killAllProcesses() - Kill all processes
142+
- streamProcessLogs(id, options) - Stream logs from running processes
143+
- getProcessLogs(id) - Get accumulated process output
144+
145+
### Git integration
146+
147+
Clone Git repositories directly into the sandbox.
148+
149+
```ts
150+
await sandbox.gitCheckout("https://github.com/user/repo", {
151+
branch: "main",
152+
targetDir: "my-project",
153+
});
154+
```
155+
156+
Sandboxes are still experimental. We're using them to explore how isolated, container-like workloads might scale on Cloudflare — and to help define the developer experience around them.

0 commit comments

Comments
 (0)