Skip to main content

tool

Attribute Macro tool 

Source
#[tool]
Expand description

Attribute macro that generates a Tool implementation from an async function.

§Requirements

  • The function must be async
  • It must take exactly one argument (the args struct) that implements serde::de::DeserializeOwned and schemars::JsonSchema
  • It must return Result<serde_json::Value, adk_tool::AdkError>
  • Doc comments become the tool description

§Example

/// Search the knowledge base for documents matching a query.
#[tool]
async fn search_docs(args: SearchArgs) -> Result<serde_json::Value, adk_tool::AdkError> {
    // ...
}

// Generated: pub struct SearchDocs; implements Tool
// Use: agent_builder.tool(Arc::new(SearchDocs))