parallel
Runs several of the agent's functions at the same time and returns their results as a dict, with one entry per call.
Shape
parallel is shaped like var, not like a command block. Each key names a function to call, and each value is an object holding the arguments for that call, empty when the function takes none. To call the same function twice, add a suffix after a dot, as with repeated commands: lookup and lookup.2. The result is a dict with the same keys. At least one function must be named, and main cannot be one of them.
Example
"parallel": {
"fetchWeather": { "city": "{ city }" },
"fetchEvents": { "city": "{ city }" }
},
"var": {
"weather": "{ result['fetchWeather'] }",
"events": "{ result['fetchEvents'] }"
}Rules
- The result is keyed by the names used in the command, so the order in which the calls finish does not matter.
- Each function runs in its own scope with its own locals. Agent and conversation variables are shared, so two parallel functions should not write the same variable.
- Branches that run
llmcommands at the same time must use different prompts. - A function that runs in parallel may
ask, and may call a function that asks; see below. - If any call fails, the whole command fails with that error.
onErroron the calling function can handle it.
Asking from a branch
A branch may pause on ask, at any depth: in the function itself or in a function it calls. parallel waits until every branch has either finished or paused. Then the questions of every paused branch are sent to the user together, one form per branch, each keyed by the branch's name in the command, such as lookup and lookup.2. When the user answers, the command runs again: the branches that had finished keep their results and do not run again, and each paused branch resumes at its own ask with its own answers. A branch whose answers have not arrived asks again, so the user may answer one form at a time. A branch that runs a parallel command of its own nests its branches' forms under its key.
Running agents describes how the questions reach a client of your own.

