Last week we shared about how you can use code generation to compose tools.
But code generation can also give your agents new capabilities- like proactively acting on your behalf.
In this case, I want to make an email agent that processes my emails.
Running an agent on every email I receive would be slow & unpredictable, so instead I'm allowing the user to generate callbacks that are called when I get an email.
Here's an example generated function:
When doing code generation, I like to think in terms of files that execute, instead of evaluating code in a repl. Files allow Claude to verify its work, create helper scripts, etc.
In my email agent, listeners are scripts in a folder that store logs as well.
This code is all run in a sandbox. So when the user makes a request that suggests a new listener, the AI writes a listener file, the backend detects it, updates and sends over an event.
Everything looks seamless to the user.
Code generation in a sandbox powered by an agent is one of the most powerful tools for creating radically new user experiences.
Look out for more content here, my next post will be about UI generation.
This week we made subagents resumable, added a Plan subagent, introduced prompt based stop hooks, fixed several high priority bugs & much more across the CLI, web and SDK.
We're also replacing output styles with with more powerful alternatives:
Next week, we're replacing output styles in Claude Code.
We found in practice that less than 1% of users actively used output styles, and they can be recreated through other extension points via plugins.
Around November 5th, your user-level output styles will be converted automatically to a plugin.
You can recreate your own output styles by using hooks that append to the system prompt. See an example here:
I've done dozens of calls with companies making general agents over the past few weeks and my advice generally boils down to: "use the bash tool more"
Here's a concrete example from my email agent:
The user asks: "How much did I spend on ride sharing this week?"
With tool calls, you have to fetch emails and then have the model figure it out from there. You might have fetched ~100 emails and it will be hard for the model to find this data.
With the bash tool, you can save these results to files and then search.
This lets the model:
- ground its results in reproducible code
- take multiple steps at finding everything
- double check its work and verify it
Besides Haiku 4.5, we added support for Claude Skills, gave Claude a new tool for asking interactive questions, added an ‘Explore’ subagent, auto-background long running tasks and fixed several bugs.
Instead of dumping a ton of emails into context, I write them to a file and let the agent grep across those files.
Fundamentally this works because it lets your agent have multiple passes at a problem and let it fix its work.
In this case it can try a few different address searches, correlate them to exact lines to make sure it doesn't hallucinate and extract them in a structured way.
If I wasn’t at Anthropic, I would be making agents using the Claude Code SDK.
But doing > talking. So I’m building in public and open sourcing a local email agent.
This is part one on agentic search.
First, why the Claude Code SDK?
Whenever I’ve built an agent in the past I ended up hand rolling the same patterns that are now just way easier to use the Claude Code SDK.
In this example I’m using it for subagents, context management, the file system & code generation.
Building Context
Email has a ton of context on me. My ideal agent should be able to (with permission):
- Know info about me like my address, phone number, etc
- Write intros based on the context I have with contacts
- Find all relevant emails to draft a response