Skip to content

Errors (Rust)

The Rust SDK keeps three error types separate. HostError means the application could not start or shut down. ActionError is what a handler returns when an invocation fails. ProtocolError is the JSON-RPC error object that crosses the connection.

TesseronErrorCode is the closed set of protocol codes. as_wire_code() returns the JSON-RPC integer, and from_wire_code(...) returns None for an integer this SDK does not define.

CodeVariantWhen
-32700ParseErrorThe peer sent bytes that are not valid JSON.
-32600InvalidRequestThe envelope is not a valid JSON-RPC 2.0 message.
-32601MethodNotFoundThe requested method is not part of the Tesseron protocol.
-32602InvalidParamsMethod parameters do not match the documented shape, including an elicit schema MCP cannot render.
-32603InternalErrorAn unexpected failure occurred. Detail stays local.
-32000ProtocolMismatchThe host and gateway disagree on the protocol major version.
-32001CancelledThe agent cancelled the invocation.
-32002TimeoutThe invocation passed its action timeout.
-32003ActionNotFoundNo action is registered under the requested name, or a resource is not readable or subscribable.
-32004InputValidationThe invocation input failed the action's declared schema.
-32005HandlerErrorThe handler reported a domain failure.
-32006SamplingNotAvailableThe agent did not negotiate sampling.
-32007ElicitationNotAvailableThe agent did not negotiate elicitation.
-32008SamplingDepthExceededThe gateway's sampling-depth limit was exceeded.
-32009UnauthorizedThe session is unclaimed or the operation is not permitted.
-32010TransportClosedThe transport closed while a request was in flight.
-32011ResumeFailedThe gateway refused the resume credentials.

Handlers return Result<Output, ActionError>. Use ActionError::handler(message) for a domain failure that should reach the agent as HandlerError. Use ActionError::protocol(code, message, data) when the agent needs a specific code and optional structured Value. ActionError::with_data(data) adds detail to an existing error.

ActionError::internal(source) keeps the source error in internal_source() and sends only -32603 Internal error. An unexpected error from a handler follows the same redacted path. This keeps panic messages, database URLs, and other local details off the wire.

ProtocolError represents the JSON-RPC error member with public code: i32, message: String, and optional data: Value. It keeps the raw integer so a newer peer's unknown code can round-trip. Call named_code() when you want Option<TesseronErrorCode>.

ProtocolError::new(code, message) builds a known-code payload, and .with_data(data) attaches structured detail. The SDK turns gateway responses into ActionError when a handler's sample, confirm, or elicit request fails.

These errors occur before an invocation reaches a handler:

VariantWhen
MissingApplicationNo application was registered before listen().
InvalidApplicationId(String)The id fails ^[a-z][a-z0-9_]*$ or is reserved.
InvalidTypedActionInputSchema { action_name, input_type_name }A typed action's derived or overridden input schema is not an object root. The error names both the action and Rust input type.
DuplicateName(String)Two actions or two resources use the same name.
NonLoopbackBindAddress(SocketAddr)bind_address(...) was given a non-loopback address.
Listen(io::Error)The loopback listener could not bind.
Manifest(io::Error)The instance manifest could not be written or removed.
HomeDirectoryUnknownThe home directory for ~/.tesseron could not be resolved.

listen() refuses a non-loopback address before binding. shutdown().await reports a manifest removal failure through HostError::Manifest.