code: an integer identifying the kind of errormessage: a short human-readable descriptiondata(optional): additional information whose shape depends on the code
Error codes
Receivers MUST treat an unrecognized code as a generic failure. Implementation-specific errors SHOULD use codes outside
-32768 to -32000 and -32899 to -32800, which are reserved for JSON-RPC and ACP. ACP takes -32800 (Request cancelled) from the second range, which LSP also reserves.
Common cases
Unknown methods
A receiver that does not implement a method, or receives a capability-gated method it did not advertise, SHOULD respond with-32601.
Invalid parameters
Malformed parameters and unsupported values get-32602. For example, an invalid session/list cursor, or an unknown configId or value in session/set_config_option. The same applies to an unknown mode in session/set_mode.
A systemPrompt the Agent cannot apply gets an error, and -32602 is recommended. See System prompt.
Unknown sessions
If a session-scoped request names a session that does not exist or is not active on the connection, the Agent SHOULD respond with-32002 and set data.sessionId to the requested ID. A session is active once it is created, loaded or resumed on the connection, until it is closed.
This applies to session/prompt, session/set_mode and session/set_config_option, and to session/load or session/resume of a session that does not exist. Closing or deleting a session that does not exist still succeeds. See Closing Active Sessions and Deleting Sessions.
Draft only. A child session that the Agent announced with subagent_update is not an unknown session, although the Client did not create, load, or resume it. session/cancel can name a child as Restricted methods describes. Agents SHOULD reject any other request that names a child with -32602.
Clients SHOULD respond with -32002 when fs/read_text_file names a file that does not exist, or a terminal/* method names an unknown terminal.
Requests before initialization
Agents SHOULD reject any request other thaninitialize that arrives before initialization completes with -32600.
Unstable features
session/forkof a session that does not exist gets-32002, as for unknown sessions.session/statusof a session the Agent does not know gets-32002, withdata.sessionIdset to the requested ID. A session that exists but isn’t loaded is not an error. The Agent reports its status.session/archiveandsession/unarchiveof a session that does not exist get-32002. Unlikesession/delete, they don’t succeed silently. Anarchivedfilter value the Agent does not support gets-32602. See Archived Sessions.session/set_titleof a session that does not exist gets-32002. The session doesn’t have to be loaded. A title the Agent rejects gets-32602.