Loading video...

Video Failed to Load

Go Home

🧵 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.

35,797 views • 11 months ago •via X (Twitter)

19 Comments

Thariq's profile picture
Thariq11 months ago

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:

Thariq's profile picture
Thariq11 months ago

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.

Thariq's profile picture
Thariq11 months ago

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.

Thariq's profile picture
Thariq11 months ago

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:

Farouq Aldori's profile picture
Farouq Aldori11 months ago

This is so good!

NA's profile picture
NA11 months ago

your tweets are the best, fascinating seeing different use cases I’ve gone through docs + repo + your tweets what’s the next best resource you recommend? who are you following/learning from? I’m interested in learning from people building with the sdk

Yum⋆₊˚'s profile picture
Yum⋆₊˚11 months ago

Really looking forward to more of your reflections on product design details, CC tools mode is really surprising

Thread Reader App's profile picture
Thread Reader App11 months ago

Your thread is going viral! #TopUnroll 🙏🏼@chaodoze for 🥇unroll

Cat Wearing a Hat's profile picture
Cat Wearing a Hat11 months ago

"But code generation can also give your agents new capabilities- like proactively acting on your behalf." I am genuinely having trouble understanding how these correlate.

Jidé ✨'s profile picture
Jidé ✨11 months ago

Very cool approach

Vishal Dubey's profile picture
Vishal Dubey11 months ago

Thank you for sharing!

Jason Kneen's profile picture
Jason Kneen11 months ago

Man, are you guys just using everything from my MCP Summit talk on servlets and the work I've been doing on this publically for last 5 months with and speaking on spaces, posts, code etc? The thing is you still haven't caught on to the real trick you can do which turns this up past 11....

Karan Jagtiani's profile picture
Karan Jagtiani11 months ago

Curious how you handle versioning and rollback of listener scripts in the sandbox environment?

chaodoze's profile picture
chaodoze11 months ago

@threadreaderapp unroll please

Shreyas Shinde's profile picture
Shreyas Shinde11 months ago

People are getting worthwhile emails!?

Kieran Klaassen's profile picture
Kieran Klaassen11 months ago

love these demos!

smol compute's profile picture
smol compute11 months ago

Could you make tutorials so less technical people can try it too?

take a puff dawg's profile picture
take a puff dawg11 months ago

Anthropic Cookbook from an year ago was goated Not these slops from recently, damn I miss the cookbook team

けーやん's profile picture
けーやん11 months ago

シェアありがとうございます!新しい能力の可能性に驚いています。 皆さんはどんな経験がありますか? 共有しましょう!

Related Videos

New short course: Building Code Agents with Hugging Face smolagents! Learn how to build code agents in this course, created in collaboration with Hugging Face, and taught by Thomas Wolf, its co-founder and CSO, and m_ric, Hugging Face’s Project Lead on Agents. Tool-calling agents use LLMs to generate multiple function calls sequentially to complete a complex sequence of tasks. They generate one function call, execute it, observe, reason, and decide what to do next. Code agents take a different approach. They consolidate all these calls into a single block of code, letting the LLM lay out an entire action plan at once, which can be executed efficiently to provide more reliable results. You’ll learn how to code agents using smolagents, a lightweight agentic framework from Hugging Face. Along the way, you’ll learn how to run LLM-generated code safely and develop an evaluation system to optimize your code agent for production. In detail, you’ll learn: - How agentic systems have evolved, gaining greater levels of agency over time—and why code agents are a next step. - How code agents write their actions in code. - When code agents outperform function-calling agents. - How to run code agents safely in your system using a constrained Python interpreter and sandboxing using E2B. - To trace, debug, and assess the code agent to optimize its behaviours for complex requests. - How to build a research multi-agent system that can find information online and organize it into an interactive report. By the end of this course, you’ll know how to build and run code agents using smolagents, and deploy them safely with a structured evaluation system in your projects. Please sign up here!

Andrew Ng

127,724 views • 1 year ago