Skip to main content
Version: 1.0.0

Strategy

A strategy is the orchestration entry point executed by the runtime. It is the entry of a Touba program: it declares in uses the agent (or strategy, skill, tool, function) it may invoke, then orchestrates execution in a do block.

Shape​

source.tb
strategy StrategyName
uses AgentName
do
AgentName

Simple Case​

strategy_simple.tb
module examples.strategy_simple

type DatasetRequest
query is Text

type DatasetBrief
summary is Text

tool SearchDatasets
takes request as DatasetRequest
gives DatasetBrief
requires network

skill BuildDatasetBrief
takes request as DatasetRequest
gives DatasetBrief
uses SearchDatasets
do
SearchDatasets
with request as request
into result
give result

agent Researcher
responsibility "Fulfill the declared Researcher responsibility using only authorized capabilities."
uses BuildDatasetBrief
callable_by strategy RunDatasetResearch

strategy RunDatasetResearch
uses Researcher
do
Researcher

RunDatasetResearch is the only authorized caller for Researcher, explicitly declared by callable_by.

Advanced Case​

strategy_advanced.tb
module examples.strategy_advanced

type ChangeRequest
summary is Text

type ReviewedChange
summary is Text

tool ApplyChange
takes request as ChangeRequest
gives ReviewedChange

skill MakeChange
takes request as ChangeRequest
gives ReviewedChange
uses ApplyChange
do
ApplyChange
with request as request
into result
give result

skill ReviewChange
takes request as ChangeRequest
gives ChangeRequest
do
give request

agent Reviewer
responsibility "Fulfill the declared Reviewer responsibility using only authorized capabilities."
uses ReviewChange
callable_by strategy RunChangeReview

agent Engineer
responsibility "Fulfill the declared Engineer responsibility using only authorized capabilities."
uses MakeChange
callable_by strategy RunChangeReview

strategy RunChangeReview
takes request as ChangeRequest
uses Reviewer
uses Engineer
do
Reviewer
Engineer

A strategy can declare takes (the run input) and orchestrate several distinct agents. Each agent remains bounded by its own uses and is invocable here only because it declares callable_by strategy RunChangeReview.

Strategy vs Agent​

  • An agent carries responsibility for a choice among the capabilities it declares itself in uses.
  • A strategy carries orchestration of the global sequence: which agents are requested, in which order, and with which input.

An agent may authorize a strategy or another agent through callable_by, including qualified names. A strategy has no callable_by: it may be a CLI/trigger entry or a typed capability invoked through with / into. Its arguments and results stay separate from its caller's local values.

Composition and parallelism​

Ordinary calls run in sequence. For independent inputs, a strategy or skill can declare a parallel group over a typed local or imported target. This example requires neither a handler nor a model:

batch_labels.tb
module examples.batch_labels

strategy LabelTicket
takes ticket as Text
gives Text
do
give "Ticket: " ++ ticket

strategy LabelBatch
takes tickets as List of Text
gives List of Text
uses LabelTicket
do
parallel LabelTicket
each ticket in tickets
with ticket as ticket
max_concurrency 4
max_items 32
into labels
give labels

LabelBatch returns labels in the order of tickets, regardless of completion order. An empty input returns an empty list; more than 32 items refuses the group before its first call. The join waits for every result: failure never becomes a successful partial list.

The same form accepts an agent, skill, function or tool with a declared output type. Run budgets remain shared while invocation data stays isolated. For providers, human pauses and recovery, follow the multi-agent tutorial.

Runtime Contract​

  • Execution is sequential outside an explicit parallel group.
  • max_concurrency and max_items bound the group; host ceilings and run budgets still apply.
  • A strategy does not bypass uses / callable_by on the agents it invokes: the runtime verifies these contracts at every call.
  • See Bounded Autonomy for the runtime control model on each agent invocation.

Dedicated walkthroughs​