Skip to main content
Minimal agent + worker split: worker polls the task queue; agent process starts runs with DisableLocalWorker. Source: examples/agent_with_worker/

What it demonstrates

  • NewAgentWorker with the same options as NewAgent
  • DisableLocalWorker on the client process
  • Stream from the remote agent process
  • Foundation pattern for production worker separation

Run

From examples/ with Temporal running:
task infra:temporal:up && task infra:temporal:wait

# Terminal 1
AGENT_RUNTIME=temporal go run ./agent_with_worker/worker

# Terminal 2
AGENT_RUNTIME=temporal go run ./agent_with_worker/agent "Hello from remote agent!"
For interactive durability scenarios (kill/restart), see Durable Agent.

Key code

worker/main.go — polls Temporal, executes workflows and activities:
w, err := agent.NewAgentWorker(
    agent.WithName("agent-worker"),
    agent.WithLLMClient(llmClient),
    agent.WithTemporalConfig(temporalCfg),
)
w.Start()
agent/main.go — starts runs, consumes stream without a local worker:
a, err := agent.NewAgent(
    agent.WithName("agent-worker"),
    agent.WithLLMClient(llmClient),
    agent.WithTemporalConfig(temporalCfg),
    agent.DisableLocalWorker(),
    agent.EnableRemoteWorkers(),
)
eventCh, _ := a.Stream(ctx, prompt, nil)
Both processes use identical agent options so the SDK fingerprint matches.

Expected output

Terminal 1 (worker) shows Temporal polling logs at LOG_LEVEL=info. Terminal 2 (agent) prints the streamed reply:
Hello from remote agent! I'm running as a Temporal workflow on a separate worker process.
See Worker Separation and Temporal Runtime for production context.

Learn more

Worker Separation

Production split-process guide

Durable Agent

Advanced durability scenarios

Agent Chat

Full app using same pattern