Skip to content

Errors (Python)

The host follows the wire-format ID rules. A request with id: null is answered with id: null; only an absent id is a notification. A frame without jsonrpc: "2.0" is answered with -32600 Invalid Request, carrying the readable request id through or using null when there is no usable id.

TesseronErrorCode is an IntEnum carrying every code the protocol defines. The set is closed: a gateway that sends an integer outside it speaks a protocol this package does not implement, so ProtocolError keeps the raw integer and named_code answers None rather than inventing a member.

CodeMemberWhen
-32700PARSE_ERRORThe peer sent something that is not JSON.
-32600INVALID_REQUESTNot a JSON-RPC 2.0 envelope.
-32601METHOD_NOT_FOUNDA method this host does not answer.
-32602INVALID_PARAMSParams the method cannot use, including an elicit schema MCP cannot render.
-32603INTERNAL_ERRORAnything unexpected. Never carries detail.
-32000PROTOCOL_MISMATCHThe two sides speak different protocol majors.
-32001CANCELLEDThe agent cancelled the invocation.
-32002TIMEOUTThe invocation passed its deadline.
-32003ACTION_NOT_FOUNDNo such action, or no such readable or subscribable resource.
-32004INPUT_VALIDATIONInput did not satisfy the declared schema.
-32005HANDLER_ERRORA domain failure the handler reported on purpose.
-32006SAMPLING_NOT_AVAILABLEThe agent never negotiated sampling.
-32007ELICITATION_NOT_AVAILABLEThe agent never negotiated elicitation.
-32008SAMPLING_DEPTH_EXCEEDEDThe gateway's own sampling-depth guard.
-32009UNAUTHORIZEDThe session is not claimed, or the claim does not cover this.
-32010TRANSPORT_CLOSEDThe connection went away with a request still in flight.
-32011RESUME_FAILEDThe gateway refused the resume credentials.

TesseronErrorCode.from_wire_code(code) names a wire integer, or answers None for one this version does not define.

from tesseron import ActionError, TesseronErrorCode
raise ActionError.handler("Todo not found", {"kind": "not_found"})
raise ActionError.protocol(
TesseronErrorCode.UNAUTHORIZED, "this agent cannot charge cards"
)
raise ActionError.internal(RuntimeError("database unavailable"))

The distinction that matters is what crosses the socket. handler and protocol send their message and data to the agent. internal keeps the cause on your side, reachable through internal_source, and answers with a bare -32603 Internal error: a stack trace or a database URL in a handler error is a leak.

An exception that is not an ActionError is turned into ActionError.internal automatically, so an unhandled failure in a handler never spills detail either. with_data(data) attaches structured detail the agent can branch on.

ProtocolError is the error member of a JSON-RPC failure, exactly as it travels: code, message, data. It is what the SDK raises when the gateway refuses something the host asked for, and what to_wire() produces for a failure the host is sending.

These never reach the wire. They are how the host tells you it cannot start.

ExceptionWhen
HostErrorThe base. A handler that is not a coroutine function, or that does not take (input_data, context).
InvalidApplicationIdErrorThe application id is reserved or does not match ^[a-z][a-z0-9_]*$.
DuplicateNameErrorTwo actions, or two resources, under one name.
ManifestErrorThe instance manifest could not be written or removed.
MissingApplicationErrorNo application descriptor was registered before listen.