Skip to Content
Custom RoutinesConceptsCombining Routines

Combining Routines

Sometimes you need one routine to delegate a focused task to another routine (for writing, summarizing, or specialized logic), then continue with the result. Combining routines lets you chain capabilities while keeping each routine focused.

When to combine routines

Use AI intelligence for tasks that need reasoning:

  • Writing — Composing emails, summaries, or reports
  • Summarizing — Condensing information into key points
  • Deciding — Making judgment calls about content
  • Analyzing — Understanding context, sentiment, or priority

Use deterministic steps for tasks that need precision:

  • Filtering — Removing items by specific criteria
  • Formatting — Structuring output in a specific way
  • Aggregating — Grouping, counting, or organizing data
  • Iterating — Processing a list of items one by one

How it works

A routine can call another routine mid-run. The calling routine pauses, the called routine does its work (like writing a summary), and the result comes back for the caller to use.

For custom routines, this relationship is explicit: the parent routine must list the child in its Callable routines setting before invoke_routine can call it. You can configure that in the routine settings UI, or through the existing routine management tools by setting callable_routine_ids when creating a routine or callable_routines.add/remove/replace when updating one. When discovering candidates through tooling, use list_routines({ callable_only: true }) so the returned routines are actually eligible.

This is powerful because it lets you combine the best of both approaches:

  1. Precise data gathering — Search emails, filter results, organize data
  2. Intelligent writing (AI) — Write a natural-sounding summary of what you found
  3. Precise delivery — Send the summary in a specific format

Example: Smart daily summary

Here’s how a daily summary routine might combine code and AI:

Step 1: Gather (code) — Search for all emails processed by Auto-inbox in the last 24 hours

Step 2: Organize (code) — Group emails by label and format them into a structured list

Step 3: Write (AI) — Ask the AI to write a friendly intro and outro based on the day’s activity

Step 4: Send (code) — Combine the structured list with the AI-written intro and send it to you

The result is a daily email that has both precise data (exact email counts, correct groupings) and a human touch (a natural-sounding summary).

Setting up AI helpers

When you create routines that delegate to other routines, define each helper routine with a clear purpose. Each helper should have:

  • A description — What this helper does
  • Instructions — How the helper should behave
  • Expected output — What the helper should return

For example, you might define a “summary writer” helper with instructions like: “Given a list of emails, write a 2-3 sentence intro summarizing the day’s activity and a brief closing line.”

Keep each helper focused on one task. It’s better to have a “summarizer” and a “writer” than one helper that tries to do everything.

Best practices

Provide context. The more relevant information you give the AI helper, the better its output will be. Include the data it needs to work with.

Define the output format. Tell the helper exactly what structure you expect back — for example, an intro paragraph and a closing line. This makes it easier to use the result in subsequent steps.

Separate AI from logic. Let code handle data gathering and formatting. Let AI handle writing and reasoning. This gives you the best of both worlds.

Last updated on