Configure run duration, approval timeouts, and interactive vs autonomous agent behavior
The problem: An agent run that calls slow tools, waits for human approval, or hits an LLM provider delay can hang indefinitely. For interactive apps, that means a frozen UI. For background pipelines, it means a stuck job that never retries or terminates.The solution: Bound every run with a deadline, choose an agent mode that matches your use case (interactive vs autonomous), and set explicit approval timeouts. When a limit fires the SDK fails the run cleanly with a typed error — no silent hangs.
When DisableLocalWorker is set, checks for available workers before submitting — returns a clear error if none are ready
Chat, REPL, web apps where a human is waiting
AgentModeAutonomous
60 minutes
Skipped — Temporal queues the workflow until a worker is available
Background jobs, pipelines, long-running tasks
// Interactive (default) — 5 min timeout, worker pre-checka, _ := agent.NewAgent( agent.WithLLMClient(llmClient), agent.WithAgentMode(agent.AgentModeInteractive),)// Autonomous — 60 min timeout, no worker pre-checka, _ := agent.NewAgent( agent.WithLLMClient(llmClient), agent.WithAgentMode(agent.AgentModeAutonomous),)
Agent mode is included in the Temporal agent fingerprint — caller and worker must agree.Worker-check and queueing behavior apply primarily to the Temporal runtime. In-process agents use the same default timeouts but do not perform worker pre-checks.
If you use a long context deadline but omit WithTimeout, approval still expires at ~4.5 minutes (interactive default 5 min − 30s). Set WithTimeout or WithApprovalTimeout explicitly for longer approval windows.
WithMaxIterations caps LLM rounds (default 5). When reached, the run finishes with finish reason max_iterations on telemetry. Separate from wall-clock timeout — a run can hit max iterations before the timeout fires.
On the Temporal runtime, process crashes and worker restarts do not appear as failures — the workflow resumes from the last recorded step. Only deadline expiry, max iterations, and provider errors surface as run failures. See Temporal runtime.