Embedded CLI
Build your own agent binary on adk_rs::cli::App and get run, web, eval, and version subcommands out of the box.
Rust binaries are statically linked — agents cannot be discovered and loaded at runtime — so adk-rs does not ship a single prebuilt adk binary. Instead, the cli feature provides library scaffolding: you write a tiny main.rs that registers agents on adk_rs::cli::App and forwards to App::run, producing a statically linked binary with a full clap-based CLI.
The App type
fn new(name: impl Into<String>) -> App- Construct an empty app.
namebecomes theapp_nameof every Runner the CLI builds. fn register(self, name: impl Into<String>, agent: Arc<dyn BaseAgent>) -> Self- Register an agent under a name.
run --agent <name>and thewebserver address agents by this name. fn run(self) -> Result<()>- Parse
std::env::args, initialise telemetry from the global flags, build a multi-threaded Tokio runtime, and dispatch the subcommand. async fn run_async(self, cmd: Command) -> Result<()>- Async dispatch with an explicit
Commandvalue — useful for tests that drive the CLI without a process boundary.
For each invocation the CLI builds a Runner with an InMemorySessionService and auto_create_session(true). Sessions therefore do not persist across process runs; embed the server directly with a persistent session service when you need durability.
Example main.rs
use std::sync::Arc;
fn main() -> adk_rs::Result<()> {
adk_rs::cli::App::new("my-app")
.register("greeter", Arc::new(build_greeter()?))
.run()
}Global flags
| Flag | Default | Purpose |
|---|---|---|
--log <FILTER> | info (env: ADK_LOG) | RUST_LOG-style tracing filter, e.g. adk_rs=debug,info. |
--log-format <FORMAT> | compact | Log output format: compact, pretty, or json. |
Subcommands
run — one user turn
| Flag / arg | Default | Purpose |
|---|---|---|
--agent <NAME> | required | Which registered agent to run. |
--user <ID> | anonymous | User id for the session. |
--session <ID> | none | Optional session id (auto-created if missing). |
<MESSAGE> | required | Positional: the user message. |
run streams the agent’s events and prints the concatenated text of every content-bearing event to stdout.
web — the dev HTTP server
| Flag | Default | Purpose |
|---|---|---|
--bind <ADDR> | 127.0.0.1:8000 | Listen address. |
--auth-token <TOKEN> | none (env: ADK_WEB_TOKEN) | Require Authorization: Bearer <token> on every request. Recommended whenever --bind is not loopback. |
--dangerously-allow-unauthenticated-remote | off | Bind a non-loopback address without a token. Refused by default — see Security model. |
--allow-origins <ORIGIN> | none (repeatable) | CORS allow-list, e.g. http://localhost:4200 for the adk-web UI. |
web registers a Runner per agent and delegates to adk_rs::server::serve_with — the full adk api_server-compatible endpoint surface including /run, /run_sse, and session CRUD.
eval — replay an eval set
| Flag | Default | Purpose |
|---|---|---|
--set <PATH> | required | Path to the JSON eval set (see Evaluation for the format). |
--agent <NAME> | required | Which registered agent to evaluate. |
eval loads the set, runs it through an EvalRunner with TrajectoryMatch::new(1.0) and ResponseMatch::new(0.5) as the metric pair and eval-user as the user id, then prints the EvalReport as pretty JSON. See Evaluation for the format and metrics.
version
Prints adk-rs <crate version>. The clap derive also provides the standard --version and --help flags at every level.
Shell session
my-app run --agent greeter "Hello!" # single-turn invocation
my-app web --bind 127.0.0.1:8000 # dev server, loopback default
my-app web --bind 0.0.0.0:8000 \
--auth-token "$ADK_WEB_TOKEN" # non-loopback bind requires auth
my-app web --allow-origins http://localhost:4200 # for the adk-web UI
my-app eval --agent greeter --set hello.evalset.json
my-app version- HTTP server — what
webactually serves. - Evaluation — eval-set format and metrics.
- Telemetry — what
--logand--log-formatconfigure.