code tools: “the deposit is 20% of the quote”, “a Toronto postal code starts with M”. Snippets are versioned. A published version never changes, and a tool pins one published version, so what an agent runs stays fixed until someone changes the tool.
What a snippet holds
Every run happens in an isolated sandbox with the version’s timeout. A result that does not match
output_schema is an error, and the value is never returned to anyone, the agent included.
Routes
Reading is open to every role. Creating, editing, publishing, archiving and testing need the
operator or owner role. Ids look like snip_0123456789abcdef; a snippet of another workspace answers 404 exactly like one that never existed.
A snippet reads id, object (snippet), name, description, status (active or archived), archived_at, created_at, updated_at, created_by, latest_published and draft_version (version numbers, or null). GET /v1/snippets/{snippet_id} adds versions and used_by, whose items are {"id", "name", "label", "version"} for each tool that pins it. A version reads object (snippet_version), snippet_id, version, state (draft or published), the body fields above, content_hash, created_by, created_at, updated_at, published_by and published_at; reading one version by number also carries snippet_name and snippet_archived.
Create, publish, test
POST /v1/snippets/{id}/publish takes no body. POST /v1/snippets/{id}/test takes {"version": 1, "arguments": {"quote": 100}}; version is a number or "draft", and omitting it tests the draft. The answer is a snippet_test record: object, snippet_id, version, state, status (succeeded or failed), input, output, error, error_code, and on success latency_ms and audit. A failed run answers 409 with that same record, not the error envelope. Run-time error_code values are arguments, timeout, sandbox, output_too_large, refused, schema and busy (every sandbox slot stayed taken through a short wait, and nothing ran).
Refusals
Pinning a snippet from a tool
Acode tool names a snippet and one published version:
code tool is always a tool that reads (access: read). Creating or changing a tool needs the owner role.