agent_with_error_control

command
v0.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

README

agent_with_error_control

Demonstrates error control (WithErrorControl) — not lifecycle WithHooks:

Scenario What this example does
OnLLMFailure Stub primary returns *LLMError rate_limit; hook swaps to named client "cheap"
OnMaxIterationsExceeded MaxIterations is 1; hook grants one extra round so the run can finish
Circuit breaker Stub tool always fails with the same args; the third call is skipped

Uses stub LLM clients and a stub tool. No extra infrastructure. No provider key required.

Error-control activity is printed to stderr with an [error-control] prefix.

Run

From examples/:

go run ./agent_with_error_control

Durable runtimes

Temporal: Register the same WithNamedLLMClients and WithErrorControl on the agent starter and the worker. Fingerprinted: hook slots (not bodies), fallback name, named-client model/provider, breaker thresholds.

Restate: Hooks run in the process that serves the embedded SDK endpoint (AGENT_RUNTIME=restate).

Documentation

Overview

Example demonstrating WithErrorControl: fallback after LLM failure, one extra iteration past max-iter, and a per-tool circuit breaker.

All scenarios use stub LLM clients and a stub tool — no provider key and no extra infra. AGENT_RUNTIME=temporal or restate still works via config.RuntimeOption.

Run from examples/:

go run ./agent_with_error_control

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL