### Run Docker Compose Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/input-required/README.md Navigate to the example directory and run the Docker Compose command to start the server and client. ```bash cd examples/input-required docker compose up --build ``` -------------------------------- ### Running AI-Powered Example with Docker Compose Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/ai-powered/README.md Steps to set up and run the AI-powered example using Docker Compose. Ensure you set your API key in the .env file. ```bash cd examples/ai-powered cp .env.example .env # Set DEEPSEEK_API_KEY (or another provider's key + matching AGENT_CLIENT_PROVIDER) docker compose up --build ``` -------------------------------- ### Run Minimal Server and Client with Taskfile Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/README.md Execute the minimal server and client examples using Taskfile commands. ```bash task examples:minimal-server task examples:minimal-client ``` -------------------------------- ### Verify Development Setup Source: https://github.com/inference-gateway/rust-adk/blob/main/CONTRIBUTING.md Run these commands to verify your development environment setup. ```bash task test task lint task analyse ``` -------------------------------- ### Run A2A Client Examples with Docker Compose Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/a2a-methods/README.md Execute a single A2A client example by specifying its profile in Docker Compose. This command builds the necessary images and starts the selected client along with the shared server. ```bash cd examples/a2a-methods # Pick a single method to exercise: docker compose --profile message-send up --build docker compose --profile message-stream up --build docker compose --profile tasks-get up --build docker compose --profile tasks-list up --build docker compose --profile tasks-cancel up --build docker compose --profile tasks-resubscribe up --build docker compose --profile push-config-set up --build docker compose --profile push-config-get up --build docker compose --profile push-config-list up --build docker compose --profile push-config-delete up --build docker compose --profile agent-authenticated-extended-card up --build # Or run every client in sequence against the same server: docker compose --profile all-clients up --build ``` -------------------------------- ### Running Example Tasks Source: https://github.com/inference-gateway/rust-adk/blob/main/CONTRIBUTING.md Examples of how to run specific A2A server and client tasks for different scenarios, such as 'minimal' or 'ai-powered'. ```shell task examples:minimal-server - task examples:minimal-client ``` -------------------------------- ### Docker Compose Up Command Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/README.md General command to start services using Docker Compose. Ensure to navigate to the example directory and configure .env if necessary. ```bash cd examples/ # When applicable: cp .env.example .env # edit .env - set DEEPSEEK_API_KEY (or another provider's key) docker compose up --build ``` -------------------------------- ### Run Auth Server Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/auth/README.md Starts the authentication server. Optionally, set EXAMPLE_BEARER_TOKEN to use a custom token. ```bash cargo run -p auth-server # Or with a custom token: # EXAMPLE_BEARER_TOKEN=my-secret cargo run -p auth-server ``` -------------------------------- ### Run Docker Compose Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/ai-powered-streaming/README.md Navigate to the example directory, copy the environment file, set your API key, and then build and run the Docker Compose stack. ```bash cd examples/ai-powered-streaming cp .env.example .env # Set DEEPSEEK_API_KEY (or another provider's key + matching AGENT_CLIENT_PROVIDER) docker compose up --build ``` -------------------------------- ### Running with Docker Compose Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/static-agent-card/README.md Commands to set up and run the example using Docker Compose. Ensure to configure your API key in the `.env` file. ```bash cd examples/static-agent-card cp .env.example .env # Set DEEPSEEK_API_KEY (or another provider's key + matching AGENT_CLIENT_PROVIDER) docker compose up --build ``` -------------------------------- ### Run A2A Client Examples Locally with Cargo Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/a2a-methods/README.md Start the shared offline server in one terminal and then run individual A2A client examples in another terminal using Cargo. Clients default to connecting to `http://localhost:8085`. ```bash In one terminal, start the server: ```bash cargo run -p a2a-methods-server ``` In another terminal, run any of the per-method clients: ```bash cargo run -p a2a-methods-message-send cargo run -p a2a-methods-message-stream cargo run -p a2a-methods-tasks-get cargo run -p a2a-methods-tasks-list cargo run -p a2a-methods-tasks-cancel cargo run -p a2a-methods-tasks-resubscribe cargo run -p a2a-methods-push-config-set cargo run -p a2a-methods-push-config-get cargo run -p a2a-methods-push-config-list cargo run -p a2a-methods-push-config-delete cargo run -p a2a-methods-agent-authenticated-extended-card ``` ``` -------------------------------- ### Run Auth Client Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/auth/README.md Starts the authentication client. Ensure the token used matches the server's configuration. ```bash cargo run -p auth-client # Token used by the client must match the server: # EXAMPLE_BEARER_TOKEN=my-secret cargo run -p auth-client ``` -------------------------------- ### Build Project Dependencies Source: https://github.com/inference-gateway/rust-adk/blob/main/CONTRIBUTING.md Build the project to install necessary dependencies. ```bash cargo build ``` -------------------------------- ### Build and Run Docker Compose Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/default-handlers/README.md Steps to set up and run the default handlers example using Docker Compose. Ensure to set your API key in the `.env` file. ```bash cd examples/default-handlers cp .env.example .env # Set DEEPSEEK_API_KEY (or another provider's key + matching AGENT_CLIENT_PROVIDER) docker compose up --build ``` -------------------------------- ### Directory Structure Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/static-agent-card/README.md Illustrates the file organization for the static agent card example, including the agent JSON file, server, and client. ```text static-agent-card/ ├── docker-compose.yaml # Server + client + inference-gateway:latest ├── .env.example # DEEPSEEK_API_KEY + provider/model overrides ├── server/ │ ├── .well-known/agent.json # Agent metadata loaded at startup │ └── main.rs # Server using with_agent_card_from_file + AgentCardOverrides ├── client/main.rs # Client demonstrating health, agent card, and a task └── README.md ``` -------------------------------- ### Run Minimal Server and Client with Cargo Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/README.md Use Cargo to build and run the minimal server and client binaries for the A2A example. ```bash cargo run -p minimal-server cargo run -p minimal-client ``` -------------------------------- ### Run Minimal Server Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/minimal/README.md Start the minimal A2A server locally. The server listens on 0.0.0.0:8080. ```bash cargo run -p minimal-server # or: task examples:minimal-server ``` -------------------------------- ### AgentBuilder Usage Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Examples of building OpenAI-compatible agents using the AgentBuilder. ```APIDOC ## AgentBuilder Build OpenAI-compatible agents that live inside the A2A server using a fluent interface: ### Example 1: Agent driven by `AgentConfig` ```rust use inference_gateway_adk::AgentBuilder; // Agent driven by `AgentConfig` (provider, model, key, …) let agent = AgentBuilder::new() .with_config(&config.agent_config) .with_toolbox(tools) .build() .await?; ``` ### Example 2: Agent with explicit per-field setters ```rust use inference_gateway_adk::AgentBuilder; let agent = AgentBuilder::new() .with_provider("deepseek") .with_model("deepseek-v4-flash") .with_system_prompt("You are a helpful assistant") .with_max_chat_completion_iterations(10) .build() .await?; ``` ### Example 3: Wiring the agent into the server ```rust let server = A2AServerBuilder::new() .with_agent(agent) .with_agent_card_from_file(".well-known/agent.json", None) .with_default_task_handlers() .build() .await?; ``` > `AgentBuilder::build()` fails fast when `provider` or `model` are unset, so a > misconfigured server errors out at startup instead of on the first chat > request. ``` -------------------------------- ### Running AI-Powered Example Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/ai-powered/README.md Instructions for running the AI-powered server and client locally. The server listens on port 8080, and the client uses the SERVER_URL environment variable. ```bash # Start an Inference Gateway separately, then run the server from inside its # subdir so .well-known/agent.json resolves correctly: cd examples/ai-powered/server cargo run -p ai-powered-server # or: task examples:ai-powered-server cargo run -p ai-powered-client # or: task examples:ai-powered-client ``` -------------------------------- ### Generate Example PKI Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/tls/README.md Generates a self-signed Public Key Infrastructure (PKI) including a root CA, server certificate, and client certificate using OpenSSL. This PKI is used for the TLS/mTLS example. ```bash ./examples/tls/make-certs.sh ``` -------------------------------- ### Run Docker Compose for OIDC Auth Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/auth/README.md Starts the Keycloak, auth-server, and auth-client services using Docker Compose for OIDC-based authentication. ```bash cd examples/auth docker compose up --build ``` -------------------------------- ### Build Agent with Custom LLM Client and System Prompt Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Integrates a pre-built LLM client with the `AgentBuilder` and sets a custom system prompt. This example shows how to combine a specific LLM client with agent-level configurations. ```rust use inference_gateway_adk::{AgentBuilder, OpenAICompatibleLLMClient}; // Build the default OpenAI-compatible client (synchronous; no `await`) let llm_client = OpenAICompatibleLLMClient::new(&config.agent_config)?; // Build agent with the custom client let agent = AgentBuilder::new() .with_llm_client(llm_client) .with_system_prompt("You are a coding assistant.") .build() .await?; ``` -------------------------------- ### Create Simple Agent with Defaults Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Builds a basic agent instance using default settings provided by `AgentBuilder`. This is the simplest way to get an agent up and running. ```rust use inference_gateway_adk::server::AgentBuilder; use tracing; // Create a simple agent with defaults let agent = AgentBuilder::new() .build() .await?; ``` -------------------------------- ### Run Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/ai-powered-streaming/README.md Start an Inference Gateway separately, then run the server and client from their respective subdirectories. The server listens on 0.0.0.0:8080, and the client respects the SERVER_URL environment variable. ```bash # Start an Inference Gateway separately, then run the server from inside its # subdir so .well-known/agent.json resolves correctly: cd examples/ai-powered-streaming/server cargo run -p ai-powered-streaming-server # or: task examples:ai-powered-streaming-server cargo run -p ai-powered-streaming-client # or: task examples:ai-powered-streaming-client ``` -------------------------------- ### Run Docker Compose for Streaming Example Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/streaming/README.md Execute this command to build and run the streaming server and client using Docker Compose. No environment variables are required as no provider keys are used. ```bash cd examples/streaming docker compose up --build ``` -------------------------------- ### Run In-memory Queue Storage Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/queue-storage/README.md Starts the server with the default in-memory storage backend and a single worker. This is useful for basic testing and development. ```sh docker compose up --build ``` -------------------------------- ### A2AServerBuilder Usage Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Demonstrates how to build an A2A server using the A2AServerBuilder. Examples include a minimal server, a server with an LLM agent and agent card, and a server with custom task handlers. ```APIDOC ## A2AServerBuilder ### Description The `A2AServerBuilder` is used to construct and configure an A2A server. ### Method `A2AServerBuilder::new()` ### Endpoint N/A (Rust SDK) ### Parameters - `with_agent(agent)`: Configures the server with a specific agent. - `with_agent_card_from_file(path, overrides)`: Loads agent metadata from a JSON file. - `with_default_task_handlers()`: Enables default task handlers. - `with_config(config)`: Applies a custom configuration. - `with_background_task_handler(handler)`: Registers a custom background task handler. - `with_streaming_task_handler(handler)`: Registers a custom streaming task handler. ### Build - `build().await?`: Finalizes the server construction. ### Request Example ```rust use inference_gateway_adk::{A2AServerBuilder}; // Minimal server let server = A2AServerBuilder::new().build().await?; // Server with LLM agent and agent card let server = A2AServerBuilder::new() .with_agent(agent) .with_agent_card_from_file(".well-known/agent.json", None) .with_default_task_handlers() .build() .await?; // Server with custom handlers let server = A2AServerBuilder::new() .with_config(config) .with_background_task_handler(my_background_handler) .with_streaming_task_handler(my_streaming_handler) .build() .await?; ``` ### Response - `Result>`: The constructed A2A server or an error. ``` -------------------------------- ### Run Minimal Client Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/minimal/README.md Start the minimal A2A client locally. The client connects to the server using the SERVER_URL environment variable, defaulting to http://localhost:8080. ```bash cargo run -p minimal-client # or: task examples:minimal-client ``` -------------------------------- ### Run TLS and Mutual TLS with Docker Compose Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/README.md Starts the TLS-enabled server and client using Docker Compose, including an optional mutual TLS profile. Requires certificate generation script to be run first. ```bash ./examples/tls/make-certs.sh docker compose --profile {tls,mtls} up --build ``` -------------------------------- ### Run Redis Queue Storage Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/queue-storage/README.md Starts the server with Redis as the storage backend and 4 concurrent workers. This configuration is suitable for scenarios requiring persistent storage and higher throughput. ```sh docker compose --env-file .env.redis --profile redis up --build ``` -------------------------------- ### Run Specific A2A Method Client with Docker Compose Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/README.md Starts a specific JSON-RPC method client against the A2A server using Docker Compose profiles. No provider keys are required. ```bash docker compose --profile up --build ``` -------------------------------- ### Environment Configuration Variables Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Runtime configuration for the ADK is managed through environment variables prefixed with `A2A_`. This example shows common variables for server settings, agent metadata, LLM client configuration, capabilities, queue/storage, authentication, and TLS. ```bash # Server A2A_SERVER_HOST="0.0.0.0" A2A_SERVER_PORT="8080" A2A_DEBUG="false" # Build-time agent metadata (compile-time env vars, read by env! macros) AGENT_NAME="My Agent" AGENT_DESCRIPTION="My agent description" AGENT_VERSION="1.0.0" AGENT_CARD_FILE_PATH="./.well-known/agent.json" # LLM client (the ADK fails fast at AgentBuilder::build if provider/model are unset) A2A_AGENT_CLIENT_PROVIDER="deepseek" # groq, google, openai, anthropic, cohere, cloudflare, deepseek, ollama A2A_AGENT_CLIENT_MODEL="deepseek-v4-flash" A2A_AGENT_CLIENT_API_KEY="your-api-key" A2A_AGENT_CLIENT_BASE_URL="http://inference-gateway:8080/v1" A2A_AGENT_CLIENT_MAX_TOKENS="4096" A2A_AGENT_CLIENT_TEMPERATURE="0.7" A2A_AGENT_CLIENT_SYSTEM_PROMPT="You are a helpful assistant" # Capabilities (surfaced in the agent card) A2A_CAPABILITIES_STREAMING="true" A2A_CAPABILITIES_PUSH_NOTIFICATIONS="true" A2A_CAPABILITIES_STATE_TRANSITION_HISTORY="false" # Queue / storage A2A_QUEUE_PROVIDER="memory" # `memory` (default) or `redis` (requires the `redis` Cargo feature) A2A_QUEUE_URL="redis://localhost:6379" # required when provider=redis A2A_QUEUE_NAMESPACE="a2a" A2A_QUEUE_WORKERS="1" # Authentication (optional, OIDC bearer-token JWT) A2A_AUTH_ENABLE="false" # when true, POST /a2a requires a valid bearer token A2A_AUTH_ISSUER_URL="http://keycloak:8080/realms/inference-gateway-realm" # OIDC issuer; the server performs discovery + JWKS lookup A2A_AUTH_CLIENT_ID="inference-gateway-client" # validated as the JWT audience when set A2A_AUTH_CLIENT_SECRET="your-secret" # currently unused server-side (reserved for client-side OAuth2) # TLS (optional) A2A_SERVER_TLS_ENABLE="false" # when true, A2AServer::serve binds an HTTPS listener via axum-server + rustls A2A_SERVER_TLS_CERT_PATH="/path/to/cert.pem" # PEM-encoded server certificate chain A2A_SERVER_TLS_KEY_PATH="/path/to/key.pem" # PEM-encoded private key (PKCS#1, PKCS#8, or SEC1) A2A_SERVER_TLS_CLIENT_CA_PATH="" # optional: when set, the server requires mTLS and trusts client certs signed by the CAs in this PEM bundle ``` -------------------------------- ### Restart Durability Test (Redis) Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/queue-storage/README.md Demonstrates restart durability by stopping and starting the server while tasks are being processed. This verifies that queued tasks are not lost when using Redis as the storage backend. ```sh # Terminal 1 docker compose --env-file .env.redis --profile redis up --build # Terminal 2 - while the client is mid-poll docker compose --env-file .env.redis stop server sleep 5 docker compose --env-file .env.redis --profile redis start server ``` -------------------------------- ### Run Server (TLS Only) Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/tls/README.md Starts the Rust A2A server with TLS enabled. Requires server certificate and key paths to be set via environment variables. The server listens on port 8443. ```bash SERVER_TLS_ENABLE=true \ SERVER_TLS_CERT_PATH=examples/tls/certs/server.crt \ SERVER_TLS_KEY_PATH=examples/tls/certs/server.key \ PORT=8443 \ cargo run -p tls-server ``` -------------------------------- ### Run Server (Mutual TLS) Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/tls/README.md Starts the Rust A2A server with mutual TLS (mTLS) enabled. In addition to server certificate and key, it requires the client CA path to verify client certificates. Clients without a valid certificate will be rejected. ```bash SERVER_TLS_ENABLE=true \ SERVER_TLS_CERT_PATH=examples/tls/certs/server.crt \ SERVER_TLS_KEY_PATH=examples/tls/certs/server.key \ SERVER_TLS_CLIENT_CA_PATH=examples/tls/certs/ca.crt \ PORT=8443 \ cargo run -p tls-server ``` -------------------------------- ### tasks/pushNotificationConfig/get Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Gets the push notification configuration for a task using the `get_task_push_notification_config` helper. ```APIDOC ## tasks/pushNotificationConfig/get ### Description Gets the push notification configuration for a task using the `get_task_push_notification_config` helper. ### Method GET (inferred from JSON-RPC) ### Endpoint /a2a/tasks/pushNotificationConfig/get (inferred) ### Parameters #### Query Parameters - **GetTaskPushNotificationConfigRequest** - The request object to retrieve the configuration. ``` -------------------------------- ### Clone and Navigate Repository Source: https://github.com/inference-gateway/rust-adk/blob/main/CONTRIBUTING.md Clone the repository and navigate into the project directory. ```bash git clone https://github.com/YOUR_USERNAME/rust-adk.git cd rust-adk ``` -------------------------------- ### Running Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/static-agent-card/README.md Instructions for running the server and client locally. The server needs to be run from its subdirectory for correct agent card path resolution. ```bash # Start an Inference Gateway separately, then run the server from inside its # subdir so `.well-known/agent.json` resolves correctly: cd examples/static-agent-card/server cargo run -p static-agent-card-server # or: task examples:static-agent-card-server cargo run -p static-agent-card-client # or: task examples:static-agent-card-client ``` -------------------------------- ### Get Task Push Notification Configuration Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Retrieves the push notification configuration for a task. Requires the full configuration name. ```rust use inference_gateway_adk::a2a_types::GetTaskPushNotificationConfigRequest; let cfg = client .get_task_push_notification_config(GetTaskPushNotificationConfigRequest { name: name.clone(), tenant: "example".to_string(), }) .await?; ``` -------------------------------- ### Run Server and Client Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/default-handlers/README.md Instructions for running the server and client locally. The server listens on port 8080, and the client uses the SERVER_URL environment variable. ```bash # Start an Inference Gateway separately, then run the server from inside its # subdir so .well-known/agent.json resolves correctly: cd examples/default-handlers/server cargo run -p default-handlers-server # or: task examples:default-handlers-server cargo run -p default-handlers-client # or: task examples:default-handlers-client ``` -------------------------------- ### Get Task Push Notification Configuration Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Retrieves a specific webhook configuration for a given task. Requires the full name of the configuration and the tenant ID. ```APIDOC ## get_task_push_notification_config ### Description Retrieves a specific webhook configuration for a given task. ### Method `client.get_task_push_notification_config(...)` ### Parameters #### Request Body - **name** (string) - Required - The full name of the configuration (e.g., `tasks/{task_id}/pushNotificationConfigs/{config_id}`). - **tenant** (string) - Required - The tenant associated with the configuration. ### Response #### Success Response (200) - **config** (object) - The retrieved push notification configuration details. - **name** (string) - The full name of the configuration. - **push_notification_config** (object) - The push notification settings. - **authentication** (object) - Optional - Authentication details for the webhook. - **id** (string) - Optional - The unique identifier for the notification configuration. - **token** (string) - Optional - The authentication token for the webhook. - **url** (string) - The URL to send webhook notifications to. ### Request Example ```rust use inference_gateway_adk::a2a_types::GetTaskPushNotificationConfigRequest; let cfg = client .get_task_push_notification_config(GetTaskPushNotificationConfigRequest { name: name.clone(), tenant: "example".to_string(), }) .await?; ``` ``` -------------------------------- ### Rust Table-Driven Test Structure Source: https://github.com/inference-gateway/rust-adk/blob/main/CONTRIBUTING.md Example of a table-driven test structure in Rust using tokio for async tests. This pattern is preferred for testing multiple scenarios. ```rust #[cfg(test)] mod tests { use super::*; #[tokio::test] async fn test_feature_name() { // Arrange: Set up test data and mocks let test_cases = vec![ TestCase { name: "valid_input", input: "test_input", expected: Ok("expected_output"), }, TestCase { name: "invalid_input", input: "invalid", expected: Err("expected_error"), }, ]; for case in test_cases { // Act: Execute the function under test let result = function_under_test(case.input).await; // Assert: Verify the result assert_eq!(result, case.expected, "Test case: {}", case.name); } } } ``` -------------------------------- ### Get Authenticated Extended Agent Card Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Fetches the authenticated extended AgentCard for the calling tenant. This call is only honored if the agent card advertises `supportsExtendedAgentCard: true`. ```rust use inference_gateway_adk::a2a_types::GetExtendedAgentCardRequest; let card = client .get_authenticated_extended_card(GetExtendedAgentCardRequest { tenant: "example".to_string(), }) .await?; ``` -------------------------------- ### Configure Agent with Tools and Function Handler Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Set up an agent with a weather tool and a synchronous function handler. Ensure the necessary SDK types are imported. ```rust use inference_gateway_adk::{A2AServerBuilder, AgentBuilder}; use inference_gateway_sdk::{ ChatCompletionTool, ChatCompletionToolType, FunctionObject, FunctionParameters, }; use serde_json::{Value, json}; let tools = vec![ChatCompletionTool { type_: ChatCompletionToolType::Function, function: FunctionObject { name: "get_weather".to_string(), description: Some("Get current weather for a location".to_string()), parameters: Some(FunctionParameters( json!({{"type": "object", "properties": {{ "location": {{ "type": "string" }}, "unit": {{ "type": "string", "enum": ["celsius", "fahrenheit"] }} }}, "required": ["location"] }})) .as_object() .unwrap() .clone(), )), strict: false, }, }]; let agent = AgentBuilder::new() .with_config(&config.agent_config) .with_system_prompt("You are a helpful weather assistant.") .with_max_chat_completion_iterations(15) .with_toolbox(tools) .with_function_tool("get_weather".to_string(), |args: Value| { let location = args["location"].as_str().unwrap_or("Unknown"); Ok(json!({ {"location": location, "temperature": "22°C" }}).to_string()) }) .build() .await?; let server = A2AServerBuilder::new() .with_config(config) .with_agent(agent) .with_agent_card_from_file(".well-known/agent.json", None) .with_default_task_handlers() .build() .await?; ``` -------------------------------- ### Get Access Token from Keycloak Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/auth/README.md Obtains an access token from Keycloak using client credentials grant type. The output token can be used for authenticating requests. ```bash TOKEN=$(curl -s -X POST \ http://localhost:8080/realms/inference-gateway-realm/protocol/openid-connect/token \ -d 'grant_type=client_credentials' \ -d 'client_id=inference-gateway-client' \ -d 'client_secret=inference-gateway-client-secret' \ | jq -r .access_token) echo "$TOKEN" | cut -d. -f2 | base64 -d 2>/dev/null | jq . ``` -------------------------------- ### Build A2AServer with Custom Handlers Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Initializes an A2A server with custom configuration, a background task handler, and a streaming task handler. Requires `inference_gateway_adk`. ```rust use inference_gateway_adk::{A2AServerBuilder}; // Server with a custom message/send (background) and message/stream handler let server = A2AServerBuilder::new() .with_config(config) .with_background_task_handler(my_background_handler) .with_streaming_task_handler(my_streaming_handler) .build() .await?; ``` -------------------------------- ### Create Agent with Custom Settings Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Demonstrates using the `AgentBuilder` fluent interface to customize agent behavior, including system prompts and conversation limits. Useful for fine-tuning agent responses and memory. ```rust use inference_gateway_adk::server::AgentBuilder; use tracing; // Or use the builder pattern for more control let agent = AgentBuilder::new() .with_system_prompt("You are a helpful AI assistant specialized in customer support.") .with_max_chat_completion(15) .with_max_conversation_history(30) .build() .await?; ``` -------------------------------- ### Get Task via A2AClient Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Retrieve task details using the `get_task` helper. Construct a `GetTaskRequest` specifying the task name (e.g., `tasks/{task_id}`) and optionally the tenant. ```rust use inference_gateway_adk::a2a_types::GetTaskRequest; let task = client .get_task(GetTaskRequest { history_length: None, name: format!("tasks/{task_id}"), tenant: Some("example".to_string()), }) .await?; ``` -------------------------------- ### Run Streaming Server Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/streaming/README.md Build and run the streaming server locally using Cargo. This server will listen on 0.0.0.0:8080. ```bash cd examples/streaming/server cargo run -p streaming-server ``` -------------------------------- ### Build A2AServer with Agent and Card Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Creates an A2A server with an LLM agent and an agent card loaded from a file. Uses default task handlers. Requires `inference_gateway_adk`. ```rust use inference_gateway_adk::{A2AServerBuilder}; // Server with an LLM agent and an agent card loaded from disk let server = A2AServerBuilder::new() .with_agent(agent) .with_agent_card_from_file(".well-known/agent.json", None) .with_default_task_handlers() .build() .await?; ``` -------------------------------- ### Run Server Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/input-required/README.md Compile and run the server component locally using Cargo. ```bash cd examples/input-required/server cargo run -p input-required-server # or: task examples:input-required-server ``` -------------------------------- ### Run Client Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/input-required/README.md Compile and run the client component locally using Cargo. ```bash cargo run -p input-required-client # or: task examples:input-required-client ``` -------------------------------- ### Common Cargo Commands Source: https://github.com/inference-gateway/rust-adk/blob/main/CLAUDE.md These commands are frequently used for linting, analysis, testing, and running examples within the Rust ADK project. Ensure you have the correct toolchain and features enabled for comprehensive testing. ```bash task lint # cargo fmt --all -- --check task lint:fix # cargo fmt --all task analyse # cargo clippy --all-targets --all-features -- -D warnings task test # cargo test --all-features --all-targets ``` ```bash cargo test --all-features ``` ```bash cargo run --example minimal-server cargo run --example a2a-methods-tasks-list ``` -------------------------------- ### Run Docker Compose Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/minimal/README.md Execute this command to build and run the server and client using Docker Compose. The client connects to the server via the internal Docker network. ```bash cd examples/minimal docker compose up --build ``` -------------------------------- ### Configure LLM from Environment Variables Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/static-agent-card/README.md Use `Config::from_env()` to read LLM configuration, including provider, model, and API key, directly from environment variables. ```rust use inference_gateway::config::Config; // Load configuration from environment variables let config = Config::from_env().expect("Failed to load config from environment"); ``` -------------------------------- ### Run All A2A Method Clients with Docker Compose Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/README.md Executes all A2A method clients sequentially against the shared server using a Docker Compose profile. No provider keys are required. ```bash docker compose --profile all-clients up --build ``` -------------------------------- ### Run Bundled Client (TLS Only) Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/tls/README.md Executes the bundled Rust client for TLS-only communication with the server. Requires the CA certificate path and server URL to be configured via environment variables. ```bash TLS_CA_PATH=examples/tls/certs/ca.crt \ SERVER_URL=https://localhost:8443 \ cargo run -p tls-client ``` -------------------------------- ### Build A2A Agent Container with Metadata Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md This Dockerfile defines a multi-stage build process for an A2A agent. It allows customization of agent metadata like name, description, and version via build arguments. Ensure Rust 1.94 or later is installed. ```dockerfile FROM rust:1.94 AS builder # Build arguments for agent metadata ARG AGENT_NAME="My A2A Agent" ARG AGENT_DESCRIPTION="A custom A2A agent built with the Rust ADK" ARG AGENT_VERSION="1.0.0" WORKDIR /app COPY Cargo.toml Cargo.lock ./ RUN cargo fetch COPY . . # Build with custom agent metadata RUN AGENT_NAME="${AGENT_NAME}" \ AGENT_DESCRIPTION="${AGENT_DESCRIPTION}" \ AGENT_VERSION="${AGENT_VERSION}" \ cargo build --release FROM debian:bookworm-slim RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY --from=builder /app/target/release/rust-adk . CMD ["./rust-adk"] ``` -------------------------------- ### Run Pre-Commit Quality Checks Source: https://github.com/inference-gateway/rust-adk/blob/main/CONTRIBUTING.md Always run linting, static analysis, and tests before committing changes. ```bash # 1. Run linting to ensure code formatting task lint # 2. Run static analysis to catch potential issues task analyse # 3. Run tests to ensure all functionality works task test ``` -------------------------------- ### Load Configuration with Envy Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Loads the application configuration using the `envy` crate with a specified prefix. Ensure environment variables are set according to the `Config` struct and the prefix. ```rust use inference_gateway_adk::Config; let config: Config = envy::prefixed("A2A_").from_env()?; ``` -------------------------------- ### Run Bundled Client (mTLS) Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/tls/README.md Executes the bundled Rust client for mutual TLS (mTLS) communication. Requires CA certificate, client certificate, client key paths, and server URL to be set via environment variables. ```bash TLS_CA_PATH=examples/tls/certs/ca.crt \ TLS_CLIENT_CERT_PATH=examples/tls/certs/client.crt \ TLS_CLIENT_KEY_PATH=examples/tls/certs/client.key \ SERVER_URL=https://localhost:8443 \ cargo run -p tls-client ``` -------------------------------- ### Run Quality Checks for Configuration Changes Source: https://github.com/inference-gateway/rust-adk/blob/main/CONTRIBUTING.md Ensure code quality, catch issues, and verify tests pass after configuration changes. ```bash task lint task analyse task test ``` -------------------------------- ### Build Default OpenAI-Compatible LLM Client Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Constructs the default OpenAI-compatible LLM client using an AgentConfig. This client is used by AgentBuilder by default if no other client is supplied. ```rust use inference_gateway_adk::{AgentBuilder, OpenAICompatibleLLMClient}; // Build the default OpenAI-compatible client from an AgentConfig let llm_client = OpenAICompatibleLLMClient::new(&config.agent_config)?; // Plug it into the agent (or implement `LLMClient` for a custom backend) let agent = AgentBuilder::new() .with_llm_client(llm_client) .build() .await?; ``` -------------------------------- ### Rust ADK Project Structure Source: https://github.com/inference-gateway/rust-adk/blob/main/CONTRIBUTING.md Overview of the directory layout for the Rust ADK project, highlighting key directories and files. ```text rust-adk/ ├── src/ │ ├── a2a_types.rs # Generated A2A protocol types │ ├── client.rs # A2A client implementation │ ├── config.rs # Configuration management │ ├── lib.rs # Library entry point │ └── server.rs # A2A server implementation ├── examples/ # Usage examples ├── tests/ # Integration tests ├── Taskfile.yml # Development tasks └── schema.{json,yaml} # A2A protocol schema ``` -------------------------------- ### Build Minimal A2A Server in Rust Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Sets up the smallest possible A2A server without custom handlers. The builder automatically configures health, agent card, and JSON-RPC routes. ```rust use inference_gateway_adk::A2AServerBuilder; use tracing::{error, info}; #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::fmt().init(); // Smallest possible A2A server - no agent, no custom handlers. // Health, agent card, and JSON-RPC routes are all wired in by the builder. let server = A2AServerBuilder::new().build().await?; let addr = "0.0.0.0:8080".parse()?; info!("A2A server listening on {addr}"); if let Err(e) = server.serve(addr).await { error!("server stopped: {e}"); } Ok(()) } ``` -------------------------------- ### Build Minimal A2AServer Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Constructs the smallest possible A2A server with built-in default handlers and no agent. Requires `inference_gateway_adk`. ```rust use inference_gateway_adk::{A2AServerBuilder}; // Smallest possible A2A server - built-in default handlers, no agent let server = A2AServerBuilder::new().build().await?; ``` -------------------------------- ### Create and Configure A2AClient Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Instantiate an A2AClient for communicating with A2A servers. Supports basic creation with a URL or advanced configuration via ClientConfig for timeouts and retries. ```rust use inference_gateway_adk::A2AClient; // Basic client creation let client = A2AClient::new("http://localhost:8080")?; ``` ```rust // Client with custom configuration let config = ClientConfig { base_url: "http://localhost:8080".to_string(), timeout: Duration::from_secs(45), max_retries: 5, }; let client = A2AClient::with_config(config)?; ``` -------------------------------- ### Build-Time Agent Metadata Configuration Source: https://github.com/inference-gateway/rust-adk/blob/main/README.md Configures agent metadata by embedding it into the binary during compilation using environment variables. This is the recommended approach for production deployments. ```APIDOC ## Build-Time Metadata (Recommended) ### Description Agent metadata is embedded directly into the binary during compilation using environment variables. This approach ensures immutable agent information and is ideal for production deployments. ### Usage Set the following environment variables before building your application: - **AGENT_NAME**: The name of the agent. - **AGENT_DESCRIPTION**: A description of the agent's purpose. - **AGENT_VERSION**: The version of the agent. ### Example ```bash AGENT_NAME="Weather Assistant" \ AGENT_DESCRIPTION="Specialized weather analysis agent" \ AGENT_VERSION="2.0.0" \ cargo build --release ``` ``` -------------------------------- ### Run Streaming Client Locally Source: https://github.com/inference-gateway/rust-adk/blob/main/examples/streaming/README.md Build and run the streaming client locally using Cargo. The client will connect to the server URL specified by the SERVER_URL environment variable, defaulting to http://localhost:8080. ```bash cargo run -p streaming-client ```