Skip to main content
The problem: Your organization already runs multi-step procedures — onboarding, provisioning, compliance checks — in an orchestration engine. You want the LLM to trigger those procedures without re-implementing steps inside the agent loop, and without the LLM improvising or skipping steps. The solution: Expose workflows as a custom tool (run_workflow). The LLM routes user intent to workflow_name and input; your WorkflowRunner executes the steps deterministically and returns the result. Steps run in order, retry on failure, and produce an auditable record — entirely inside your engine.

What deterministic means here

The LLM’s job is intent routing — mapping “onboard Alice” to workflow_name: onboarding, input: Alice. Your orchestration engine owns the procedure: This is different from asking the LLM to “figure out what steps to run” — the engine always runs the same steps for the same workflow name. Example: Workflows.

Tool pattern

Execute delegates to WorkflowRunner.Run and returns when the workflow reaches a terminal state (or the context deadline fires).

How the agent waits

One agent Run stays open until WorkflowRunner.Run returns — minutes or hours depending on workflow duration and any wait steps inside your engine. Pass the SDK’s ctx from Execute into your wait loop so deadlines propagate.

Wait steps inside orchestration

Workflows can pause on external events or human gates defined in your engine — the agent run stays open the whole time: Size WithToolExecutionConfig and WithTimeout to cover the full workflow duration including any wait steps.

Timeout layers

Default tool execution timeout is 30 minutes with up to 3 attempts if unset — raise it for workflow agents.
If the deadline fires, Execute returns context deadline exceeded — the workflow may still be running in your engine. Use idempotent workflow IDs and a status API in your runner for recovery.

Orchestration runners

Implement WorkflowRunner once per engine — map workflow_name + input to your API, wait until terminal, return WorkflowResult: The example ships two runners: inprocess_runner.go (default, no infra) and temporal_runner.go (ORCHESTRATION_ENGINE=temporal). Add conductor_runner.go, argo_runner.go, etc. for other engines — only main.go changes when you swap runners. Workflow orchestration is independent of AGENT_RUNTIME — the agent can run in-process while your runner uses any backend. Example: Workflows.

Examples

Workflows

run_workflow tool with in-process and Temporal runners

Execution config

Per-operation timeout overrides

Execution config

Tool execute timeout and max attempts

Timeouts & modes

Agent run timeout and interactive vs autonomous

Tools

Custom tool implementation