- Project/component:
rustiaLLM tool adapter contract - Canonical path:
crates/rustia-llm
- Runtime: Rust library crate
- Primary language: Rust
- Rust developers integrating
rustiatyped validation withaisdkfunction calling/tool execution. - Maintainers preserving compatibility between
rustia,rustia-macros, andrustia-llmpublic contracts.
- Stable component identifier:
llm. - Stable public identifiers:
LlmToolInputLlmToolOutputLlmToolSpectoolLlmToolBuildErrorLlmToolInputErrorLlmToolExecutionError
LlmToolInputtrait bound contract:LlmToolInput: rustia::LLMData + schemars::JsonSchema + Send + Sync + 'static
LlmToolOutputtrait bound contract:LlmToolOutput: serde::Serialize + Send + Sync + 'static
toolfunction contract:tool<I, O, F, E>(spec, handler) -> Result<aisdk::core::tools::Tool, LlmToolBuildError>F: Fn(I) -> Result<O, E> + Send + Sync + 'static,E: Display
- Input execution contract:
- aisdk-provided
serde_json::Valueinput is converted to string and parsed throughI::parse - rustia parse/parse-coercion/validation feedback harness is always applied before handler execution
- validation failure returns deterministic error feedback text including rustia paths (
$input...) and expected constraints
- aisdk-provided
- Output execution contract:
- handler success payload is serialized as JSON string via
serde_json::to_string - handler and serialization failures are returned as tool errors
- handler success payload is serialized as JSON string via
- No persistent storage contract.
- All parsing/validation/execution state remains request-scoped in memory.
- Tool input validation must remain fail-closed before typed handler execution.
- Input coercion must remain delegated to rustia runtime semantics; no bypass path may skip
LLMData::parse. - Error payloads must avoid leaking hidden internal state beyond tool input/value-level diagnostics.
- Tool parse success/failure and execution outcomes must emit structured logs using
tracing. - Baseline log fields must include
tool_name, parse success/failure, and error count.
- Local validation:
cargo test -p rustia-llm - Workspace baseline:
cargo test --workspace --all-targets
- Runtime dependencies:
rustia,aisdk,schemars,serde,serde_json,tracing. - Upstream contract dependency:
docs/crates-rustia-core-foundation.md. - Project-level contract dependency:
docs/project-rustia.md.
- Update
docs/project-rustia.mdand this file when adapter API signatures, handler contracts, or error payload contracts change. - Keep rustia cross-component compatibility updates synchronized with
docs/crates-rustia-core-foundation.mdanddocs/crates-rustia-macros-foundation.md. - Update root
Cargo.tomlworkspace membership and publish-tag package list in the same change when release eligibility changes.
docs/project-rustia.mddocs/crates-rustia-core-foundation.mddocs/crates-rustia-macros-foundation.mddocs/domain-template.md