Skip to content
LogoLogo

Run agent scripts

Toolang lets you define reusable tasks in .too files and run them directly from the command line.

Write a script

Save the following as helpers.too:

#!/usr/bin/env too
 
agic rewrite(_, tone):
  Rewrite {{_}} in a {{tone}} tone.
 
flow summarize:
  Summarize {{_}} in three bullets.
 
  Make these bullets clear and concise, preserving their meaning: {{_}}

An agic uses a model to complete a task, while a flow defines how tasks are executed in sequence. _ represents the primary input, and tone is a named argument.

See Runnables for more about agics, flows, and their inputs and outputs.

Run a script

Inspect available runnables and their arguments:

too helpers.too --help
too helpers.too rewrite --help

Invoke a runnable by name:

too helpers.too rewrite tone=casual -- Make this clearer.

Arguments come before --, which separates them from the primary input.

You can also include file contents or pipe input from another command:

too helpers.too summarize -- @README.md
cat README.md | too helpers.too summarize

File references such as @README.md are resolved relative to the directory where the command is launched.

Save output

Use -o to save the result and -q to hide progress:

too helpers.too summarize -q -o summary.txt -- @README.md

To write the result to stdout:

too helpers.too summarize -q -o - -- @README.md

Text output is saved as plain text; other Part outputs are serialized as JSON.

Configure execution

Override the model and execution limits for a command:

too helpers.too summarize \
  --model openai/gpt-6.1-sol \
  --limit tokens=10000 \
  -- @README.md

To grant access to another directory and select it as the working directory:

mkdir -p scratch
too helpers.too summarize \
  -w scratch=./scratch \
  -d scratch:// \
  -- @README.md

By default, scripts grant access to their source directory. Explicit -w grants replace this default. File attachments remain relative to the launch directory and do not grant filesystem access.