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 b075c93
Browse filesBrowse the repository at this point in the historyBrowse files
hzq
committed
Preserve Responses history when caller tools change
Keep the original function declarations and ordered native items, while restricting new calls to the active tools. Append newly available published functions after their confirmed return and require a worker that advertises the matching Responses codec.
Improvement-Round: 7/10 after v0.0.73
Copy file name to clipboardExpand all lines: docs/harness.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -167,6 +167,7 @@ Key points:
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
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
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.
170
+
- With the **OpenAI Responses provider**, disabling caller tools keeps the original declarations and ordered reasoning, function calls and confirmed results. The worker sends `tool_choice: "none"` if nothing is callable, or [`allowed_tools`](https://developers.openai.com/api/docs/guides/function-calling) to restrict the existing catalog. When a published function first becomes available after a forced caller turn, the worker appends a developer [`additional_tools` item](https://developers.openai.com/api/docs/guides/tools-tool-search#add-tools-at-a-specific-point-in-the-input) after the return. This requires endpoint support; a rejection does not trigger another request with stripped history. Inspect the original run instead of executing the caller tool again. A model-returned declaration is not execution permission.
170
171
- 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.
171
172
- 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.
172
173
- 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.
Copy file name to clipboardExpand all lines: docs/protocol.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -420,9 +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`, `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.
423
+
`welcome.features` is now `execution-capabilities-v1`, `byok-v1`, `sandbox-v1`, `provider-turn-v1`, `bridge-tool-replay-v1`, `bridge-tool-replay-v2`, `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
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.
425
+
With `bridge-tool-replay-v1`, `execution.bridgeReplayProviders` covers Anthropic Messages only. A worker that also negotiates `bridge-tool-replay-v2` can report the codec for each provider alias in `execution.bridgeReplayProtocols` (for example, `{"local":"openai-responses"}`). A Responses transition requires an exact match; a v1 claim for the same alias is not enough. Older peers can still handle ordinary turns. If no eligible worker can replay the change, the run is interrupted with `provider_state_unsupported`; resume that run after upgrading rather than resubmitting its confirmed tool result.
426
426
427
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.
428
428
@@ -756,7 +756,7 @@ Error codes and response shapes do not depend on language; only the text of `mes
756
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) |
757
757
|`client_tools_too_many`| 400 | Published tools plus caller tools exceed 100 |
758
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 |
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 |
759
+
|`tool_choice_unmet`| 422 | An Anthropic Messages or OpenAI Responses 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 |
760
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 |
761
761
|`invalid_json`| 400 | The request body is not valid JSON, or is empty while declared as JSON |
762
762
|`payload_too_large`| 413 | The request body or data exceeds the size limit |
0 commit comments