Plugin Protocol
Status: 2026-11-16, api v1. The wire protocol between the Host and a process plugin, for writing one in any language. The method table is pkg/plugin/rpc/spec.go; the JSON Schemas i
Status: 2026-11-16, api v1. The wire protocol between the Host and a process plugin, for writing one in any language. The method table is pkg/plugin/rpc/spec.go; the JSON Schemas in schemas/protocol/v1 are generated from it. Back to the guide index; building and shipping a plugin is in plugin development.
1. Transport
| Item | Rule |
|---|---|
| Channel | The process's stdin (Host → plugin) and stdout (plugin → Host) |
| Messages | JSON-RPC 2.0, UTF-8 JSON |
| Framing | Content-Length: N\r\n\r\n followed by N bytes, as in LSP; the header name is case-insensitive |
| Size | At most 32 MiB per message (MaxFrame) and 64 KiB per header line; larger frames or longer lines end the connection. A peer serves at most 256 requests at once; one past them gets error -32000 rpc: too many requests at once (Feishu #256) |
| stderr | Kept in the Host log, line by line, redacted, at most 8 MiB per process |
| Start | process.command for the Host's os/arch, relative to the plugin directory, started without a shell |
| Working directory | The plugin directory |
| Environment | Only PATH, HOME, USER, LANG, LC_ALL, TMPDIR, TZ (on Windows also SystemRoot, ComSpec, PATHEXT, TEMP, TMP, USERPROFILE, LOCALAPPDATA); configuration comes through initialize |
Both sides send requests on the same connection. Each side numbers its own request ids; a reply carries the id of the request it answers. A plugin must keep reading while it handles a request, because the Host may answer a callback or send $/cancel meanwhile.
2. Lifecycle
Host starts the process ──► initialize ──► role methods … (callbacks both ways) ──► shutdown ──► stdin closed
▲ │ crash
└──── restart after 2^n s (max 1 min) ◄─┘- Start. The Host starts the process when the instance loads.
initialize(15 s limit). The Host sends the instance's id, configuration, data directory and option values. The plugin answers with its manifest and the optional methods it implements. The Host refuses the process ifname,versionorrolesdiffer fromplugin.yaml; a plugin built with the Go SDK refuses anapiit does not serve (errorrpc.api).- Role methods and callbacks, concurrently.
shutdown(2 s), then stdin is closed and the process is stopped.- Crash. Calls in flight fail. The Host restarts the process on the next need, waiting 2, 4, 8 … seconds up to one minute after repeated start failures, and answers
plugin.restartingmeanwhile. A tool call whose outcome is unknown is recorded as unknown in the ledger and reported to the model; it is never replayed blindly. A long tool (long: true) is called again with the samekeyand must be idempotent by it.
3. Calls, Callbacks and call_id
A role method that may need the Host carries a call_id: tool/invoke, runtime/execute, delivery/deliver, transport/start, service/serve, observer/observe, parser/parse. (model/chat carries one only to tag the model/delta notifications of a streamed reply.) A callback (host/*) must carry that call_id; the Host runs it with the authority of that call (its run, principal and uses) and only while the call is in flight. Each callback is allowed only within the calls named in its within column (section 7); elsewhere the Host answers the plugin error rpc.not_allowed.
| within | Calls |
|---|---|
caller | Any call that has a call_id: tool/invoke, runtime/execute, and the background calls |
background | Those, plus service/serve and observer/observe |
tool | tool/invoke |
runtime | runtime/execute |
transport | transport/start |
delivery | delivery/deliver |
parser | parser/parse |
Notifications have no id and get no reply: $/cancel (either side, {"id": <request id>}, cancels that request; the receiver may already have acted) and model/delta (a model plugin streams {"call_id", "text", "kind"} while answering a streamed model/chat; kind is text, the default when it is absent, reasoning or tool_args, so a plugin that sends none streams text).
4. Errors
| JSON-RPC code | Meaning |
|---|---|
-32601 | Method not found. For an optional method not listed in initialize, the Host does not call it |
-32603 | Internal error: the result could not be encoded |
-32000 | Plugin error. With data {"code", "message", "retryable", "not_sent"} it is classified; without data (any other failure, including a panic in a Go SDK handler) it is not |
Use stable dotted codes, <namespace>.<reason> (notes.failed, rail.sold_out). retryable: true lets the Host retry the same operation later; not_sent: true says the operation certainly had no external effect. An error without data counts as retryable with an unknown outcome. Logic never parses message.
5. Data Conventions
| Item | Rule |
|---|---|
| Field names | snake_case, as in the schemas |
| Unknown fields | Ignore them; newer peers add fields within v1 |
| Omitted fields | Fields not marked required in a schema may be absent; arrays and maps may also be null |
| Bytes | base64 strings (data of artifacts and fetched files) |
| Times | RFC 3339 strings |
| Free JSON | args, config, parameters and checkpoints are any JSON value |
| Text for people | Rendered by the Host's locale files; text for models is English |
6. Versioning
The version is api in plugin.yaml and in initialize; the Host serves v1. Within v1 changes are additive only: new optional fields, new optional methods (announced in InitializeResult.optional), new callbacks. Anything that would break an existing plugin needs a new api version, served next to v1.
7. Methods
A guard's Args (guard/rewrite), Messages and Content (guard/before_model, guard/after_model) take effect only for an instance the operator gives grants: [rewrite] (ADR 0005); otherwise the Host ignores them and logs it.
7.1 Host → plugin
| Method | Role | Optional | Params | Result | Schema |
|---|---|---|---|---|---|
initialize | — | InitializeParams | InitializeResult | initialize.json | |
shutdown | — | {} | {} | shutdown.json | |
tool/list | tool | ContextParams | []ToolSpec | tool.list.json | |
tool/invoke | tool | InvokeParams | ToolResult | tool.invoke.json | |
skill/list | skill | ContextParams | []SkillCard | skill.list.json | |
skill/load | skill | SkillLoadParams | SkillDoc | skill.load.json | |
guard/check | guard | GuardParams | GuardDecision | guard.check.json | |
guard/check_input | guard | yes | GuardInputParams | GuardDecision | guard.check_input.json |
guard/check_result | guard | yes | GuardResultParams | ResultDecision | guard.check_result.json |
guard/check_completion | guard | yes | GuardCompletionParams | CompletionDecision | guard.check_completion.json |
guard/rewrite | guard | yes | GuardParams | RewriteDecision | guard.rewrite.json |
guard/filter_tools | guard | yes | GuardToolsParams | ToolFilterDecision | guard.filter_tools.json |
guard/before_model | guard | yes | GuardModelParams | ModelDecision | guard.before_model.json |
guard/after_model | guard | yes | GuardModelParams | ModelDecision | guard.after_model.json |
guard/check_step | guard | yes | GuardStepParams | StepDecision | guard.check_step.json |
reviewer/review | reviewer | GuardParams | ReviewDecision | reviewer.review.json | |
context/get | context | ContextGetParams | []ContextItem | context.get.json | |
compactor/compact | compactor | CompactParams | CompactRecord | compactor.compact.json | |
processor/process | context_processor | ProcessParams | []ViewEdit | processor.process.json | |
observer/observe | observer | ObserveParams | {} | observer.observe.json | |
observer/before_compact | observer | yes | FlushParams | FlushResult | observer.before_compact.json |
service/serve | service | HostParams | {} (returns when cancelled) | service.serve.json | |
model/chat | model | ChatParams | ChatResponse | model.chat.json | |
trigger/match | trigger | TriggerInput | Decision | trigger.match.json | |
presentation/present | presentation | Output | []Item | presentation.present.json | |
runtime/execute | runtime | ExecuteParams | Result | runtime.execute.json | |
delivery/deliver | delivery | DeliverParams | Receipt | delivery.deliver.json | |
transport/start | transport | HostParams | {} (returns when cancelled) | transport.start.json | |
transport/fetch | transport | FetchParams | FetchResult | transport.fetch.json | |
parser/parse | parser | ParserParseParams | media.Document | parser.parse.json |
Plugin → Host notification: model/delta (DeltaParams, model.delta.json). Either side: $/cancel (CancelParams, cancel.json).
7.2 Plugin → Host (callbacks)
| Method | Within | Params | Result | Schema |
|---|---|---|---|---|
host/tools | caller | HostParams | []ToolSpec | host.tools.json |
host/call_tool | caller | HostCallToolParams | ToolResult | host.call_tool.json |
host/chat | background | HostChatParams | ChatResponse | host.chat.json |
host/embed | background | HostEmbedParams | [][]float32 | host.embed.json |
host/put_artifact | caller | HostPutArtifactParams | ArtifactRef | host.put_artifact.json |
host/parse | caller | HostParseParams | media.Document | host.parse.json |
host/read_artifact | parser | HostReadArtifactParams | HostReadArtifactResult | host.read_artifact.json |
host/open_artifact | delivery | HostTextParams | HostArtifactResult | host.open_artifact.json |
host/skills | caller | HostParams | []SkillCard | host.skills.json |
host/load_skill | caller | HostLoadSkillParams | SkillDoc | host.load_skill.json |
host/context_items | caller | HostContextParams | []ContextItem | host.context_items.json |
host/report_spans | caller | HostSpansParams | {} | host.report_spans.json |
host/check_completion | caller | HostCompletionParams | []string | host.check_completion.json |
host/progress | runtime | HostTextParams | {} | host.progress.json |
host/ask | tool or runtime | HostAskParams | Answer | host.ask.json |
host/checkpoint | runtime | HostStateParams | {} | host.checkpoint.json |
host/commit | runtime | HostCommitParams | {} | host.commit.json |
host/session_entries | runtime | HostEntriesParams | []Entry | host.session_entries.json |
host/compact | caller | HostCompactParams | CompactRecord | host.compact.json |
host/process_context | caller | HostProcessParams | []ProcessorEdits | host.process_context.json |
host/before_compact | caller | HostFlushParams | []string | host.before_compact.json |
host/check_step | caller | HostStepParams | StepResult | host.check_step.json |
host/send | runtime | HostSendParams | {} | host.send.json |
host/read_tool_result | runtime | HostReadResultParams | ResultPage | host.read_tool_result.json |
host/remind | tool | HostRemindParams | {} | host.remind.json |
host/take_reminders | runtime | HostParams | []Reminder | host.take_reminders.json |
host/submit | transport | HostEventParams | {} | host.submit.json |
host/answer | transport | HostAnswerParams | AnswerResult | host.answer.json |
host/locale | transport | HostParams | string | host.locale.json |
host/run_for_event | transport | HostTextParams | HostRunResult | host.run_for_event.json |
host/run | transport | HostTextParams | RunView | host.run.json |
host/cancel_run | transport | HostTextParams | {} | host.cancel_run.json |
host/link_start | caller | HostParams | string | host.link_start.json |
host/link_finish | caller | HostTextParams | {} | host.link_finish.json |
host/secret_get | caller | HostSecretParams | HostSecretResult | host.secret_get.json |
host/secret_put | caller | HostSecretParams | {} | host.secret_put.json |
host/secret_delete | caller | HostSecretParams | {} | host.secret_delete.json |
host/resolve_secret | tool | HostTextParams | string | host.resolve_secret.json |
The meaning of each role method and its limits are in plugin development §6 and the hook reference; the parser role's two methods, their limits and failures are in parser protocol.
8. Examples
Frames are shown without their Content-Length header. → is Host to plugin, ← plugin to Host. The context object (CallContext) is the trusted context the Host fills; it is shortened after the first example.
initialize
1→ {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"api":"v1","id":"notes","config":{"blocked_words":["secret"]},
2 "data_dir":"/var/orquelo/data/notes","options":{}}}
3← {"jsonrpc":"2.0","id":1,"result":{"manifest":{"name":"notes-python","version":"0.1.0","roles":["tool","guard","context","skill"]},
4 "optional":[]}}tool/list
1→ {"jsonrpc":"2.0","id":2,"method":"tool/list","params":{"context":{"run_id":"rn_7f3a","caller":"agent",
2 "principal":{"id":"pr_1","tenant":"default","connection":"feishu","external_id":"ou_ab","role":"user","user":"us_1"},
3 "conversation":{"id":"oc_1","kind":"direct"},"connection":"feishu","chain":["agent"],"session":"ss_9"}}}
4← {"jsonrpc":"2.0","id":2,"result":[{"name":"note_add","description":"Save one short note for later.",
5 "parameters":{"type":"object","properties":{"text":{"type":"string"}},"required":["text"]}}]}tool/invoke with a callback in between
1→ {"jsonrpc":"2.0","id":3,"method":"tool/invoke","params":{"call_id":"c12","call":{"name":"note_add",
2 "args":{"text":"the code is BLUE"},"key":"tc_4be1a9c0d2","context":{"run_id":"rn_7f3a","caller":"agent","…":"…"}}}}
3← {"jsonrpc":"2.0","id":1,"method":"host/remind","params":{"call_id":"c12","kind":"notes","text":"A note was saved."}}
4→ {"jsonrpc":"2.0","id":1,"result":{}}
5← {"jsonrpc":"2.0","id":3,"result":{"content":"Saved."}}The plugin's callback uses its own id sequence (1), independent of the Host's (3).
guard/check
→ {"jsonrpc":"2.0","id":4,"method":"guard/check","params":{"context":{"…":"…"},
"intent":{"name":"bash","args":{"command":"echo secret"},"provider":"files","key":"tc_9d02"}}}
← {"jsonrpc":"2.0","id":4,"result":{"deny":true,"reason":"the word 'secret' is blocked by notes-python"}}A guard may instead answer {"ask":true,"reason":"…","approver":"admin"} to require a person's approval.
context/get
→ {"jsonrpc":"2.0","id":5,"method":"context/get","params":{"context":{"…":"…"},"input":{"text":"what did I note?","locale":"zh-CN"}}}
← {"jsonrpc":"2.0","id":5,"result":[{"title":"Saved notes","content":"1 notes are saved; use note_list to read them."}]}skill/load
→ {"jsonrpc":"2.0","id":6,"method":"skill/load","params":{"context":{"…":"…"},"name":"take-notes"}}
← {"jsonrpc":"2.0","id":6,"result":{"content":"When the user asks you to remember something, call `note_add` …"}}$/cancel
→ {"jsonrpc":"2.0","method":"$/cancel","params":{"id":3}}An error reply
← {"jsonrpc":"2.0","id":6,"error":{"code":-32000,"message":"no skill named 'x'",
"data":{"code":"notes.failed","message":"no skill named 'x'"}}}9. Conformance
| Tool | Use |
|---|---|
schemas/protocol/v1 | One JSON Schema 2020-12 file per method (params, result) and index.json (method, direction, role, optional, notification, within). Generated from pkg/plugin/rpc/spec.go by go test ./pkg/plugin/rpc -update; a test fails when they drift from the code. Use them to generate types or to validate messages |
plugins/notes-python | A complete reference plugin in Python, standard library only; TestPythonPlugin runs it against the Go suites |
orquelo plugin test [-config JSON] [-options JSON] DIR | -options gives the plugin's option values as an instance's options, resolved and expanded as the Host does (a URL with ${option.api_key} is tested with the key). Starts the plugin in DIR and runs the suite of each declared role over this protocol; prints PASS/FAIL per suite and exits non-zero on failure. Added together with this guide |