Thariq Profile picture
Nov 11 5 tweets 2 min read Read on X
🧵 Making Proactive Agents with Code Generation

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: Image
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. Image
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.

You can see my code for the email agent here: github.com/anthropics/cla…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Thariq

Thariq Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @trq212

Nov 1
Claude Code Weekly Round Up

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:Image
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:

See an example here: github.com/anthropics/cla…
Read 5 tweets
Oct 27
Why even non-coding agents need bash

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:Image
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
Read 7 tweets
Oct 18
Claude Code Weekly Round Up

A big week for shipping!

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.Image
in case you missed it, launch posts for Haiku:
Read 4 tweets
Sep 22
Your Agent should use a File System

This is a hill I will die on. Every agent can use a file system.

The file system is an elegant way of representing state that your agent could read into context & allowing it to verify its work.

🧵on why and examplesImage
Claude Code was what proved this to me.

Before CC, people though context windows would get long enough that you could just fit a codebase into context.

But that is not how programming works. You don't need to remember everything, you just need to know how to find it.
Here's an example from my open source email agent (github.com/anthropic-expe…)

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.Image
Read 6 tweets
Sep 17
Making an Email Agent using the Claude Code SDK

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
Read 7 tweets
Aug 7
It's maddening that we're creating real time AI game engines, but there aren't any actual AI games.

🧵 here's my take as an ex-gaming founder on why
People don't want generative slop.

The edge that games have over other media is achievement.

As Tiktok increasingly offers the best ratio of effort to dopamine, games need to lean into achievement and mastery.

In an infinitely generated world, where do you find the mastery?
Creation is Fun

Is Claude Code an AI video game? I've had several people make that claim to me.

It's easy to learn and hard to master. It rewards you with joyful output.

It feels more like riding a horse than turning on an oven.
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(