Skip to main content
How I AI

How to design AI agent loops: schedules, goals, and subagents in Claude Code and Codex

29 min episode · 2 min read

Episode

29 min

Read time

2 min

Topics

Productivity, Remote Work, Investing

AI-Generated Summary

Key Takeaways

  • Loop Types — Three Distinct Formats: Agent loops take three forms: heartbeats (recurring intervals like every 5 minutes), crons (fixed schedule like every Friday at 9AM), and hooks (event-triggered via webhooks or internal lifecycle events). A fourth type — goal loops — runs continuously until a defined success condition is met or the agent becomes blocked, then stops automatically.
  • Goal Loop Precision: Goal-based loops require explicitly defined evaluation and success criteria in the prompt. Vague goals burn tokens without useful output. OpenAI publishes a dedicated guide for writing Codex goals. A reliable pattern: prompt the sub-agent with a specific, measurable validation target against a defined branch or dataset before the loop begins executing.
  • Sub-Agent Architecture: Both Claude Code and Codex support spawning sub-agents from a parent loop. The parent identifies tasks, then delegates each to a dedicated thread with its own goal loop for validation. In a live demo, a Friday automation scanned recent PRs, generated missing skills, and spawned named sub-agents — Gauss, Galileo — each pursuing independent validation goals concurrently.
  • Loop Cost Management: Loops with loose validation criteria or wide-ranging scope burn tokens rapidly. Goal loops are especially expensive because agents iterate until thresholds are self-assessed as met. Monitoring both cost and execution efficiency is necessary from day one. Applying loops only to well-scoped, repeatable tasks with precise success criteria reduces unnecessary token consumption significantly.
  • Practical Loop Design Framework: Designing a loop mirrors writing a job description for an employee. Define the schedule or trigger, the specific task, the tools available (GitHub, Slack, Google Calendar connectors), and the done condition. A daily PR aging review loop in Claude Code checks for PRs open over 12 hours, babysits merge checks, and posts Slack alerts — all without manual prompting.

What It Covers

This episode demystifies AI agent loops — scheduled, goal-based, and hook-triggered automations in Claude Code and Codex — explaining how to design agents that prompt themselves autonomously, deploy sub-agents for parallel work, and validate outcomes without human input, using practical product and engineering workflow examples.

Key Questions Answered

  • Loop Types — Three Distinct Formats: Agent loops take three forms: heartbeats (recurring intervals like every 5 minutes), crons (fixed schedule like every Friday at 9AM), and hooks (event-triggered via webhooks or internal lifecycle events). A fourth type — goal loops — runs continuously until a defined success condition is met or the agent becomes blocked, then stops automatically.
  • Goal Loop Precision: Goal-based loops require explicitly defined evaluation and success criteria in the prompt. Vague goals burn tokens without useful output. OpenAI publishes a dedicated guide for writing Codex goals. A reliable pattern: prompt the sub-agent with a specific, measurable validation target against a defined branch or dataset before the loop begins executing.
  • Sub-Agent Architecture: Both Claude Code and Codex support spawning sub-agents from a parent loop. The parent identifies tasks, then delegates each to a dedicated thread with its own goal loop for validation. In a live demo, a Friday automation scanned recent PRs, generated missing skills, and spawned named sub-agents — Gauss, Galileo — each pursuing independent validation goals concurrently.
  • Loop Cost Management: Loops with loose validation criteria or wide-ranging scope burn tokens rapidly. Goal loops are especially expensive because agents iterate until thresholds are self-assessed as met. Monitoring both cost and execution efficiency is necessary from day one. Applying loops only to well-scoped, repeatable tasks with precise success criteria reduces unnecessary token consumption significantly.
  • Practical Loop Design Framework: Designing a loop mirrors writing a job description for an employee. Define the schedule or trigger, the specific task, the tools available (GitHub, Slack, Google Calendar connectors), and the done condition. A daily PR aging review loop in Claude Code checks for PRs open over 12 hours, babysits merge checks, and posts Slack alerts — all without manual prompting.

Notable Moment

During a live recording session, a Friday automation was built on the spot that not only scanned a codebase for missing skills but autonomously spawned multiple named sub-agents, each running its own goal-based validation loop — a multi-layer autonomous system created in real time without pre-planning.

Know someone who'd find this useful?

Episode Transcript

Prompts are out and loops are in. If your agent isn't able to prompt itself through an automation, what are you even doing? In today's episode, I'm gonna teach you what a prompt is in normal person speak, how to write one, when it's useful, and some pitfalls to watch out for. We will be doing this in codex and in Cloud Code. And at the end of this episode, you'll be one of the cool kids whose agents prompt itself. Let's get to it. This episode is brought to you by WorkOS. AI has already changed how we work. Tools are helping teams write better code, analyze customer data, and even handle support tickets automatically. But there's a catch. These tools only work well when they have deep access to company systems. Your Copilot needs to see your entire code base. Your chatbot needs to search across internal docs. And for enterprise buyers, that raises serious security concerns. That's why these apps face intense IT scrutiny from day one. To pass, they need secure authentication, access controls, audit logs, the whole suite of enterprise features. Building all that from scratch, it's a massive lift. That's where WorkOS comes in. WorkOS gives you drop in APIs for enterprise features so your app can become enterprise ready and scale up market faster. Think of it like Stripe for enterprise features. OpenAI, Perplexity, and Cursor are already using Work OS to move faster and meet enterprise demands. Join them and hundreds of other industry leaders at workos.com. Start building today. Okay. So why are we all prompt maxing? Of course, it's Pete at Open Claw who told us we are old news if we are prompting, and we really need to be designing loops where our agents can prompt themselves. Now this one tweet spun off tons of content about what is a loop, how to use a loop. And to be honest, I don't think any of them explained it very well. So I am here to answer your safe space questions about what is a loop, how do I get one set up, is it really that useful, and should I really be letting my agents prompt itself. I think the answer is yes And, yes, there are tons of great use cases for loops, and we're gonna talk about how you can use those and how they can be beneficial, especially with software engineering. But there are some reasons why you wouldn't want to use loops. And honestly, I still do a little prompting. So don't worry if you are not loop maxing, you're in good company and you can still get a lot done with AI. So to answer what a loop is, I'm just gonna make this super simple for you all. And this goes back to one of the the earliest articles I wrote on OpenClaw, which was this article about why OpenClaw feels alive even though it's not. And the core of this article was …

Get the full transcript (5,248 words) + summary by email — free

One-time email with the complete transcript and AI summary of this episode. No account needed.

One email, no spam. We’ll also show you what SignalCast does.

Browse all How I AI transcripts →

You just read a 3-minute summary of a 26-minute episode.

Get How I AI summarized like this every Monday — plus up to 2 more podcasts, free.

Pick Your Podcasts — Free

Keep Reading

Books, tools, and gear mentioned in this episode

SignalCast may earn commission on purchases via these links.

Tools

  • Claude CodeRecommended

    by Anthropic

    Agent loops take three forms: heartbeats (recurring intervals like every 5 minutes), crons (fixed schedule like every Friday at 9AM), and hooks (event-triggered via webhooks or internal lifecycle events)... Both Claude Code and Codex support spawning sub-agents from a parent loop.
  • CodexRecommended

    by OpenAI

    Both Claude Code and Codex support spawning sub-agents from a parent loop. The parent identifies tasks, then delegates each to a dedicated thread with its own goal loop for validation.
  • by WorkOS

    💼 SPONSORS [{'name': 'WorkOS', 'url': 'https://workos.com'}]
  • by Runway

    💼 SPONSORS [{'name': 'Runway', 'url': 'https://runwayml.com/howiai'}]

More from How I AI

We summarize every new episode. Want them in your inbox?

Similar Episodes

Related episodes from other podcasts

Explore Related Topics

This podcast is featured in Best AI Podcasts (2026) — ranked and reviewed with AI summaries.

Read this week's Investing & Markets Podcast Insights — cross-podcast analysis updated weekly.

You're clearly into How I AI.

Every Monday, we deliver AI summaries of the latest episodes from How I AI and 192+ other podcasts. Free for one show.

Start My Monday Digest

No credit card · Unsubscribe anytime