You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit eade0cb
Browse filesBrowse the repository at this point in the historyBrowse files
hzq
committed
Resume Anthropic bridge runs across verified tool policy changes
Verify historical declarations separately from the current tool offer. Preserve accepted results on restart, reject disallowed plans before dispatch, and negotiate replay support with workers.
Improvement-Round: 6/10 after v0.0.73
Copy file name to clipboardExpand all lines: docs/compatibility.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,7 +110,7 @@ A request that declares `tools` and chooses no mode is handled as `auto` (docs/h
110
110
111
111
* An agent that can take the tools over (a kernel agent, Codex, Claude Code, Antigravity ACP, or an ACP adapter) gets them: its calls come back as `tool_calls` / `function_call` / `tool_use` / `functionCall`, the run continues from your results, and the response carries `X-OAA-Client-Tools: bridge`. This is what coding agents and agent frameworks (Cline, Roo Code, Continue, Zed, the OpenAI Agents SDK, LangChain, the Vercel AI SDK, ...) need, on the ordinary Base URL, without a header.
112
112
* An agent that cannot (DSH, A2A, HTTP adapters) behaves as before. OpenAI's default endpoints refuse with `400 unsupported_parameter` (`error.param``tools`; the message gives the reason and the three ways out: the Base URL `http://<host>:8787/v1/compat`, `X-OAA-Compat: true`, `X-OAA-Client-Tools: managed`); the compat endpoints, Claude and Gemini let the agent finish with its own tools (`X-OAA-Client-Tools: ignored`).
113
-
* Tool choice (`tool_choice``auto` / `none` / `required` / a named function, Claude `tool_choice`, and Gemini `toolConfig.functionCallingConfig`) is honoured: `none`withholds caller tools for the turn; forced choices push down natively to kernel model drivers (converging back to `auto` on continuation) and enforce prompt + 1-round continuation repair on bridged external agents (failing with `422 tool_choice_unmet` if unmet, or `400 client_tools_unsupported` when `managed` / unbridgeable).
113
+
* Tool choice (`tool_choice``auto` / `none` / `required` / a named function, Claude `tool_choice`, and Gemini `toolConfig.functionCallingConfig`) is honoured: `none`disables caller-tool execution for the turn (see [historical declarations](harness.md) for Anthropic continuations); forced choices push down natively to kernel model drivers (converging back to `auto` on continuation) and enforce prompt + 1-round continuation repair on bridged external agents (failing with `422 tool_choice_unmet` if unmet, or `400 client_tools_unsupported` when `managed` / unbridgeable).
114
114
*`X-OAA-Client-Tools: managed | bridge | reject | auto` (or `metadata["oaa.client_tools"]`) chooses explicitly and is never overridden; the gateway setting `clientTools.default` changes what a request that chooses nothing gets.
Copy file name to clipboardExpand all lines: docs/harness.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ For discovery, model selection and multi-model execution see [models.md](models.
48
48
49
49
A request that declares tools and chooses no mode gets `auto` (the gateway configuration `clientTools.default` can change that default to `managed`, `bridge` or `reject`; an explicit `auto` in the header beats the configuration). The rule, with the agent known at submit time:
50
50
51
-
1. The agent can take the tools over (kernel agent, or an enabled Codex, Claude Code, Antigravity ACP, or ACP adapter with an online execution machine that declared `client-tools-v1` for it), and the tools are plain functions with names that do not collide with the agent's own: the request is handled as `bridge` (`tool_choice: "none"`withholds caller tools for that turn; forced `tool_choice` is pushed down to kernel model drivers or enforced on bridged external agents via prompt constraint plus up to 1 continuation repair round, failing with 422 `tool_choice_unmet` if still unmet). The response carries `X-OAA-Client-Tools: bridge`; the agent's calls come back as `tool_calls` / `function_call` / `tool_use` / `functionCall`.
51
+
1. The agent can take the tools over (kernel agent, or an enabled Codex, Claude Code, Antigravity ACP, or ACP adapter with an online execution machine that declared `client-tools-v1` for it), and the tools are plain functions with names that do not collide with the agent's own: the request is handled as `bridge` (`tool_choice: "none"`disables caller tools for that turn; forced `tool_choice` is pushed down to kernel model drivers or enforced on bridged external agents via prompt constraint plus up to 1 continuation repair round, failing with 422 `tool_choice_unmet` if still unmet). The response carries `X-OAA-Client-Tools: bridge`; the agent's calls come back as `tool_calls` / `function_call` / `tool_use` / `functionCall`.
52
52
2. Anything else gets what the entry did before. If a forced `tool_choice` (`required` / `any` or a named function) cannot be bridged (or `managed` was chosen), submission fails with 400 `client_tools_unsupported`. Otherwise OpenAI's default endpoints (`/v1/chat/completions`, `/v1/responses` without `X-OAA-Compat`) refuse with 400 `unsupported_parameter` (`error.param``tools`): the message says this agent cannot take the tools over, gives the reason (an engine without bridge support, no execution machine for client tools, a name collision, tools that are not functions), and names the three ways out: the Base URL `<origin>/v1/compat`, `X-OAA-Compat: true`, `X-OAA-Client-Tools: managed`. The compatibility endpoints, Claude Messages and Gemini continue as `managed` (the agent finishes with its own tools; `X-OAA-Client-Tools: ignored`).
53
53
54
54
Legacy integrations retain this auto-selection rule. DSH, A2A and HTTP native/adapter entries remain managed-only; Codex, Claude Code, ACP adapters, and Antigravity's capability-checked ACP path support `bridge`. Selecting auto never grants additional approval authority. New publication and key policies take precedence as described above.
@@ -165,6 +165,8 @@ Key points:
165
165
- The final check includes the actual system prompt for that route. If the request does not fit, already completed steps remain recorded, but no new model attempt is saved or sent. At handoff the worker request must still match the admitted conversation; the byte count and digest used for that check are not recorded in public run events.
166
166
- A newly returned tool plan must also leave room for the assistant message and **one empty reply per call**, including the call IDs. If even this minimum cannot fit, the kernel does not run a tool, ask for approval, or hand the call to a client. The model turn, its reported usage and already produced output are retained; its rejected arguments are not saved as pending work. A plan that fits can still receive a larger result later. Already accepted calls, including those restored after an upgrade, follow the normal result and recovery paths. A final answer without tools needs no further turn.
167
167
- Only a valid return with new results can change the run to `tool_choice: "none"`. A bad batch or read-only replay leaves the option and output position unchanged. If storage cannot confirm a return, inspect the original run ID rather than executing the caller tools again.
168
+
- On an Anthropic Messages continuation the historical tool declarations and the currently callable tools are distinct. If no tools remain active, the worker keeps the verified declarations for the same provider and sends `tool_choice: {"type":"none"}`. A fresh request without caller tools does not gain any. The kernel checks the entire new plan before opening a step or caller action; earlier accepted results are not undone.
169
+
- After a forced caller turn, eligible published tools can return. Plain text and ordinary `tool_use` blocks are checked against their original prefix and replayed unchanged. For a signed or otherwise opaque history that needs tools individually added or withdrawn, enable `anthropicInlineToolChanges`**only on a supporting endpoint/model**. The worker appends the protocol's tool changes after the result; without that option it interrupts with `provider_state_unsupported` rather than rewriting history. Resume the original run after restoring support, not the caller tool. The [Anthropic guidance](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/change-tools-or-instructions) distinguishes turning tools off from changing their declarations.
168
170
- Streaming (`stream: true`): when the run parks, the frames are sent in this order: the role frame (with `content: null`, if one has not been sent before), one `tool_calls` delta frame per call (`index` starting at 0), the closing frame with `finish_reason: "tool_calls"`, then (if `include_usage` was requested) the usage frame and `[DONE]`. After continuation, the stream starts from where the last one ended and does not replay earlier text.
169
171
- When the arguments the model produces do not match the caller's schema, the call is not handed to the caller. Instead `{"error":"invalid_arguments","detail":...}` is returned to the model as the tool result so that it can fix the call and try again. This differs from argument errors of published tools (`invalid_tool_arguments`, where the run fails outright): the caller's schema is not under the publisher's control.
170
172
- Names: must match `^[a-zA-Z0-9_-]{1,64}$`. The internal alias replaces `-` with `_` and prepends `t_` when the first character is not a letter; the original name is always used externally. A conflict with a published tool, workflow, delegate, `execute_graph`, or another caller tool returns `client_tool_conflict`; more than 100 published tools plus caller tools returns `client_tools_too_many`; a schema that cannot be compiled returns `invalid_client_tool`. All of these are checked before any execution. Caller tools cannot appear in `execute_graph` or in workflows.
|`anthropicInlineToolChanges`| Anthropic Messages only, off by default. Permit `inline-tools-2026-09-15` for verified tool changes in a native bridge continuation. Not needed just to turn all tools off. See [caller tools](harness.md). |
Copy file name to clipboardExpand all lines: docs/protocol.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -420,7 +420,9 @@ Revocation is not remote process attestation, deletion of previously transferred
420
420
421
421
Model `Work` may carry an optional `maxOutputTokens` (the caller's output cap, always below the published `limits.maxOutputTokens`); a worker applies the smaller of the two to the model call, and an older worker that ignores it uses the published limit. The agent definition itself stays identical to the published one.
422
422
423
-
`welcome.features` is now `execution-capabilities-v1`, `byok-v1`, `sandbox-v1`, `provider-turn-v1`, `client-tools-v1`, `image-input-v1`, `trace-context-v1`, `conversion-profiles-v1` (and `/health` additionally advertises `prometheus-metrics-v1` for `GET /metrics` and `trace-context-v1` for W3C `traceparent` / `tracestate` propagation). With `trace-context-v1` a worker accepts `WorkContext.trace` and `WorkContext.subject` (stripped automatically when dispatching to legacy workers); with `conversion-profiles-v1` a worker includes `execution.adapterProfiles` so custom remote `adapter/<name>` entries expose their real `ConversionProfile` on the gateway. With `image-input-v1` a worker reports `execution.imageInput = { providers: {<name>: "none"|"inline"|"url"}, native: {<engine>: "native"|"agent-declared"|"workspace-file"} }`; a run with images is placed only on a worker whose declaration covers its provider or engine (placement reason `image_input_unsupported`), so older workers never receive one ([images.md](images.md)). With `client-tools-v1` a worker reports `execution.clientTools = { native: ["kernel", "codex", "claude", "adapter/<acp name>", …] }`: the engines on which it can bridge caller tools (docs/harness.md). Bridged runs are placed only on workers that declared the run's engine there (placement reason `client_tools_unsupported` otherwise); when no such worker exists, submission answers `client_tools_bridge_unsupported` (400). Only those workers receive `Work.native.clientTools` and send the `client_tool` event (`data: { name, arguments, relay_call_id }`), which the gateway answers like an approval with `{ output }` or `{ error }`. Older workers and older gateways keep working; an older worker simply never receives bridged work. Every update is validated against the same node identity and credential grants as the initial registration. Idle peers also lose their registration when heartbeats expire.
423
+
`welcome.features` is now `execution-capabilities-v1`, `byok-v1`, `sandbox-v1`, `provider-turn-v1`, `bridge-tool-replay-v1`, `client-tools-v1`, `image-input-v1`, `trace-context-v1`, `conversion-profiles-v1` (and `/health` additionally advertises `prometheus-metrics-v1` for `GET /metrics` and `trace-context-v1` for W3C `traceparent` / `tracestate` propagation). With `trace-context-v1` a worker accepts `WorkContext.trace` and `WorkContext.subject` (stripped automatically when dispatching to legacy workers); with `conversion-profiles-v1` a worker includes `execution.adapterProfiles` so custom remote `adapter/<name>` entries expose their real `ConversionProfile` on the gateway. With `image-input-v1` a worker reports `execution.imageInput = { providers: {<name>: "none"|"inline"|"url"}, native: {<engine>: "native"|"agent-declared"|"workspace-file"} }`; a run with images is placed only on a worker whose declaration covers its provider or engine (placement reason `image_input_unsupported`), so older workers never receive one ([images.md](images.md)). With `client-tools-v1` a worker reports `execution.clientTools = { native: ["kernel", "codex", "claude", "adapter/<acp name>", …] }`: the engines on which it can bridge caller tools (docs/harness.md). Bridged runs are placed only on workers that declared the run's engine there (placement reason `client_tools_unsupported` otherwise); when no such worker exists, submission answers `client_tools_bridge_unsupported` (400). Only those workers receive `Work.native.clientTools` and send the `client_tool` event (`data: { name, arguments, relay_call_id }`), which the gateway answers like an approval with `{ output }` or `{ error }`. Older workers and older gateways keep working; an older worker simply never receives bridged work. Every update is validated against the same node identity and credential grants as the initial registration. Idle peers also lose their registration when heartbeats expire.
424
+
425
+
With `bridge-tool-replay-v1` a worker may also advertise `execution.bridgeReplayProviders`. Only an eligible worker with this provider-specific capability receives a history-sensitive caller-tool transition. Older peers still handle ordinary turns; when an upgrade is needed, the confirmed caller result stays on the original run.
424
426
425
427
Native execution requires the node credential to grant `native/<engine>` (or `*`), in addition to the agent alias. `oaa expose` already grants only its selected native executor. A generic adapter uses `native/adapter/<name>`. Enabled native executables are checked for local availability without starting them; declared model mappings are still not proof of account/model compatibility.
426
428
@@ -754,7 +756,7 @@ Error codes and response shapes do not depend on language; only the text of `mes
754
756
|`client_tool_conflict`| 400 | A bridged caller tool has the same name as a published tool, workflow, delegate, `execute_graph`, or another caller tool (the internal alias is compared) |
755
757
|`client_tools_too_many`| 400 | Published tools plus caller tools exceed 100 |
756
758
|`invalid_client_tool`| 400 | A caller tool's name does not match `^[a-zA-Z0-9_-]{1,64}$`, its format is wrong, or its parameter schema cannot be compiled |
757
-
|`tool_choice_unmet`| 422 |A forced `tool_choice` (`required`, `any`, or a named function) was requested in bridge mode, but the external agent still did not invoke the required caller tool after a correction round |
759
+
|`tool_choice_unmet`| 422 |An Anthropic native bridge plan did not match the forced caller-tool selection, or a bridged external agent did not meet that selection after a correction round |
758
760
|`output_schema_unsupported`| 400 | The requested output schema (`response_format`, `text.format`, `responseSchema`, `output_config.format`) contains something the gateway cannot honestly enforce: `$async`, a `$ref` outside the document, a `format` nobody implements, a very long or exponentially backtracking regular expression, nesting deeper than 40 levels; rewrite the schema |
759
761
|`invalid_json`| 400 | The request body is not valid JSON, or is empty while declared as JSON |
760
762
|`payload_too_large`| 413 | The request body or data exceeds the size limit |
@@ -964,7 +966,7 @@ Error codes and response shapes do not depend on language; only the text of `mes
964
966
|`invalid_provider_state`| 502 | The provider's native turn state (Provider Turn State) is missing, malformed, failed verification, does not match the normalized result, or the underlying SDK cannot replay it safely; this indicates corrupted or tampered state, and the caller should start a new session |
965
967
|`provider_state_mismatch`| 409 | The provider protocol, endpoint, model, tools, or conversation prefix changed on continuation, or native state was replayed across incompatible protocols; the caller must restore the original configuration or start a new session |
966
968
|`provider_state_too_large`| 413 | One turn's native state exceeds 2,000,000 bytes of UTF-8 JSON. The checked state is the snapshot used for replay. Trim the turn's output or tool data, or start a new session. |
967
-
|`provider_state_unsupported`| 502/503 | The worker node or driver cannot keep the provider's native turn state, the gateway did not negotiate native-state capability, or the streamed output contains state deltas that cannot be kept safely; the caller must route to a supported node or start a new session |
969
+
|`provider_state_unsupported`| 502/503 | The worker node or driver cannot keep the provider's native turn state, the gateway did not negotiate native-state capability, or the streamed output contains state deltas that cannot be kept safely, or the required bridge replay / inline tool-change capability is unavailable; the caller must route to a supported node or start a new session |
0 commit comments