This document provides comprehensive configuration options for the A2A Ruby SDK.
- Global Configuration
- Client Configuration
- Server Configuration
- Transport Configuration
- Authentication Configuration
- Storage Configuration
- Logging Configuration
- Performance Configuration
- Environment Variables
Configure the A2A SDK globally using the A2A.configure method:
# config/initializers/a2a.rb (Rails)
# or at the top of your application
A2A.configure do |config|
# Protocol settings
config.protocol_version = "0.3.0"
config.default_transport = "JSONRPC"
# Feature flags
config.streaming_enabled = true
config.push_notifications_enabled = true
# Timeouts
config.default_timeout = 30
config.connect_timeout = 10
# Security
config.force_ssl = true
config.ssl_verify = true
end- Type: String
- Default:
"0.3.0" - Description: A2A protocol version to use
config.protocol_version = "0.3.0"- Type: String
- Default:
"JSONRPC" - Options:
"JSONRPC","GRPC","HTTP+JSON" - Description: Default transport protocol for clients
config.default_transport = "JSONRPC"- Type: Boolean
- Default:
true - Description: Enable streaming responses globally
config.streaming_enabled = true- Type: Boolean
- Default:
true - Description: Enable push notification support
config.push_notifications_enabled = true- Type: Boolean
- Default:
true(when Rails is detected) - Description: Enable Rails-specific features
config.rails_integration = true- Type: Integer
- Default:
30 - Unit: Seconds
- Description: Default request timeout
config.default_timeout = 60 # 1 minute- Type: Integer
- Default:
10 - Unit: Seconds
- Description: Connection establishment timeout
config.connect_timeout = 5 # 5 seconds- Type: Integer
- Default:
30 - Unit: Seconds
- Description: Response read timeout
config.read_timeout = 45 # 45 seconds- Type: Boolean
- Default:
true(production),false(development) - Description: Require HTTPS for all connections
config.force_ssl = Rails.env.production?- Type: Boolean
- Default:
true - Description: Verify SSL certificates
config.ssl_verify = true- Type: Array
- Default:
[](no restrictions) - Description: Restrict connections to specific hosts
config.allowed_hosts = ["agent1.example.com", "agent2.example.com"]Configure individual clients using A2A::Client::Config:
config = A2A::Client::Config.new
# Streaming settings
config.streaming = true
config.polling = false
config.polling_interval = 5
# Transport settings
config.supported_transports = ['JSONRPC', 'GRPC']
config.use_client_preference = true
# Output settings
config.accepted_output_modes = ['text', 'structured']
# Timeout settings
config.timeout = 60
config.connect_timeout = 10
# Retry settings
config.max_retries = 3
config.retry_delay = 1
config.retry_backoff = 2
client = A2A::Client::HttpClient.new(url, config: config)- Type: Boolean
- Default:
true - Description: Enable streaming responses for this client
- Type: Boolean
- Default:
false - Description: Enable polling fallback when streaming fails
- Type: Integer
- Default:
5 - Unit: Seconds
- Description: Polling interval for task status updates
- Type: Array
- Default:
['JSONRPC'] - Options:
'JSONRPC','GRPC','HTTP+JSON' - Description: Transport protocols supported by client
- Type: Boolean
- Default:
true - Description: Use client transport preference in negotiation
- Type: Array
- Default:
['text', 'structured'] - Options:
'text','structured','binary' - Description: Output modes accepted by client
- Type: Integer
- Default:
3 - Description: Maximum number of retry attempts
- Type: Integer
- Default:
1 - Unit: Seconds
- Description: Initial delay between retries
- Type: Float
- Default:
2.0 - Description: Backoff multiplier for retry delays
Configure A2A servers and agents:
class MyAgent
include A2A::Server::Agent
# Agent metadata
a2a_config(
name: "My Agent",
description: "A sample A2A agent",
version: "1.0.0",
url: "https://myagent.example.com/a2a",
provider: {
name: "My Company",
url: "https://mycompany.com"
}
)
# Global agent settings
a2a_settings do |settings|
settings.max_concurrent_tasks = 10
settings.task_timeout = 300
settings.enable_task_history = true
settings.history_length = 100
end
end- Type: String
- Required: Yes
- Description: Human-readable agent name
- Type: String
- Required: Yes
- Description: Agent description
- Type: String
- Required: Yes
- Description: Agent version (semantic versioning recommended)
- Type: String
- Required: No
- Description: Agent endpoint URL
- Type: Hash
- Required: No
- Description: Provider information
name(String) - Provider nameurl(String) - Provider URL
- Type: Integer
- Default:
10 - Description: Maximum concurrent tasks per agent
- Type: Integer
- Default:
300 - Unit: Seconds
- Description: Default task timeout
- Type: Boolean
- Default:
true - Description: Store task message history
- Type: Integer
- Default:
100 - Description: Maximum messages in task history
A2A.configure do |config|
config.http_adapter = :net_http_persistent
config.http_pool_size = 5
config.http_keep_alive = 30
config.http_user_agent = "A2A-Ruby/#{A2A::VERSION}"
end- Type: Symbol
- Default:
:net_http - Options:
:net_http,:net_http_persistent,:typhoeus - Description: Faraday adapter for HTTP transport
- Type: Integer
- Default:
5 - Description: HTTP connection pool size
- Type: Integer
- Default:
30 - Unit: Seconds
- Description: HTTP keep-alive timeout
A2A.configure do |config|
config.grpc_enabled = true
config.grpc_pool_size = 5
config.grpc_keepalive_time = 30
config.grpc_keepalive_timeout = 5
end- Type: Boolean
- Default:
false - Description: Enable gRPC transport support
- Type: Integer
- Default:
5 - Description: gRPC connection pool size
A2A.configure do |config|
config.sse_heartbeat_interval = 30
config.sse_reconnect_delay = 5
config.sse_max_reconnects = 10
end- Type: Integer
- Default:
30 - Unit: Seconds
- Description: SSE heartbeat interval
- Type: Integer
- Default:
5 - Unit: Seconds
- Description: Delay before SSE reconnection
auth = A2A::Client::Auth::OAuth2.new(
client_id: ENV['A2A_CLIENT_ID'],
client_secret: ENV['A2A_CLIENT_SECRET'],
token_url: ENV['A2A_TOKEN_URL'],
scope: "a2a:read a2a:write",
audience: "https://api.example.com"
)auth = A2A::Client::Auth::JWT.new(
token: ENV['A2A_JWT_TOKEN'],
header: "Authorization", # or custom header
prefix: "Bearer" # token prefix
)# Header-based
auth = A2A::Client::Auth::ApiKey.new(
key: ENV['A2A_API_KEY'],
header: "X-API-Key"
)
# Query parameter
auth = A2A::Client::Auth::ApiKey.new(
key: ENV['A2A_API_KEY'],
parameter: "api_key"
)# config/initializers/a2a.rb
A2A.configure do |config|
config.server_auth_strategy = :jwt
config.jwt_secret = ENV['JWT_SECRET']
config.jwt_algorithm = 'HS256'
config.jwt_issuer = 'your-app'
config.jwt_audience = 'a2a-agents'
endA2A.configure do |config|
config.storage_backend = :database
config.database_url = ENV['DATABASE_URL']
config.database_pool_size = 5
config.database_timeout = 5000
endA2A.configure do |config|
config.storage_backend = :redis
config.redis_url = ENV['REDIS_URL']
config.redis_pool_size = 5
config.redis_timeout = 5
config.redis_namespace = 'a2a'
endA2A.configure do |config|
config.storage_backend = :memory
config.memory_max_tasks = 1000
config.memory_cleanup_interval = 300
endA2A.configure do |config|
# Log level
config.log_level = :info # :debug, :info, :warn, :error
# Request/response logging
config.log_requests = false
config.log_responses = false
config.log_request_bodies = false
config.log_response_bodies = false
# Custom logger
config.logger = Rails.logger # or custom logger
# Log format
config.log_format = :json # :text, :json
# Structured logging
config.structured_logging = true
config.log_correlation_id = true
enddebug- Detailed debugging informationinfo- General information messageswarn- Warning messageserror- Error messages only
require 'logger'
custom_logger = Logger.new(STDOUT)
custom_logger.formatter = proc do |severity, datetime, progname, msg|
"[#{datetime}] #{severity}: #{msg}\n"
end
A2A.configure do |config|
config.logger = custom_logger
endA2A.configure do |config|
config.enable_metrics = true
config.metrics_backend = :prometheus # :prometheus, :statsd, :custom
config.metrics_namespace = 'a2a'
config.metrics_tags = { service: 'my-agent' }
endA2A.configure do |config|
config.rate_limit_enabled = true
config.rate_limit_requests = 100
config.rate_limit_window = 60
config.rate_limit_storage = :redis # :memory, :redis
endA2A.configure do |config|
config.enable_caching = true
config.cache_backend = :redis # :memory, :redis, :rails
config.cache_ttl = 300 # 5 minutes
config.cache_namespace = 'a2a_cache'
endA2A.configure do |config|
config.connection_pool_size = 10
config.connection_pool_timeout = 5
config.connection_keep_alive = 30
endThe A2A SDK supports configuration via environment variables:
# Protocol
A2A_PROTOCOL_VERSION=0.3.0
A2A_DEFAULT_TRANSPORT=JSONRPC
# Timeouts
A2A_DEFAULT_TIMEOUT=30
A2A_CONNECT_TIMEOUT=10
# Security
A2A_FORCE_SSL=true
A2A_SSL_VERIFY=true# OAuth 2.0
A2A_CLIENT_ID=your-client-id
A2A_CLIENT_SECRET=your-client-secret
A2A_TOKEN_URL=https://auth.example.com/token
A2A_SCOPE=a2a:read a2a:write
# JWT
A2A_JWT_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
A2A_JWT_SECRET=your-jwt-secret
# API Key
A2A_API_KEY=your-api-key# Database
A2A_STORAGE_BACKEND=database
DATABASE_URL=postgresql://user:pass@localhost/db
# Redis
A2A_STORAGE_BACKEND=redis
REDIS_URL=redis://localhost:6379/0A2A_LOG_LEVEL=info
A2A_LOG_REQUESTS=false
A2A_LOG_RESPONSES=false
A2A_LOG_FORMAT=jsonA2A_ENABLE_METRICS=true
A2A_METRICS_BACKEND=prometheus
A2A_RATE_LIMIT_ENABLED=true
A2A_RATE_LIMIT_REQUESTS=100The SDK validates configuration at startup:
A2A.configure do |config|
config.protocol_version = "invalid" # Will raise error
end
# Raises A2A::Errors::InvalidConfigurationprotocol_versionmust be a valid semantic versiondefault_transportmust be a supported transport- Timeout values must be positive integers
- Storage backend must be available
- Authentication credentials must be valid format
Configuration is resolved in this order (highest to lowest priority):
- Explicit configuration in code
- Environment variables
- Configuration files
- Default values
# 1. Explicit (highest priority)
A2A.configure { |c| c.timeout = 60 }
# 2. Environment variable
ENV['A2A_DEFAULT_TIMEOUT'] = '45'
# 3. Configuration file
# config/a2a.yml: timeout: 30
# 4. Default value: 30
# Result: timeout = 60 (explicit wins)# config/a2a.yml
development:
protocol_version: "0.3.0"
default_transport: "JSONRPC"
streaming_enabled: true
log_level: debug
storage_backend: memory
production:
protocol_version: "0.3.0"
default_transport: "JSONRPC"
streaming_enabled: true
log_level: info
storage_backend: database
force_ssl: trueLoad configuration:
config_file = Rails.root.join('config', 'a2a.yml')
config_data = YAML.load_file(config_file)[Rails.env]
A2A.configure do |config|
config_data.each do |key, value|
config.send("#{key}=", value)
end
endSome settings can be changed at runtime:
# Change log level
A2A.configuration.log_level = :debug
# Enable/disable features
A2A.configuration.streaming_enabled = false
# Update timeouts
A2A.configuration.default_timeout = 60Note: Some settings (like storage backend) require restart to take effect.
- Use environment variables for sensitive data (API keys, secrets)
- Set appropriate timeouts based on your use case
- Enable SSL verification in production
- Use structured logging for better observability
- Configure rate limiting to protect your services
- Enable metrics for monitoring and debugging
- Use connection pooling for better performance
- Validate configuration in your deployment pipeline
SSL Certificate Errors:
# Temporary fix for development
A2A.configure { |c| c.ssl_verify = false }Timeout Issues:
# Increase timeouts for slow networks
A2A.configure do |config|
config.default_timeout = 120
config.connect_timeout = 30
endAuthentication Failures:
# Enable request logging to debug
A2A.configure do |config|
config.log_requests = true
config.log_level = :debug
endFor more configuration help, see the Troubleshooting Guide.