anda_core 0.12.0

Core types and traits for Anda -- an AI agent framework built with Rust, powered by ICP and TEEs.
Documentation

anda_core

License Crates.io Test Docs.rs Latest Version

anda_core defines the shared traits, data models, and protocol helpers used by the Anda agent framework. It is the stable contract between runtimes, agents, tools, model adapters, and clients.

This crate is intentionally small in scope: it does not run an engine, call model providers directly, or ship built-in tools. Runtime orchestration and provider integrations live in higher-level crates such as anda_engine.

Full API documentation is available on docs.rs.

Install

[dependencies]
anda_core = "0.11"

What It Provides

  • Strongly typed Agent and Tool traits.
  • Dynamic registries through AgentSet and ToolSet.
  • Execution context capability traits for state, keys, storage, cache, HTTP, and canister calls.
  • Provider-neutral model types such as Message, ContentPart, CompletionRequest, and AgentOutput.
  • JSON schema helpers for LLM function calling.
  • CBOR/Candid HTTP RPC helpers for remote engines and ICP canisters.

Module Map

Module Purpose
agent Defines agents, dynamic dispatch, dependency declarations, and agent registries.
tool Defines typed tools, raw JSON dispatch, supported resource tags, and tool registries.
context Defines runtime capabilities exposed to agents and tools.
model Defines request/response, message, content, function-call, document, and usage types.
http Provides CBOR/Candid RPC request and response helpers.
json Generates compact JSON Schema values for tool and agent parameters.

Core Concepts

Agents

An agent implements Agent<C> for a runtime context C. It declares a name, description, function definition, optional tool dependencies, optional supported resource tags, and an async run method.

Agent names are registered case-insensitively and must follow the same function-name rules used for LLM function calling: lowercase ASCII letters, digits, and underscores, starting with a lowercase letter.

Tools

A tool implements Tool<C> with typed Args and Output associated types. The runtime accepts raw JSON tool calls, deserializes them into Args, executes the tool, then serializes the output back to JSON.

Tools can declare supported resource tags. During a call, the runtime removes matching resources from the request resource list and passes them to the tool.

Contexts

BaseContext is the capability surface available to tools and agents. It combines:

  • StateFeatures for engine identity, caller identity, metadata, cancellation, and elapsed time.
  • KeysFeatures for AES, Ed25519, and Secp256k1 key derivation, signing, verification, and public keys.
  • StoreFeatures for isolated object storage.
  • CacheFeatures for isolated in-memory cache values with optional TTL/TTI expiration.
  • HttpFeatures for runtime-managed HTTPS calls.
  • CanisterCaller for ICP canister calls.

AgentContext extends BaseContext with LLM completion and orchestration methods for local or remote agents and tools.

Messages and Content

Message and ContentPart provide a normalized representation for text, reasoning, files, inline binary data, tool calls, tool outputs, signed actions, and provider-specific JSON payloads. Model adapters can preserve unknown provider content in ContentPart::Any while still exposing common behavior to the rest of the framework.

Minimal Tool Example

use anda_core::{
    BaseContext, BoxError, FunctionDefinition, Resource, Tool, ToolOutput, gen_schema_for,
};
use schemars::JsonSchema;
use serde::Deserialize;

#[derive(Debug, Deserialize, JsonSchema)]
struct EchoArgs {
    text: String,
}

#[derive(Default)]
struct EchoTool;

impl<C> Tool<C> for EchoTool
where
    C: BaseContext + Send + Sync,
{
    type Args = EchoArgs;
    type Output = String;

    fn name(&self) -> String {
        "echo".to_string()
    }

    fn description(&self) -> String {
        "Returns the provided text.".to_string()
    }

    fn definition(&self) -> FunctionDefinition {
        FunctionDefinition {
            name: self.name(),
            description: self.description(),
            parameters: gen_schema_for::<EchoArgs>(),
            strict: Some(true),
        }
    }

    async fn call(
        &self,
        _ctx: C,
        args: Self::Args,
        _resources: Vec<Resource>,
    ) -> Result<ToolOutput<Self::Output>, BoxError> {
        Ok(ToolOutput::new(args.text))
    }
}

Validation

Useful checks while working on this crate:

cargo test -p anda_core
cargo clippy -p anda_core --all-targets -- -D warnings
RUSTDOCFLAGS="-D warnings" cargo doc -p anda_core --no-deps

License

Copyright © 2026 LDC Labs.

ldclabs/anda is licensed under the MIT License. See the MIT license for the full license text.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in anda by you shall be licensed as MIT, without any additional terms or conditions.