Files
PaperClipAI/packages/paperclip-runner/spec/fixtures/pre-flat-tool-input-schemas.json
DottaandClaude Opus 5.5 df1b12ad8e fix(runner): advertise flat tool schemas and stop repeated runner-side input rejections (#21398)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents act through Paperclip tools. The runner shows each tool to
the model with an input schema and checks every call against that schema
before it runs
> - Some tool schemas had a root `oneOf`, `anyOf`, `allOf` or
`if`/`then`. `handoff_case` had no top-level `properties` at all
> - Some model hosts convert such a schema into an empty argument list.
The model then calls the tool with no arguments, and the runner rejects
the call as "Invalid tool input"
> - The repeated-failure guard from #21360 does not see these
rejections, because they happen in the runner before the call reaches
the control plane. The model sent the same rejected call again and again
> - This pull request gives every agent-facing tool a plain object
schema with named properties, checks the old cross-field rules with
named errors, and adds a runner-side guard for identical "Invalid tool
input" rejections
> - The benefit is that models on these hosts can see and send the
arguments, and a dropped argument ends in a clear correction or a stop,
not a long loop

## Linked Issues or Issue Description

**What happened?**
In a chat eval cohort with OpenCode and
`openrouter/deepseek/deepseek-v4.1-flash-1017`, the hosts Wafer and
DigitalOcean served most model calls. In the case handoff case,
`handoff_case` arrived with no arguments on all 10 calls across two
cases. The runner rejected each one with "must have required property
idempotencyKey, case, toAgentId, ...". The model's reasoning said that
the tool showed an empty property list. The model fell back to
`call_api`, but the reply waiter had already expired, so the case
failed. In the preserve-draft case, `request_human_input` was rejected 9
times in a row with the same root `then` error.

**Expected behavior**
Every tool that an agent sees has a plain object schema with named
properties, so every host can show its arguments. When the same call is
rejected twice with the same arguments, the model gets a correction that
lists the expected properties. On the third identical call, the model is
told to change the arguments or stop.

**Paperclip version or commit**
`master` at f7ddab8e94.

**Steps to reproduce**
1. Run an OpenCode agent with
`openrouter/deepseek/deepseek-v4.1-flash-1017`, where OpenRouter routes
to Wafer or DigitalOcean.
2. Ask the agent to hand a case to another agent with `handoff_case`.
3. See `handoff_case` arrive with no arguments and get rejected on every
call.

## What Changed

- Add `providerToolSchemaShapeIssues`
(`packages/paperclip-runner/src/contracts/provider-tool-schema-shape.ts`).
It reports a root that is not `type: "object"`, has no `properties`, or
uses `oneOf`, `anyOf`, `allOf`, `not`, `if`, `then`, `else`,
`dependent*` or `$ref`.
- Add inventory tests that run this check on every agent-facing tool:
the live semantic catalog, the semantic action catalog, the Codex tool
specs, `paperclip_finish` and `paperclip_block` (runner), and the
server-only tool definitions (server). Before this change, the runner
test listed 16 entries for 8 tools: `handoff_case`,
`request_human_input`, `read_case`, `update_case`, `create_case`,
`read_workflow`, `update_workflow` and `paperclip_finish`.
- Flatten these 8 schemas. `handoff_case` is now one object with `to`
(optional, `"done"`), and `case` is one object with optional `id` and
`create`. Descriptions on the properties state which fields each variant
needs.
- Add `toolInputVariantError`
(`packages/paperclip-runner/src/contracts/tool-input-variants.ts`). It
checks the former cross-field rules and returns an error that names what
is wrong and how to send the call correctly. For example: `Invalid tool
input for handoff_case: An agent handoff requires toAgentId, phase. To
finish an existing case instead, send to: "done" with
expectedHandoffVersion and expectedIssueStatusVersion.`
- The server runs this check first in
`PaperclipRunnerToolAuthority.execute` and returns `422`. The #21360
guard therefore counts these errors too. Assigned MCP tools and
connector tools are not checked. The runner semantic dispatchers run the
same check after schema validation. The runner MCP bridges run it for
`paperclip_finish`, which never reaches the control plane.
- Add `RepeatedToolInputRejectionGuard`
(`packages/paperclip-runner/src/drivers/repeated-tool-input-rejection.ts`)
and use it in the OpenCode MCP bridge and the runner tool bridge, where
runner-side validation happens. The key is the tool, the canonical
arguments and the error text, separated per MCP session. The second
identical rejection adds the arguments that arrived and the expected
required and optional properties. The third and later identical calls
say that the call was not accepted and that the model must change the
arguments or stop and report the blocker. State is in memory, per
bridge, and capped at 64 entries.
- Regenerate `semantic-tool-contracts.json`,
`semantic-action-catalog.json`, `protocol/manifest.json` and the seeded
eval fixture.
- Add `spec/fixtures/pre-flat-tool-input-schemas.json`: the 8 strict
schemas from the previous release, for the upgrade test.

## Verification

- `cd packages/paperclip-runner && npx vitest run src/contracts
src/catalog src/protocol-actions src/semantic-tools
src/drivers/opencode/mcp-bridge.test.ts
src/drivers/runner-tool-bridge.test.ts`: all pass.
- `cd server && npx vitest run
src/services/native-runtime/tool-input-variant-admission.test.ts
src/services/native-runtime/repeated-tool-failure-guard.test.ts`: 9
passed.
- Red/green:
- The runner inventory test fails on `master` and lists the 16 entries.
It passes after the change.
- The guard test replays the recorded empty `handoff_case` call 4 times
through the real OpenCode bridge. Without the guard, the second call has
no correction and the test fails. With the guard, the second call lists
`required idempotencyKey, case, instructions; optional to, toAgentId,
phase, ...`, and the third says the call was not accepted.
- Negative controls: changed arguments get a fresh error, and a valid
call still runs once.
- Upgrade safety: `tool-input-variants.test.ts` compiles the previous
release's strict schemas from the fixture. For a corpus of valid and
invalid inputs per tool (27 for `handoff_case`), it checks that "flat
schema accepts and `toolInputVariantError` is null" gives exactly the
same result as the old schema. Each tool has accepted and rejected
inputs.
- Generated outputs: `check:semantic-contracts`,
`check:capability-contract`, `check:protocol-coverage`,
`check:capability-inventory`, `check:protocol-manifest` and the replay
golden check pass.
- Rust tests that read the generated contract: see the CI `runner`
checks.
- Paid narrow run: see the comment below.

## Risks

- Previous-release story: tool schemas are not saved run identity. The
OpenCode bridge lists tools again when a session resumes. A durable Rust
run that is already attached keeps the tool catalog it saved, because
re-attaching the same run does not replace the catalog. Every input the
old strict schemas accepted is still accepted, and every input they
rejected is still rejected, so saved calls, receipts and replays carry
forward. No session is reset, and no profile version or provider
`commandDigest` changes. The pack `contractDigest` changes because
`generated/` changed, as it does for any tool contract change.
- A rejected variant now arrives later for the semantic tools: the
server returns `422` instead of the runner bridge rejecting it. The
error text names the problem.
- For `paperclip_finish` on Codex, the advertised schema no longer has
the root conditional. The Rust bridge accepts a `done` result with a
continuation object, and canonical result validation still rejects it,
as before.
- Latency: the advertised schemas of the 8 tools are 1,876 bytes smaller
(23,785 to 21,909), about 470 fewer prompt tokens when all are listed.
Compiling their validators in the bridge takes 164 ms instead of 214 ms
(median of 15). The guard adds one SHA-256 of the canonical arguments
for each rejected call only. Nothing is added before turn start.

## Model Used

- Claude (Anthropic), model ID `claude-opus-5-5`, used through Claude
Code with tool use and code execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 12:08:58 -06:00

1453 lines
36 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"schema": "paperclip.test.pre-flat-tool-input-schemas.v1",
"source": "origin/master f7ddab8e94",
"tools": {
"handoff_case": {
"oneOf": [
{
"additionalProperties": false,
"allOf": [
{
"if": {
"properties": {
"case": {
"properties": {
"create": {}
},
"required": [
"create"
],
"type": "object"
}
},
"required": [
"case"
]
},
"then": {
"oneOf": [
{
"properties": {
"workflowId": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
}
},
"required": [
"workflowId"
]
},
{
"properties": {
"workflow_document_text": {}
},
"required": [
"workflow_document_text"
]
}
]
}
},
{
"not": {
"properties": {
"workflowId": {},
"workflow_document_text": {}
},
"required": [
"workflowId",
"workflow_document_text"
]
}
}
],
"properties": {
"bindIssueId": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
},
"case": {
"oneOf": [
{
"additionalProperties": false,
"properties": {
"id": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
}
},
"required": [
"id"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"create": {
"additionalProperties": false,
"properties": {
"caseType": {
"maxLength": 120,
"minLength": 1,
"type": "string"
},
"fields": {
"additionalProperties": true,
"type": "object"
},
"projectId": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": [
"string",
"null"
]
},
"summary": {
"maxLength": 8000,
"type": "string"
},
"title": {
"maxLength": 500,
"minLength": 1,
"type": "string"
}
},
"required": [
"caseType",
"title"
],
"type": "object"
}
},
"required": [
"create"
],
"type": "object"
}
]
},
"expectedHandoffVersion": {
"minimum": 0,
"type": "integer"
},
"expectedIssueStatusVersion": {
"minimum": 0,
"type": "integer"
},
"idempotencyKey": {
"maxLength": 240,
"minLength": 1,
"type": "string"
},
"initialDocuments": {
"description": "Initial Markdown documents for a newly created primary task. Keys are trimmed and lowercased; duplicates after normalization are rejected. The workflow text and normalized optional document bodies must total at most 200000 characters. The workflow key is reserved. Never creates case-owned documents.",
"items": {
"additionalProperties": false,
"properties": {
"body": {
"description": "Ordinary task document input limit. The server applies ordinary task body normalization and enforces the combined 200000-character kickoff limit.",
"maxLength": 524288,
"type": "string"
},
"key": {
"description": "Canonical task document key; lowercase letters, numbers, underscore or hyphen.",
"maxLength": 64,
"minLength": 1,
"not": {
"const": "workflow"
},
"pattern": "^[a-z0-9][a-z0-9_-]*$",
"type": "string"
},
"title": {
"maxLength": 200,
"minLength": 1,
"type": "string"
}
},
"required": [
"key",
"title",
"body"
],
"type": "object"
},
"maxItems": 20,
"type": "array"
},
"instructions": {
"maxLength": 20000,
"minLength": 1,
"type": "string"
},
"phase": {
"maxLength": 120,
"minLength": 1,
"type": "string"
},
"toAgentId": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
},
"workflowId": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": [
"string",
"null"
]
},
"workflow_document_text": {
"description": "Workflow instructions as nonblank text. Recommend Markdown with both a fenced Mermaid stateDiagram-v2 diagram and prose for each transition. Use stable state IDs matching phase names; define each named arrow outcome in prose with its trigger or condition, required evidence or outputs, destination agent ID, human wait and resume behavior, and bounded correction, retry or escalation rules. The diagram is advisory. Required for a new case or its first workflow task unless workflowId is supplied; omit on later handoffs. Stored unchanged as the ordinary task document key workflow, title Workflow. The server does not parse the flow or enforce transitions. Combined workflow text and normalized initial document bodies must total at most 200000 characters.",
"maxLength": 200000,
"minLength": 1,
"pattern": "\\S",
"type": "string"
}
},
"required": [
"idempotencyKey",
"case",
"toAgentId",
"phase",
"instructions"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"case": {
"additionalProperties": false,
"properties": {
"id": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
}
},
"required": [
"id"
],
"type": "object"
},
"expectedHandoffVersion": {
"minimum": 0,
"type": "integer"
},
"expectedIssueStatusVersion": {
"minimum": 0,
"type": "integer"
},
"idempotencyKey": {
"maxLength": 240,
"minLength": 1,
"type": "string"
},
"instructions": {
"maxLength": 20000,
"minLength": 1,
"type": "string"
},
"phase": {
"const": "done",
"default": "done",
"type": "string"
},
"to": {
"const": "done",
"type": "string"
}
},
"required": [
"to",
"idempotencyKey",
"case",
"instructions",
"expectedHandoffVersion",
"expectedIssueStatusVersion"
],
"type": "object"
}
],
"type": "object"
},
"request_human_input": {
"additionalProperties": false,
"if": {
"properties": {
"interactionKind": {
"const": "questions"
}
},
"required": [
"interactionKind"
]
},
"properties": {
"continuationPolicy": {
"enum": [
"none",
"wake_assignee",
"wake_assignee_on_accept"
]
},
"idempotencyKey": {
"description": "Caller-stable retry key.",
"maxLength": 240,
"minLength": 1,
"type": "string"
},
"interactionKind": {
"enum": [
"confirmation",
"checkbox",
"questions",
"suggest_tasks",
"item_verdicts"
]
},
"payload": {
"additionalProperties": true,
"description": "Kind-specific interaction data. For questions, send one complete questionSet containing every text and choice question. Paperclip generates compatibility questions. Each canonical question needs id, prompt, required, and answerMode: text, single_select, or multi_select. Text questions have no options or customAnswer. Choice questions need at least two meaningful options with id/label. Use customAnswer:{enabled:true} for an optional written answer to a choice question. Legacy questions remain supported; if both representations are supplied, they must describe the same complete form. Keep IDs stable across retries. For required output quality review, confirmation payload must contain qualityReview:{key:<required deliverable key>} and target:{type:issue_document,key:<output document key>,revisionId:<saved revision>} or target:{type:issue_attachment,attachmentId,assetId,sha256}. For item_verdicts put qualityReview and target on each reviewed item. Keep supersedeOnUserComment:false inside payload. Never discard these bindings to work around a validation error; an unbound confirmation cannot satisfy required quality review.",
"properties": {
"qualityReview": {
"additionalProperties": false,
"properties": {
"key": {
"pattern": "^[a-z][a-z0-9_-]{0,79}$",
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
},
"questionSet": {
"additionalProperties": false,
"properties": {
"description": {
"maxLength": 100000,
"type": "string"
},
"questions": {
"items": {
"additionalProperties": false,
"allOf": [
{
"if": {
"properties": {
"answerMode": {
"const": "text"
}
},
"required": [
"answerMode"
]
},
"then": {
"not": {
"required": [
"customAnswer"
]
},
"properties": {
"options": {
"maxItems": 0,
"type": "array"
}
}
}
},
{
"if": {
"properties": {
"answerMode": {
"enum": [
"single_select",
"multi_select"
]
}
},
"required": [
"answerMode"
]
},
"then": {
"not": {
"required": [
"initialText"
]
},
"properties": {
"options": {
"minItems": 1,
"type": "array"
}
},
"required": [
"options"
]
}
}
],
"properties": {
"answerMode": {
"enum": [
"single_select",
"multi_select",
"text"
]
},
"customAnswer": {
"additionalProperties": false,
"properties": {
"enabled": {
"const": true
},
"label": {
"maxLength": 1000,
"type": "string"
},
"placeholder": {
"maxLength": 1000,
"type": "string"
}
},
"required": [
"enabled"
],
"type": "object"
},
"header": {
"maxLength": 1000,
"type": "string"
},
"helpText": {
"maxLength": 4000,
"type": "string"
},
"id": {
"maxLength": 160,
"minLength": 1,
"type": "string"
},
"initialText": {
"description": "Editable draft of at most 100000 Unicode code points. Never an implicit answer; submitted text still uses the existing response bounds.",
"maxLength": 100000,
"type": "string"
},
"options": {
"items": {
"additionalProperties": false,
"properties": {
"description": {
"maxLength": 4000,
"type": "string"
},
"id": {
"maxLength": 160,
"minLength": 1,
"type": "string"
},
"label": {
"maxLength": 1000,
"minLength": 1,
"type": "string"
},
"recommended": {
"type": "boolean"
}
},
"required": [
"id",
"label"
],
"type": "object"
},
"maxItems": 128,
"type": "array"
},
"prompt": {
"maxLength": 4000,
"minLength": 1,
"type": "string"
},
"required": {
"type": "boolean"
},
"textValidation": {
"additionalProperties": false,
"properties": {
"inputType": {
"enum": [
"text",
"number",
"integer"
]
},
"maxLength": {
"maximum": 100000,
"minimum": 0,
"type": "integer"
},
"maximum": {
"type": "number"
},
"minLength": {
"maximum": 100000,
"minimum": 0,
"type": "integer"
},
"minimum": {
"type": "number"
},
"pattern": {
"maxLength": 1000,
"type": "string"
}
},
"type": "object"
}
},
"required": [
"id",
"prompt",
"required",
"answerMode"
],
"type": "object"
},
"maxItems": 64,
"minItems": 1,
"type": "array"
},
"schema": {
"const": "paperclip.question_set.v1"
},
"submitLabel": {
"maxLength": 200,
"type": "string"
},
"title": {
"maxLength": 1000,
"type": "string"
}
},
"required": [
"schema",
"questions"
],
"type": "object"
},
"questions": {
"items": {
"additionalProperties": true,
"properties": {
"id": {
"maxLength": 160,
"minLength": 1,
"type": "string"
},
"options": {
"items": {
"additionalProperties": true,
"properties": {
"freeText": {
"type": "boolean"
},
"id": {
"maxLength": 160,
"minLength": 1,
"type": "string"
},
"label": {
"maxLength": 1000,
"minLength": 1,
"type": "string"
}
},
"required": [
"id",
"label"
],
"type": "object"
},
"maxItems": 129,
"minItems": 1,
"type": "array"
},
"prompt": {
"maxLength": 4000,
"minLength": 1,
"type": "string"
},
"required": {
"type": "boolean"
},
"selectionMode": {
"enum": [
"single",
"multi"
]
}
},
"required": [
"id",
"prompt",
"selectionMode",
"options"
],
"type": "object"
},
"maxItems": 64,
"minItems": 1,
"type": "array"
},
"supersedeOnUserComment": {
"type": "boolean"
},
"target": {
"additionalProperties": true,
"description": "Exact registered output identity. Use an output document revision or immutable attachment for quality review; a plan does not qualify.",
"type": [
"object",
"null"
]
},
"version": {
"description": "Optional. Paperclip stores version 1; you may omit it.",
"enum": [
1,
"1"
]
}
},
"type": "object"
},
"prompt": {
"description": "Question or decision prompt.",
"maxLength": 10000,
"minLength": 1,
"type": "string"
},
"resolverPolicy": {
"const": "human_only",
"description": "Optionally require an authenticated human response. Required output-quality bindings also enforce this server-side."
},
"targetRevisionId": {
"description": "Optional bound document revision.",
"maxLength": 20000,
"type": [
"string",
"null"
]
},
"title": {
"description": "Interaction card title.",
"maxLength": 300,
"minLength": 1,
"type": "string"
}
},
"required": [
"idempotencyKey",
"interactionKind",
"title",
"prompt",
"continuationPolicy"
],
"then": {
"properties": {
"payload": {
"anyOf": [
{
"required": [
"questionSet"
]
},
{
"required": [
"questions"
]
}
]
}
},
"required": [
"payload"
]
},
"type": "object"
},
"read_case": {
"additionalProperties": false,
"allOf": [
{
"if": {
"properties": {
"offsetBytes": {
"minimum": 1,
"type": "integer"
}
},
"required": [
"offsetBytes"
]
},
"then": {
"properties": {
"snapshot": {}
},
"required": [
"snapshot"
]
}
},
{
"else": {
"properties": {
"documentIssueId": false,
"documentKey": false
}
},
"if": {
"properties": {
"section": {
"const": "document"
}
},
"required": [
"section"
]
},
"then": {
"properties": {
"documentKey": {}
},
"required": [
"documentKey"
]
}
},
{
"if": {
"properties": {
"documentIssueId": {}
},
"required": [
"documentIssueId"
]
},
"then": {
"properties": {
"documentKey": {
"maxLength": 64,
"pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
"type": "string"
}
}
}
}
],
"properties": {
"caseId": {
"description": "Case ID. Omit to use the active task's primary workflow case.",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
},
"documentIssueId": {
"description": "Only with section=document: owning primary/currently linked task ID from the case reference. Omit for a historical case-owned document; arbitrary tasks are denied.",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
},
"documentKey": {
"description": "Required only with section=document. Historical case document keys retain their original case. Task keys use at most 64 letters, numbers, underscore or hyphen and normalize to lowercase.",
"maxLength": 120,
"minLength": 1,
"pattern": "^[A-Za-z0-9_.:-]+$",
"type": "string"
},
"limitBytes": {
"description": "Maximum UTF-8 bytes per JSON text page; defaults to 8192.",
"maximum": 8192,
"minimum": 4,
"type": "integer"
},
"offsetBytes": {
"description": "UTF-8 continuation offset from readPage.nextOffsetBytes. Nonzero offsets require snapshot.",
"maximum": 9007199254740991,
"minimum": 0,
"type": "integer"
},
"section": {
"description": "Select full case JSON, entire fields JSON, or exact referenced document JSON. Explicit selectors return JSON text pages.",
"enum": [
"case",
"fields",
"document"
],
"type": "string"
},
"snapshot": {
"description": "Copy readPage.snapshot on continuation. If current data or routing changed, restart at offset zero after the conflict.",
"pattern": "^[a-f0-9]{64}$",
"type": "string"
}
},
"type": "object"
},
"update_case": {
"additionalProperties": false,
"anyOf": [
{
"properties": {
"title": {}
},
"required": [
"title"
]
},
{
"properties": {
"summary": {}
},
"required": [
"summary"
]
},
{
"properties": {
"fields": {}
},
"required": [
"fields"
]
}
],
"properties": {
"caseId": {
"description": "Case ID. Omit to use the active task's primary workflow case.",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
},
"fields": {
"additionalProperties": true,
"type": "object"
},
"idempotencyKey": {
"description": "Retry key scoped to this admitted run. Reuse with exactly the same input after a lost response. A new run does not replay this receipt; inspect current state first.",
"maxLength": 240,
"minLength": 1,
"type": "string"
},
"summary": {
"maxLength": 8000,
"type": [
"string",
"null"
]
},
"title": {
"maxLength": 500,
"minLength": 1,
"type": "string"
}
},
"required": [
"idempotencyKey"
],
"type": "object"
},
"create_case": {
"additionalProperties": false,
"oneOf": [
{
"properties": {
"workflowId": {}
},
"required": [
"workflowId"
]
},
{
"properties": {
"workflow_document_text": {}
},
"required": [
"workflow_document_text"
]
}
],
"properties": {
"caseType": {
"maxLength": 120,
"minLength": 1,
"type": "string"
},
"fields": {
"additionalProperties": true,
"type": "object"
},
"idempotencyKey": {
"maxLength": 240,
"minLength": 1,
"type": "string"
},
"initialDocuments": {
"description": "Initial Markdown documents for a newly created primary task. Keys are trimmed and lowercased; duplicates after normalization are rejected. The workflow text and normalized optional document bodies must total at most 200000 characters. The workflow key is reserved. Never creates case-owned documents.",
"items": {
"additionalProperties": false,
"properties": {
"body": {
"description": "Ordinary task document input limit. The server applies ordinary task body normalization and enforces the combined 200000-character kickoff limit.",
"maxLength": 524288,
"type": "string"
},
"key": {
"description": "Canonical task document key; lowercase letters, numbers, underscore or hyphen.",
"maxLength": 64,
"minLength": 1,
"not": {
"const": "workflow"
},
"pattern": "^[a-z0-9][a-z0-9_-]*$",
"type": "string"
},
"title": {
"maxLength": 200,
"minLength": 1,
"type": "string"
}
},
"required": [
"key",
"title",
"body"
],
"type": "object"
},
"maxItems": 20,
"type": "array"
},
"kickoff": {
"additionalProperties": false,
"properties": {
"instructions": {
"maxLength": 20000,
"minLength": 1,
"type": "string"
},
"phase": {
"maxLength": 120,
"minLength": 1,
"type": "string"
},
"toAgentId": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
}
},
"required": [
"toAgentId",
"phase",
"instructions"
],
"type": "object"
},
"projectId": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": [
"string",
"null"
]
},
"summary": {
"maxLength": 8000,
"type": "string"
},
"title": {
"maxLength": 500,
"minLength": 1,
"type": "string"
},
"workflowId": {
"description": "Adopt this company workflow’s latest prompt.",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
},
"workflow_document_text": {
"description": "Workflow instructions as nonblank text. Recommend Markdown with both a fenced Mermaid stateDiagram-v2 diagram and prose for each transition. Use stable state IDs matching phase names; define each named arrow outcome in prose with its trigger or condition, required evidence or outputs, destination agent ID, human wait and resume behavior, and bounded correction, retry or escalation rules. The diagram is advisory. Required for a new case or its first workflow task unless workflowId is supplied; omit on later handoffs. Stored unchanged as the ordinary task document key workflow, title Workflow. The server does not parse the flow or enforce transitions. Combined workflow text and normalized initial document bodies must total at most 200000 characters.",
"maxLength": 200000,
"minLength": 1,
"pattern": "\\S",
"type": "string"
}
},
"required": [
"idempotencyKey",
"caseType",
"title",
"kickoff"
],
"type": "object"
},
"read_workflow": {
"additionalProperties": false,
"allOf": [
{
"if": {
"properties": {
"responseText": {
"properties": {
"offsetBytes": {
"minimum": 1,
"type": "integer"
}
},
"required": [
"offsetBytes"
],
"type": "object"
}
},
"required": [
"responseText"
]
},
"then": {
"properties": {
"snapshot": {}
},
"required": [
"snapshot"
]
}
}
],
"properties": {
"responseText": {
"additionalProperties": false,
"properties": {
"limitBytes": {
"maximum": 24576,
"minimum": 4,
"type": "integer"
},
"offsetBytes": {
"maximum": 9007199254740991,
"minimum": 0,
"type": "integer"
}
},
"type": "object"
},
"snapshot": {
"description": "Content fingerprint returned by the first page; required for continuation pages.",
"pattern": "^[a-f0-9]{64}$",
"type": "string"
},
"workflowId": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
}
},
"required": [
"workflowId"
],
"type": "object"
},
"update_workflow": {
"additionalProperties": false,
"anyOf": [
{
"properties": {
"name": {}
},
"required": [
"name"
]
},
{
"properties": {
"prompt": {}
},
"required": [
"prompt"
]
}
],
"properties": {
"idempotencyKey": {
"maxLength": 240,
"minLength": 1,
"type": "string"
},
"name": {
"maxLength": 200,
"minLength": 1,
"type": "string"
},
"prompt": {
"description": "Reusable Markdown instructions for LLM execution. Phases and routing are advisory instructions, not a state machine.",
"maxLength": 200000,
"minLength": 1,
"pattern": "\\S",
"type": "string"
},
"workflowId": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"type": "string"
}
},
"required": [
"workflowId",
"idempotencyKey"
],
"type": "object"
},
"paperclip_finish": {
"type": "object",
"additionalProperties": true,
"required": [
"reportedWorkDisposition",
"summary",
"completionClaim",
"evidence",
"verification"
],
"properties": {
"schema": {
"enum": [
"paperclip.run_result.v1",
"paperclip_finish",
"paperclip_paperclip_finish",
"paperclip_finish.v1"
]
},
"summary": {
"type": "string",
"minLength": 1,
"description": "The complete user-facing answer for this turn. Do not replace the requested answer with routine work/control bookkeeping. Include the requested result and any genuine actionable failure, limitation, or required user action. Unless explicitly requested, omit routine preparation, unconfirmed-delivery, and wait/review status; put the response-wake reason in continuation.summary. Never claim delivery without a confirmed receipt."
},
"completionClaim": {
"type": "object",
"additionalProperties": false,
"required": [
"contractRevision",
"objectiveSatisfied",
"criteria",
"remainingWork"
],
"properties": {
"contractRevision": {
"type": "string",
"minLength": 1,
"description": "Use the current turn completion.revision (or completionContract.revision on the first turn), never a previous turn’s revision. On stale-revision feedback, reassess the current request and correct the report without repeating completed work."
},
"objectiveSatisfied": {
"type": "boolean"
},
"criteria": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"criterionId",
"status",
"evidenceRefs"
],
"properties": {
"criterionId": {
"type": "string",
"minLength": 1
},
"status": {
"enum": [
"satisfied",
"not_satisfied",
"unknown",
"pass",
"passed",
"complete",
"completed",
"fail",
"failed",
"incomplete"
],
"description": "Use satisfied when the criterion is met, not_satisfied when it is not met, or unknown when no verdict is available. Common provider aliases are accepted and normalized."
},
"evidenceRefs": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"remainingWork": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"description",
"blocksCompletion"
],
"properties": {
"description": {
"type": "string",
"minLength": 1
},
"blocksCompletion": {
"type": "boolean"
}
}
}
}
}
},
"evidence": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"ref"
],
"properties": {
"ref": {
"type": "string",
"minLength": 1
}
}
}
},
"verification": {
"type": "array",
"description": "Checks used to verify the work. Use failed only when the check actually ran and found a defect in the work. If a check could not run or complete because the environment, tool, dependency, permission, credential, policy, external service, or budget was unavailable, use not_run with reasonCode even when the attempted command exited non-zero.",
"items": {
"type": "object",
"additionalProperties": true,
"required": [
"status"
],
"properties": {
"commandOrCheck": {
"type": "string",
"minLength": 1
},
"command": {
"type": "string",
"minLength": 1
},
"status": {
"enum": [
"passed",
"failed",
"not_run",
"blocked",
"skipped",
"pass",
"success",
"succeeded",
"fail"
],
"description": "passed: the check ran and succeeded. failed: the check ran to a meaningful verdict and found the work incorrect. not_run: no meaningful verdict because the check was not attempted or could not complete. Prefer not_run over legacy blocked/skipped, and include reasonCode for any unavailable check."
},
"reasonCode": {
"enum": [
"environment_unavailable",
"tool_unavailable",
"dependency_missing",
"permission_denied",
"credential_missing",
"policy_restricted",
"external_service_unavailable",
"budget_exhausted",
"other"
],
"description": "Required for not_run; identify why the check had no meaningful verdict."
},
"detail": {
"type": "string"
},
"result": {
"type": "string"
},
"cwd": {
"type": "string"
},
"artifactRef": {
"type": [
"string",
"null"
],
"description": "Reference to a real verification artifact. Omit or use null when no artifact exists; empty values are normalized away."
}
}
}
},
"attentionRequests": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true,
"required": [
"kind",
"summary"
],
"properties": {
"kind": {
"type": "string",
"minLength": 1
},
"summary": {
"type": "string",
"minLength": 1
},
"ownerClass": {
"enum": [
"human",
"agent",
"external_system"
]
},
"targetAgentId": {
"type": "string",
"minLength": 1
},
"requestedCapability": {
"type": "string",
"minLength": 1
},
"requiredAuthority": {
"type": "string",
"minLength": 1
},
"target": {
"type": "object",
"additionalProperties": true
}
}
}
},
"artifacts": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"kind",
"ref"
],
"properties": {
"kind": {
"type": "string",
"minLength": 1
},
"ref": {
"type": "string",
"minLength": 1
}
}
}
},
"reportedWorkDisposition": {
"enum": [
"done",
"needs_review",
"yielded",
"completed"
]
},
"continuation": {
"type": [
"object",
"null"
],
"description": "For yielded, omit or use null to reuse this run's authorized published-review wait, eligible saved monitor, or repository-preparation continuation; the controller reads current task state. Otherwise provide a real response_wake or monitor with summary and idempotencyKey. Use null or omit for done, completed, or needs_review.",
"additionalProperties": false,
"required": [
"kind",
"summary",
"idempotencyKey"
],
"properties": {
"kind": {
"type": "string",
"enum": [
"response_wake",
"monitor",
"case_handoff"
]
},
"summary": {
"type": "string",
"minLength": 1,
"description": "Internal control-plane reason to wait for the next response. Keep routine waiting and continuation bookkeeping here, not in the top-level user-facing summary. This field is not the answer to the user's request."
},
"idempotencyKey": {
"type": "string",
"minLength": 1
},
"handoffId": {
"type": "string",
"minLength": 1,
"description": "Exact server-issued handoff ID; required for case_handoff."
}
},
"allOf": [
{
"if": {
"properties": {
"kind": {
"const": "case_handoff"
}
},
"required": [
"kind"
]
},
"then": {
"required": [
"handoffId"
]
}
}
]
}
},
"if": {
"properties": {
"reportedWorkDisposition": {
"const": "yielded"
}
},
"required": [
"reportedWorkDisposition"
]
},
"then": {
"properties": {
"continuation": {
"type": [
"object",
"null"
]
}
}
},
"else": {
"properties": {
"continuation": {
"type": "null"
}
}
}
}
}
}