Skip to content
LogoLogo

Runnables

A runnable is a callable unit of work with defined inputs and outputs. Toolang currently supports two kinds of runnables: agics and flows.

Runnables are defined in .too files.

Agics and flows

An agic is a model-driven execution loop. It follows instructions, calls tools, and produces a result. An agic may make multiple model and tool calls before completing.

An agic composes model calls from instructions, context, messages, and selected caps. These provide behavioral guidance, runtime information, and access to external capabilities.

A flow defines an explicit workflow. It can call other runnables, process collections, repeat operations, and coordinate concurrent work.

Flows determine the execution order, while agics make model-driven decisions within that structure.

Inputs and outputs

Runnables declare their inputs and output types through signatures.

struct Summary:
  headline: Text
  points: Text[]
 
agic summarize(_: Text, audience: Text) -> Summary:
  Summarize {{_}} for {{audience}}.

A signature can specify:

  • Primary input (_): The main input, always declared first.
  • Named inputs (arguments): Additional inputs accessed by name.
  • Output type (->): The type of result the runnable produces.

Toolang provides default types to keep definitions concise:

ElementDefault
Primary inputPart[]
Named inputsText
OutputText

The default Part[] input supports multimodal content, including text, images, audio, and documents. Other supported types include Number, Boolean, Json, arrays, and structs.

When a runnable accepts only the primary input, its parameter list can be omitted. Use () to explicitly declare a runnable with no inputs.

Explicit types are only needed when the defaults do not fit.

Composition

Runnables can call and combine other runnables to build more complex workflows.

For example:

agic summarize:
  Summarize {{_}} in three bullets.
 
flow brief:
  run summarize
  run -> Text:
    Rewrite {{_}} for a general audience.

The brief flow calls summarize, then passes its result to an inline agic.

Toolang supports several ways to compose execution:

OperationBehavior
runCall a child runnable and continue with its result.
async / awaitStart child work asynchronously and await its result when needed.
execTransfer control to another runnable within the current run.
spawnStart independent work with its own root run.

Agics can delegate work through hands and transfer control through handoffs, while flows express these operations directly.

Each execution is recorded as a run. Child calls form a run tree, while spawned work has an independent lifecycle.

See Run agent scripts for invoking runnables and Grammar for syntax details.