The aomi_sdk::testing module lets you unit-test your tools without loading the full FFI plugin. You build a tool call context, invoke the tool with typed arguments, and assert on what it returns. Tests run as ordinary cargo test cases, so they fit straight into your CI.
Overview
Building a Test Context
TestCtxBuilder constructs the DynToolCallCtx the host normally passes into a tool. It uses generated defaults for the session and call IDs, and lets you override them or inject state attributes and resolved secrets:
The secret value simulates what the host injects from the per-app vault before each call, so you can test code paths that read secrets through resolve_secret_value.
run_tool deserializes your JSON args into the tool’s Args type, invokes the tool, and returns a ToolReturn. The ToolReturn carries the tool’s value plus any routes it emitted:
Tests that only care about the payload can read output.value. Tests that exercise multistep routing can assert on output.routes.
run_async_tool drives a tool that sets IS_ASYNC = true. It returns a tuple: every intermediate sink.emit(...) value in order, plus the terminal sink.complete(...) payload as a ToolReturn:
Intermediate updates are always bare values. When the tool completes with a routed ToolReturn, terminal.routes is populated; otherwise terminal.value holds the raw completion value and terminal.routes is empty.
Running the Tests
These are plain Rust tests in your app crate. Run them with cargo test:
Best Practices
Next Steps
Last modified on June 10, 2026