Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

docs(agent): the failure path and the model-set refusal on the RPC page

thinhlpgce6e81140fa9
diff --git a/docs/src/pages/docs/agent/protocol.mdx b/docs/src/pages/docs/agent/protocol.mdx
index 85d442b58..cddcbb78e 100644
--- a/docs/src/pages/docs/agent/protocol.mdx
+++ b/docs/src/pages/docs/agent/protocol.mdx
@@ -77,6 +77,11 @@ of each outbound provider request (run, session, provider, model, wire API, body
hashes, image hashes) and none of its content. See
[Request provenance](/docs/agent/cli#request-provenance) for the record's fields.
+A turn whose provider request fails ends with `item/error` (`{type: "error", code, message}`, the
+provider's own words where it gave any) and then `turn/completed` with `stopReason: "error"` and the
+same message. A client must read that as the turn's outcome: the assistant text is whatever arrived
+before the failure, which is usually nothing, and no further records follow.
+
## RPC host tools
A host declares tools on `session/start`; the model calls them, Jan sends the call to the host,
@@ -138,7 +143,7 @@ turn's `turn/completed`. When stdin closes, pending requests are cancelled the s
| --- | --- | --- |
| `session/tools/get` | `{sessionId}` | `{tools, toolSpecs}` |
| `session/tools/set` | `{sessionId, tools}` | `{tools, toolSpecs}`. Replaces the host set; refusals are `invalid_tools`. |
-| `session/model/set` | `{sessionId, model}` | `{model}`. History, host tools, `builtins` and `permissions` are kept. |
+| `session/model/set` | `{sessionId, model}` | `{model}`. History, host tools, `builtins` and `permissions` are kept. A model no configured provider can serve fails here with `-32602` rather than being substituted at the next turn. |
| `session/reset` | `{sessionId}` | `{tools, toolSpecs}`. History is cleared; model and tools are kept. |
These four methods are refused while that session's turn is running: `-32001` with
@@ -148,6 +153,10 @@ and `session/archive` of a busy session, and a second `turn/start`, keep their p
tools, `builtins` and `permissions`, but pending requests are never shared between sessions.
`session/list` entries include `hostTools`, the number of declared host tools.
+`provider/model` is explicit selection: the provider is taken from the name, so a provider that
+accepts ids it does not list (a gateway, a proxy) is used as asked rather than overridden. A bare
+model id that no provider lists is refused as above.
+
Every mutating method is answered. A client that gets no answer, for example because the process
died, should treat the session as gone and close it. This fail-closed handling belongs to the SDK
or client, not the wire protocol.