Skip to main content
Uses WithTemporalClient instead of WithTemporalConfig. You create and own the Temporal SDK client — required for TLS, API key auth, Temporal Cloud, and custom connection options. Source: examples/agent_with_temporal_client/

What it demonstrates

  • client.Dial with your own client.Options
  • WithTemporalClient(tc, taskQueue) on NewAgent
  • Caller-owned client lifecycle (defer tc.Close())

Run

From examples/ with Temporal running:
task infra:temporal:up && task infra:temporal:wait
AGENT_RUNTIME=temporal go run ./agent_with_temporal_client "Hello, what can you do?"
Set TEMPORAL_HOST, TEMPORAL_PORT, TEMPORAL_NAMESPACE, and TEMPORAL_TASKQUEUE in .env.

Key code

tc, err := client.Dial(client.Options{
    HostPort:  "localhost:7233",
    Namespace: "default",
    // ConnectionOptions, Credentials for Cloud / mTLS
})
defer tc.Close()

a, err := agent.NewAgent(
    agent.WithTemporalClient(tc, "my-task-queue"),
    agent.WithLLMClient(llmClient),
)
For simple local dev without custom dial options, WithTemporalConfig is sufficient — see Temporal runtime.

Expected output

I'm a helpful assistant powered by an LLM. I can answer questions, help with tasks,
and have multi-turn conversations. What would you like to explore?
The Temporal workflow ID and task queue are logged to stderr at LOG_LEVEL=debug. The response itself is identical to the simple-agent — the difference is the execution path (Temporal workflow vs in-process goroutine).

Learn more

Temporal Runtime

WithTemporalConfig vs WithTemporalClient

Agent Worker

Split client and worker