Skip to content

Commit 56efcb4

Browse files
tylergibbs1claude
andcommitted
Add code mode section to README
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9ce8b74 commit 56efcb4

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A better TypeScript agent SDK for Azure OpenAI. Build multi-agent systems with t
2222
- **Type-safe from schema to output** — Zod schemas drive tool parameters, structured output, and validation. Context types flow through agents, hooks, and guardrails at compile time.
2323
- **Zero dependencies** — only Zod as a peer dep. No transitive dependency sprawl, no framework lock-in.
2424

25-
`agents` `tools` `streaming` `structured output` `handoffs` `subagents` `guardrails` `hooks` `tracing` `sessions` `abort signals` `todo tracking` `cost tracking`
25+
`agents` `tools` `streaming` `structured output` `handoffs` `subagents` `guardrails` `hooks` `tracing` `sessions` `abort signals` `code mode` `todo tracking` `cost tracking`
2626

2727
## Install
2828

@@ -408,6 +408,37 @@ const agent = new Agent({
408408
});
409409
```
410410

411+
### Code Mode (Experimental)
412+
413+
Let LLMs write code that orchestrates multiple tools instead of calling them one at a time. Inspired by [Cloudflare's Code Mode](https://blog.cloudflare.com/code-mode-the-better-way-to-use-mcp) — LLMs are better at writing code than making individual tool calls.
414+
415+
```ts
416+
import { createCodeModeTool, FunctionExecutor } from "stratus-sdk/core";
417+
418+
const executor = new FunctionExecutor({ timeout: 30_000 });
419+
const codemode = createCodeModeTool({
420+
tools: [getWeather, sendEmail, lookupOrder],
421+
executor,
422+
});
423+
424+
const agent = new Agent({
425+
name: "assistant",
426+
model,
427+
tools: [codemode],
428+
});
429+
430+
// The LLM writes code like:
431+
// async () => {
432+
// const weather = await codemode.get_weather({ location: "London" });
433+
// if (weather.temp > 60) {
434+
// await codemode.send_email({ to: "team@co.com", subject: "Nice day!", body: ... });
435+
// }
436+
// return { weather, notified: true };
437+
// }
438+
```
439+
440+
`createCodeModeTool` generates TypeScript types from your tools, presents the LLM with a single `execute_code` tool, and runs the generated code in an executor. All tool calls happen within one invocation — no round-trips through the model between calls. Implement the `Executor` interface for custom sandboxes (isolated-vm, containers, Cloudflare Workers).
441+
411442
## Imports
412443

413444
Stratus provides three export paths:

0 commit comments

Comments
 (0)