Skip to main content

RequestHandlerBuilder

Struct RequestHandlerBuilder 

Source
pub struct RequestHandlerBuilder { /* private fields */ }
Expand description

Fluent builder for RequestHandler.

§Required

  • executor: Any AgentExecutor implementation (passed as a concrete type; the builder erases it to Arc<dyn AgentExecutor> during build).

§Optional (with defaults)

Implementations§

Source§

impl RequestHandlerBuilder

Source

pub fn with_authorized_tenant_resolver( self, resolver: impl TenantResolver, ) -> RequestHandlerBuilder

Sets the tenant resolver and asserts that it is authorized: it names a tenant only from something the server has verified, or a gateway sets and strips from client traffic, never from what the client chose. Profile::MultiTenant refuses a resolver given through with_tenant_resolver alone, since a tenant the caller can choose isolates nothing (see the tenant_resolver module’s security section).

The assertion is yours: nothing here can check that a gateway strips a header or that a JWT’s signature was verified before the claim was read. It is a signed statement in the configuration, and the profile refuses a configuration that does not make it.

Source§

impl RequestHandlerBuilder

Source

pub const fn with_steering( self, config: SteeringConfig, ) -> RequestHandlerBuilder

Takes steering messages: a SendMessage that names a running task and lists the steering extension (STEERING_EXTENSION_URI) is put in that turn’s inbox instead of being refused, and the agent card declares the extension. Off by default: a server that does not call this answers such a message as it always did, and its card does not declare the extension.

An executor reads the inbox with RequestContext::inbox; one that never does is unaffected. config bounds the inbox and the message size; see SteeringConfig and crate::steering for what a steering message is checked against and how it can be refused.

use a2a_protocol_server::{RequestHandlerBuilder, SteeringConfig};

let handler = RequestHandlerBuilder::new(Agent)
    .without_agent_card()
    .with_steering(SteeringConfig::new().with_inbox_capacity(4))
    .build()
    .unwrap();
Source§

impl RequestHandlerBuilder

Source

pub fn new(executor: impl AgentExecutor) -> RequestHandlerBuilder

Creates a new builder with the given executor.

The executor is type-erased to Arc<dyn AgentExecutor>.

Source

pub fn with_task_store( self, store: impl TaskStore + 'static, ) -> RequestHandlerBuilder

Sets a custom task store.

Source

pub fn with_task_store_arc( self, store: Arc<dyn TaskStore>, ) -> RequestHandlerBuilder

Sets a custom task store from an existing Arc.

Use this when you want to share a store instance across multiple handlers or access it from background tasks.

Source

pub fn with_task_store_config( self, config: TaskStoreConfig, ) -> RequestHandlerBuilder

Configures the default InMemoryTaskStore with custom TTL and capacity settings.

When tasks are isolated by caller (the default with an authenticating interceptor; see isolate_tasks_by_caller), the default store is a TenantAwareInMemoryTaskStore and these settings apply to each caller’s partition, so it holds up to max_tenants (1,000) times the capacity. To bound the total otherwise, supply that store with your own TenantStoreConfig.

§Panics

Panics in debug builds if a custom task store has already been set via with_task_store, since the config would be silently ignored.

Source

pub fn with_push_config_store( self, store: impl PushConfigStore + 'static, ) -> RequestHandlerBuilder

Sets a custom push configuration store.

Source

pub fn with_push_config_store_arc( self, store: Arc<dyn PushConfigStore>, ) -> RequestHandlerBuilder

Sets a push-config store from an existing Arc, to keep a handle for work outside requests, such as a tenant-aware store’s erase_caller.

Source

pub fn with_content_signer(self, signer: ContentSigner) -> RequestHandlerBuilder

Available on crate feature signing only.

Signs every artifact, status message and direct reply the server sends with signer (ADR 0027): stream events, pushes, and the tasks and messages SendMessage, GetTask, ListTasks, CancelTask and SubscribeToTask return. Each is signed over exactly what is sent, so an artifact streamed in chunks verifies chunk by chunk on the stream and whole from GetTask. A task’s history is not signed: it holds the caller’s messages as they arrived. Content already signed, such as another agent’s artifact forwarded unchanged, is left as it is. Publish signer.public_jwk() where callers fetch keys.

Source

pub fn with_content_keys(self, keys: Jwks) -> RequestHandlerBuilder

Available on crate feature signing only.

Verifies the provenance signature of every message sent to this agent against keys (ADR 0027): a message whose signature does not verify, because it was altered or signed by a key not in the set, is refused with InvalidParams before the executor runs. An unsigned message is accepted, and the executor reads ContentCheck::Unsigned from RequestContext::content_check; require_signed_content refuses it too.

Source

pub fn require_signed_content(self) -> RequestHandlerBuilder

Available on crate feature signing only.

Refuses unsigned messages as well as altered ones. Anyone able to alter a message can also remove its signature, so a deployment that acts only on content from known agents requires one. Needs with_content_keys, called before this.

Source

pub fn with_push_sender( self, sender: impl PushSender + 'static, ) -> RequestHandlerBuilder

Sets a push notification sender.

Source

pub fn with_push_outbox( self, outbox: Arc<dyn PushOutbox>, ) -> RequestHandlerBuilder

Keeps webhook deliveries in outbox until they are delivered, instead of in memory (ADR 0037): a delivery waiting or being retried when the process stops is delivered after it, by this replica or any other that shares the outbox, with the same A2A-Delivery-Id, and a webhook that is down is retried with backoff for up to push_outbox_max_age. Delivery is then at least once. Needs a push sender; without one there is nothing to deliver with and the outbox is not used.

The handler’s worker claims rows from the moment the handler is built inside a Tokio runtime (or, built outside one, from its first event), so a replica that restarts delivers what an earlier process left.

Source

pub fn with_audit(self, log: Arc<AuditLog>) -> RequestHandlerBuilder

Available on crate feature audit only.

Records every call, run, task event and cancel request in log, a hash chain per tenant (the audit feature; ADR 0015).

The recording interceptor is placed first in the chain, whatever order with_interceptor was called in, so it records calls that authentication refuses. The task store is wrapped so that each event written to a task’s event log is also recorded. Records go to the tenant’s chain, "" for a single-tenant server.

Source

pub fn with_profile(self, profile: Profile) -> RequestHandlerBuilder

Applies a deployment Profile; see each profile for what it sets and what build() then requires. Profiles combine: each one applied adds its requirements.

Source

pub fn with_approval_gate(self, gate: ApprovalGate) -> RequestHandlerBuilder

Checks approval decisions before the executor sees them: see approval. The agent card, if one is set, declares the approval extension.

Source

pub fn with_admission(self, admission: Admission) -> RequestHandlerBuilder

Puts an admission gate in front of the send path (audit H9, ADR 0045): a capacity, slots reserved per tenant, a bounded wait inside the send’s budget, priority classes and weighted fairness, all set by the server. Without one, which is the default, a send the server has no room for is refused at once, as before.

§Errors at build

ServerError::Config when the gate’s capacity is 0 or above the concurrent-stream cap (with_max_concurrent_streams), when its default share reserves slots, or when its reservations sum past its capacity.

Source

pub const fn with_load_reporting(self) -> RequestHandlerBuilder

Reports this replica’s load for balancers (audit H7, ADR 0046): GET /load answers it as JSON on the HTTP+JSON binding and the axum router, and every response the crate’s server or the axum router sends carries it in LOAD_HEADER. Off by default; readiness does not change with it.

Source

pub fn with_halt_store(self, store: impl HaltStore) -> RequestHandlerBuilder

Keeps halts in store as well as in this process (ADR 0019): every handler sharing it follows a halt or resume given to any of them, and a restarted process comes back halted.

The handler reads the store before it admits its first send, refusing sends while it cannot, then every with_halt_poll_interval. A halt given elsewhere therefore stops this process’s running tasks and refuses its sends within one interval; one given here acts at once. Use PostgresHaltStore (the postgres feature) across replicas, SqliteHaltStore (the sqlite feature) for one process that restarts.

Source

pub const fn with_halt_poll_interval( self, interval: Duration, ) -> RequestHandlerBuilder

How often a handler with a halt store reads it; default DEFAULT_HALT_POLL_INTERVAL (one second). It bounds how long a halt given on another replica takes to stop this one. build refuses zero.

Source

pub fn with_lease_store(self, store: impl LeaseStore) -> RequestHandlerBuilder

Grants leases on delegated tasks and stops a task whose lease lapses (ADR 0020; the lease extension, which the agent card then declares).

A send whose message carries a grant (Lease::attach) has it stored here; a GetTask that activates the extension renews it, on any handler sharing the store; a task whose deadline passes is stopped as a halt stops it. Use InMemoryLeaseStore for one process and PostgresLeaseStore (the postgres feature) across replicas.

Source

pub const fn allow_process_local_stores(self) -> RequestHandlerBuilder

Lets Profile::Production accept halt, lease, push-config and audit stores that keep their state in this process, on a task store that several processes share.

Without it build() refuses that combination (audit E-F13, ADR 0025): a halt given to one replica would not reach the tasks another runs, a task delegated to one would be leased only there, a webhook registered through one would never be sent by the replica that runs the task, and each replica would keep an audit chain of its own. The task store being shared is read from it: it hands out turn claims (TaskStore::turn_claims), as the SQL stores do.

Call this when the process-local store is the right one: a deployment that runs on one replica at a time over a shared database, or that routes every request for a task to one replica. It has no effect without the production profile, and none when the task store is not shared.

Source

pub fn with_turn_claims( self, claims: impl TurnClaimStore, ) -> RequestHandlerBuilder

Claims each task for the length of a turn in claims, in place of the task store’s own (TaskStore::turn_claims): one replica at a time runs a task, however many share the store (crate::store::claim).

For a custom store several replicas share, whose writes must then also be fenced with current_fence. build refuses it over a store that provides claims of its own (the bundled PostgreSQL and SQLite stores): their writes are fenced against those, so claims kept anywhere else would refuse every write.

Source

pub fn without_turn_claims(self) -> RequestHandlerBuilder

Takes no turn claims, even when the task store provides them.

For a store only one replica uses: each send then saves the claim’s round trips (two statements per turn, and one renewal per second while any turn runs). With several replicas sharing the store and no claims, every turn of a task must be routed to one replica, or two can run the same task at once and one can overwrite what the other wrote.

Source

pub const fn with_turn_claim_timing( self, ttl: Duration, renewal: Duration, ) -> RequestHandlerBuilder

How long a turn claim lives without renewal, and how often the handler renews the claims it holds; defaults DEFAULT_TURN_CLAIM_TTL (15 s) and DEFAULT_TURN_CLAIM_RENEWAL (1 s).

The time to live bounds how long a task waits after the replica running it dies; the renewal interval, how long a cancel given on another replica takes to reach the executor. build refuses a time to live under MIN_TURN_CLAIM_TTL or a renewal interval that is zero or more than a third of it.

Source

pub fn with_replica_name(self, name: impl Into<String>) -> RequestHandlerBuilder

Names this replica in the claims it takes, for an operator reading the claims table; default HOSTNAME (a Kubernetes pod’s name), else replica. The process id and a random suffix are appended, so two processes never share an owner.

Source

pub const fn with_max_lease_ttl(self, ttl: Duration) -> RequestHandlerBuilder

The longest lease a send may ask for; default DEFAULT_MAX_LEASE_TTL (an hour). A longer one is refused, as is one shorter than MIN_LEASE_TTL; build refuses a bound below that.

Source

pub fn with_interceptor( self, interceptor: impl ServerInterceptor + 'static, ) -> RequestHandlerBuilder

Adds a server interceptor to the chain.

Source

pub const fn with_executor_timeout( self, timeout: Duration, ) -> RequestHandlerBuilder

Sets a timeout for executor execution.

If the executor does not complete within this duration, the task is marked as failed with a timeout error — which the client sees, so this is not a silent outcome.

Defaults to DEFAULT_EXECUTOR_TIMEOUT (1 hour). Match it to the slowest work your agent legitimately does; too short a value fails real tasks, which is why the default is generous rather than tight.

Source

pub const fn without_executor_timeout(self) -> RequestHandlerBuilder

Removes the executor timeout entirely.

An executor that never returns then pins its task, its event queue and its cancellation token for the life of the process. With max_cancellation_tokens at its default of 10,000, enough of them stop the handler accepting work — and nothing reclaims them in between.

Deliberately a named method rather than with_executor_timeout(None): unbounded execution is a position worth stating out loud, and it should be greppable in a deployment’s source.

Source

pub fn with_agent_card(self, card: AgentCard) -> RequestHandlerBuilder

Sets the agent card for discovery responses.

The JSON-RPC and HTTP+JSON dispatchers serve it at /.well-known/agent-card.json, and the handler checks requests against what it declares: streaming, push notifications, input modes, required extensions, the extended card. build() requires a card unless told without_agent_card.

Source

pub fn with_extended_agent_card(self, card: AgentCard) -> RequestHandlerBuilder

Sets the card GetExtendedAgentCard serves to an authenticated caller (spec §3.1.11, §13.3): the public card plus whatever the agent offers only to clients it knows, such as more skills or a security scheme.

Without it, a handler whose card declares capabilities.extendedAgentCard answers GetExtendedAgentCard with ExtendedAgentCardNotConfiguredError, as §3.1.11 and §13.3 require. Until 0.15 it served the public card in its place; to keep serving the same content, pass the public card here.

build() checks it as it checks the public card: it must be valid, a push-notification capability needs a sender, and the extensions this server can honour are advertised on it too, since a client that fetches it uses its capabilities from then on. build() refuses it when the public card does not declare extendedAgentCard, since it would never be served. Without a public card (without_agent_card) it is served, the card published elsewhere being the one that declares it.

Source

pub fn with_extended_card_provider( self, provider: impl ExtendedCardProvider, ) -> RequestHandlerBuilder

Chooses, per caller, the extended card GetExtendedAgentCard serves (spec §13.3: “Agents MAY return different extended card content based on the authenticated client’s identity or authorization level”).

The provider is given the request’s CallContext, after the interceptor chain has authenticated it, and the card set with with_extended_agent_card, which build() therefore requires. The card it returns is checked as that one is; see ExtendedCardProvider.

Source

pub fn without_agent_card(self) -> RequestHandlerBuilder

Builds a handler with no agent card.

Spec §8.1: an A2A server MUST make an agent card available, so build() refuses a handler without one unless this is called. Call it when the card is published by something other than this handler (a gateway, or your own route serving a DynamicAgentCardHandler), or when the handler is not a public A2A server at all, as in a test.

Without a card the dispatchers answer /.well-known/agent-card.json with 404, GetExtendedAgentCard answers UnsupportedOperationError (SPEC §13.3: nothing here declares the capability) unless with_extended_agent_card set one, and nothing a card would declare is checked: streaming and push notifications are served, any input mode is accepted, no extension is required, and none is advertised.

Source

pub const fn with_event_queue_capacity( self, capacity: usize, ) -> RequestHandlerBuilder

Sets the event queue channel capacity for streaming.

Defaults to DEFAULT_QUEUE_CAPACITY (256 items). Higher values allow more events to be buffered before backpressure is applied. Lower values reduce memory footprint at the cost of earlier slow-consumer stalls.

Source

pub const fn with_max_event_size( self, max_event_size: usize, ) -> RequestHandlerBuilder

Sets the maximum serialized event size in bytes.

Events exceeding this size are rejected to prevent OOM conditions. Defaults to 16 MiB.

Source

pub const fn with_max_concurrent_streams( self, max: usize, ) -> RequestHandlerBuilder

Sets the maximum number of concurrent event queues: one per task being run, whether its send blocks or streams.

Limits memory usage from concurrent tasks. When the limit is reached, a send that would open one more is refused as overloaded. Defaults to DEFAULT_MAX_CONCURRENT_STREAMS (1024); pass usize::MAX to effectively disable the ceiling.

Source

pub const fn with_handler_limits( self, limits: HandlerLimits, ) -> RequestHandlerBuilder

Sets configurable limits for the handler (ID lengths, metadata size, etc.).

Defaults to HandlerLimits::default().

Source

pub fn with_metrics( self, metrics: impl Metrics + 'static, ) -> RequestHandlerBuilder

Sets a metrics observer for handler activity.

Defaults to OtelMetrics instruments on the global meter provider as it stands at each measurement (otel), else NoopMetrics.

This replaces the default, so a handler given a counter of its own no longer exports rpc.server.call.duration or the a2a.server.* instruments. To keep the default and also observe, use with_additional_metrics.

Source

pub fn with_additional_metrics( self, metrics: impl Metrics + 'static, ) -> RequestHandlerBuilder

Also reports to metrics, keeping what the handler reports to now: the default (OtelMetrics instruments on the global meter provider, else NoopMetrics), or whatever with_metrics or an earlier call set.

Each callback goes to the existing metrics first, then to metrics. Use it to count something of your own beside the OpenTelemetry export; with_metrics is for replacing the export.

Source

pub fn with_tenant_resolver( self, resolver: impl TenantResolver, ) -> RequestHandlerBuilder

Sets a tenant resolver for multi-tenant deployments.

The resolver extracts a tenant identifier from each incoming request’s CallContext. That identifier is what partitions the tenant-aware stores, so setting a resolver is what makes data isolation real.

It is also what keys per-tenant resource limits: pair it with with_tenant_config and the limits of the resolved tenant are applied. Because every limit is keyed on what this resolver returns, a resolver that trusts client-supplied input lets a caller choose their own limits — see tenant_config.

Defaults to None (single-tenant mode).

Source

pub const fn require_resolved_tenant(self) -> RequestHandlerBuilder

Enables strict multi-tenancy: reject any request for which a configured with_tenant_resolver returns None (no tenant could be determined) instead of falling back to the shared default ("") partition.

Use this when every request must carry an identifiable tenant — it closes the gap where header-less or unauthenticated callers would otherwise all share one default bucket. Has no effect unless a resolver is configured.

Defaults to false (the resolver’s documented None → default-partition behavior is preserved).

Source

pub const fn accept_unisolated_tenants(self) -> RequestHandlerBuilder

Serves requests that name a tenant even though the stores do not partition by tenant.

By default such a request is refused with UnsupportedOperation: a store that ignores the tenant would serve tenant B the records tenant A wrote. Call this only where tenants key something other than data — per-tenant limits through with_tenant_config over a store every caller is meant to share. Every tenant then reads and writes the same records; that is what this opts in to.

Has no effect when both stores answer isolates_tenants.

Source

pub const fn isolate_tasks_by_caller(self) -> RequestHandlerBuilder

Gives every authenticated caller a partition of its own within its tenant (spec §13.1), and refuses a request whose caller no interceptor identified.

Partitioning is already the default whenever an interceptor authenticates, with one difference: by default a request no interceptor identified (an unlabelled bearer token or API key) keeps the tenant’s shared records, as it would with no isolation, so credentials that name nobody behave as before. A JWT without sub is refused under either. Call this when every caller must be identified: such a request is then refused with PermissionDenied, and build() refuses a chain with no authenticating interceptor.

Without isolation the SDK scopes tasks by tenant only: two callers who pass the interceptors as different identities in the same tenant (or in the default single-tenant deployment) can get, list, cancel and subscribe to each other’s tasks, and register webhooks on them. §13.1 requires results scoped to the caller’s authorization boundaries; this is the user-identity model of it. With it, the identity an authenticating interceptor sets (CallContext::set_caller_identity) selects the records a request can reach: another caller’s task is TaskNotFound, exactly as an unknown id is, so its existence is not revealed, and ListTasks returns only the caller’s own.

Per-tenant policy is unchanged: the halt switch, concurrency quotas, audit chains and metrics still see one tenant. Each caller’s partition counts against the store’s tenant limit (TenantStoreConfig::max_tenants, 1,000 by default, for the in-memory store; once reached, new callers are refused until partitions empty). The SQL tenant stores have no such limit.

Models that share tasks between callers (roles, groups, projects) are not this: map the group to a tenant with a TenantResolver instead, or call share_tasks_across_callers.

§Stores and build errors

Isolation, by default or by this call, needs a task store and a push-config store that partition by tenant. Left unset, both default to the tenant-aware in-memory stores. build() refuses a store you supplied that does not partition, since nothing would then keep callers apart, and refuses this call with no authenticating interceptor, since every request would then be refused for want of an identity.

Source

pub const fn share_tasks_across_callers(self) -> RequestHandlerBuilder

Keeps one set of records per tenant, shared by every caller in it, even when an interceptor authenticates.

Spec §13.1 leaves the authorization model to the agent; this is the model in which every authenticated caller of a tenant may see every task in it, and it lets build() accept stores that do not partition by tenant. Without this call a handler with an authenticating interceptor isolates tasks by identified caller (see isolate_tasks_by_caller). Where the sharing group is known (a team, a project), mapping it to a tenant with a TenantResolver keeps other groups out and is usually the better fit.

Source

pub const fn with_inbound_trace_policy( self, policy: InboundTracePolicy, ) -> RequestHandlerBuilder

Decides what this handler does with a traceparent an as-yet unauthenticated peer sent it.

The inbound trace is joined while the CallContext is built, which is before the interceptor chain runs — and the interceptor chain is where authentication happens. So on a public endpoint the peer choosing the trace-id and the sampling bit is, at that moment, anonymous. W3C Trace Context §7.2 names the consequences and §3.4 names the remedy; InboundTracePolicy quotes both.

Defaults to InboundTracePolicy::Continue, because A2A’s premise is a mesh of agents delegating to one another and one trace id surviving every hop is what makes such a chain readable. A front gate opts in to Restart or Drop.

Per handler, so one process serving both a public front gate and an internal endpoint can hold a different policy on each.

Source

pub fn with_baggage_propagation( self, policy: BaggagePolicy, ) -> RequestHandlerBuilder

Which entries of a caller’s W3C baggage header the call’s OpenTelemetry context takes, and so the executor and the calls it makes: none by default (audit C-10). Baggage can carry user data across a trust boundary, so a receiving agent names the keys it accepts (BaggagePolicy::keys). Read only under InboundTracePolicy::Continue, within the W3C limits (64 members, 8192 bytes); never a metric label.

Source

pub fn with_propagators(self, propagators: Propagators) -> RequestHandlerBuilder

Which propagators inbound calls are read with, instead of OTEL_PROPAGATORS (read when the handler is built; default tracecontext,baggage). Without tracecontext a caller’s traceparent is not continued (a Continue policy acts as Restart); without baggage no baggage is read.

Source

pub const fn with_agent_span_conventions( self, on: bool, ) -> RequestHandlerBuilder

Whether the executor’s span follows the OpenTelemetry GenAI agent conventions (default: yes).

On, each run of the executor is an invoke_agent {name} span with gen_ai.operation.name, the agent’s name, description and version from its card, and the A2A context as gen_ai.conversation.id — which is what observability backends key on: Langfuse shows the run as an agent and groups a context’s runs into one session. Off, the span is a2a.execute with the task and context ids only, as in 0.14.

Turn it off when an agent framework running inside the executor reports its own invoke_agent span, so the two do not nest. The conventions are development upstream and may change; see book/src/deployment/observability.md.

Source

pub const fn with_span_content_capture(self, on: bool) -> RequestHandlerBuilder

Whether the executor’s span records the request’s message and the agent’s replies and artifacts, as gen_ai.input.messages and gen_ai.output.messages (default: no).

This copies what users and agents say into your traces, and from there to wherever they are exported — which is why the conventions make these attributes opt-in and why this is off unless you turn it on. Each attribute holds at most 64 KiB of text and data, cut with a marker beyond that; raw file bytes are never recorded, only their media type and length.

Source

pub const fn allow_unauthenticated_extended_card(self) -> RequestHandlerBuilder

Serves GetExtendedAgentCard even when no authenticating interceptor is registered.

Spec §13.3 requires the extended card endpoint to be authenticated, so by default a handler whose card declares capabilities.extendedAgentCard: true refuses to serve the card unless the interceptor chain contains at least one interceptor whose authenticates() returns true. Call this only when the extended card genuinely contains nothing sensitive (e.g. it is identical to the public card) or authentication is enforced upstream of this process (API gateway, service mesh, mTLS sidecar).

Source

pub const fn authenticated_upstream(self) -> RequestHandlerBuilder

Builds a handler whose agent card requires authentication although no interceptor here authenticates, because something in front of this process does (an API gateway, a service mesh, an mTLS sidecar).

By default build refuses a card whose securityRequirements (or a skill’s) ask for a credential when no registered interceptor authenticates: every request would otherwise be served without the credential the card demands (spec §3.3.2, §7.4). Call this only when that credential is checked before a request reaches this handler. Since 2026-10-18.

Source

pub const fn expose_internal_errors(self) -> RequestHandlerBuilder

Sends callers the text of internal errors: what an executor, a store or an outbound call wrote, as written.

By default a caller is told only that an internal error happened, with a reference to find its text in the log (feature tracing), in the error it is answered with and in the Failed status of a task whose executor returned one. That text is often not the caller’s to read: a URL with its API key, a database’s table and constraint names, an identity provider’s response (audit SEC-07). Errors of any other code, such as InvalidParams, are sent as they are written. For development, or an agent whose callers are its operators.

Source

pub const fn allow_undeclared_input_modes(self) -> RequestHandlerBuilder

Accepts message parts whose mediaType the agent card does not declare.

By default, when the card declares input modes — defaultInputModes or any skill’s inputModes — a SendMessage part carrying a mediaType outside them is refused with ContentTypeNotSupportedError, as spec §3.1.1 requires. Call this for an agent whose card under-declares what it accepts, until the card is corrected. Parts without a mediaType are never checked.

Source

pub const fn refuse_private_file_urls(self) -> RequestHandlerBuilder

Refuses a message carrying a file reference (a part whose content is a url) that points into a private, loopback, link-local or internal network, with InvalidParams naming the part. Default: accepted.

Spec §14: “File references within A2A messages MUST be validated to prevent SSRF”. The SDK never fetches a file reference; an agent that does fetches whatever a caller names, from inside the deployment’s network. This applies url_guard::check_public_url to every one on arrival, with no DNS lookup: an agent should still connect through url_guard::resolve_public_url, since a public name can resolve inward. Off by default because an agent on a private network may be meant to read internal files. Since 2026-10-18.

Source

pub fn declare_external_control( self, control: ExternalControl, how: impl Into<String>, ) -> RequestHandlerBuilder

Declares how a control outside this process is met, for the record: how says what the deployment does ("backups: nightly pg_dump to another region; restore rehearsed 2026-10-30"). Nothing checks it. It is carried into RequestHandler::profile_report as declared, not verified, so the record of what the handler was built to promise says what the deployment said it does, beside what was checked. Declaring a control again replaces the earlier declaration. build() refuses a declaration whose text is blank, and Profile::RegulatedData refuses to build without the declarations it relies on.

Source

pub fn with_tenant_config( self, config: PerTenantConfig, ) -> RequestHandlerBuilder

Applies per-tenant resource limits.

The handler enforces max_concurrent_tasks, executor_timeout and event_queue_capacity from this configuration for every request, keyed on the tenant that with_tenant_resolver resolved. rate_limit_rps needs one more step — the same config passed to RateLimitInterceptor::with_tenant_config — because the request is counted in an interceptor rather than here.

See tenant_config for where each limit is applied and what exceeding it returns.

Defaults to None: uniform limits for all callers.

Source

pub fn build_arc(self) -> Result<Arc<RequestHandler>, ServerError>

build, in the Arc every dispatcher takes (audit G-17: every snippet wrapped Arc::new(builder.build()?)).

§Errors

As build.

Source

pub fn build(self) -> Result<RequestHandler, ServerError>

Builds the RequestHandler.

§Errors

Returns ServerError::Config, naming what to change, if the configuration is one this handler cannot serve correctly:

  • an agent card the spec does not allow (AgentCard::validate and AgentCard::validate_security_schemes), or a signed card it would have to edit to declare an extension;
  • no agent card, unless without_agent_card (spec §8.1);
  • an agent card whose securityRequirements ask for a credential when no interceptor authenticates, unless authenticated_upstream; or an authenticating interceptor that checks none of the schemes the card declares (spec §3.3.2, §7.4, §13.3);
  • an agent card that declares pushNotifications with no push sender (spec §3.3.4);
  • a zero executor timeout, max_id_length, max_metadata_size or push_delivery_timeout;
  • tasks isolated by caller with a store that does not partition by tenant, with no authenticating interceptor (when asked for explicitly), or with an approval gate that needs a second approver (see isolate_tasks_by_caller);
  • an approval gate whose quorum could never be met: 0, more than its allowed approvers, or more than one with tasks isolated by caller;
  • a Profile whose requirements are not met.

Trait Implementations§

Source§

impl Debug for RequestHandlerBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more