Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion capabilities/reasoning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ A definition whose `output.shape` names an [output shape](../../packages/definit

A reasoning function whose front matter names `tools` (each `server/tool`, or `server/*`) runs with the tools of the tool servers configured for its playbook, MCP servers and HTTP APIs alike. `makeReasoningFunctionAdapter` takes the server's `ToolAccess` from [`@on.auto/tool-servers`](../../packages/tool-servers) as `tools`, as a type only: it imports the helpers it needs to parse `tools` and bound a run from `@on.auto/tool-servers/policy`, which loads no transport code; `tools` is required, and a test with no tool server gives `noToolServers` of `@on.auto/tool-servers/testing`; with no server configured, a function that names tools is rejected as `unavailable`, kind `tool_not_offered`, in the words of `namedLinks`. The adapter then says it may change something outside (`mayChangeOutside`), so `run_definition` is destructive. The capability declares as the stream kind it owns `tool-calls`, with the presenter of `@on.auto/tool-servers`, `handCallPresenter`, since the server serves `execute`, which calls a tool as a run of a reasoning function would, beside it: the playbook shows each call made by hand in its events, under the types of a run's calls, `tool_call_started`, `tool_call_answered` and `tool_call_failed`, on a stream of its own whose kind tells it from a run's, as the declarations allow, since a stream kind is checked apart from the facts of a run.

A function that names tools calls tools (`callsTools`), so the start of its run records that, and a run of it that is still `started` is not run again under its id. A run first admits its request with the model's `admit`, so a run whose model is not offered reaches no server and starts no process; it then opens its tools with its id, org, playbook and journal before the model is called, and rejects as `unavailable` with kind `tool_not_offered` (because `tool_server_not_configured`, `tool_not_allowed` or `tool_not_listed`, or for a connection a person added `connection_pending`, `connection_broken` or `connection_not_allowed`) or `tool_server_failed` (because `unreachable`, `failing` or `rate_limited`). Otherwise the request carries `tools`: the offered tools under their model-facing names, `server__tool`, with their input schemas unchanged, whether the calls have ended, a signal that ends them, the bound of the whole run, the most input tokens its model calls may add up to, `mostInputTokens`, and the model's context window, `contextWindow`, where the catalog knows it. Both come from the adapter's `reading`, a `ModelReading` the server gives: `mostInputTokens` from `REASONING_MAX_INPUT_TOKENS`, 2,000,000 unless set (`defaultMostInputTokens`), and `contextWindowOf`, the catalog's `contextWindowOf`, which resolves the model's alias and reads the `context_window` its provider lists for it, through the listing's cache; a run without tools reads no window, and a test that gives no `reading` has the default bound and no window. In the adapter, the AI SDK's loop:
A function that names tools calls tools (`callsTools`), so the start of its run records that, and a run of it that is still `started` is not run again under its id. A run first admits its request with the model's `admit`, so a run whose model is not offered reaches no server and starts no process; it then opens its tools with its id, org, playbook and journal before the model is called, and rejects as `unavailable` with kind `tool_not_offered` (because `tool_server_not_configured`, `tool_not_allowed` or `tool_not_listed`, or for a connection a person added `connection_pending`, `connection_broken`, `connection_not_allowed` or `connection_unavailable`) or `tool_server_failed` (because `unreachable`, `failing` or `rate_limited`). Otherwise the request carries `tools`: the offered tools under their model-facing names, `server__tool`, with their input schemas unchanged, whether the calls have ended, a signal that ends them, the bound of the whole run, the most input tokens its model calls may add up to, `mostInputTokens`, and the model's context window, `contextWindow`, where the catalog knows it. Both come from the adapter's `reading`, a `ModelReading` the server gives: `mostInputTokens` from `REASONING_MAX_INPUT_TOKENS`, 2,000,000 unless set (`defaultMostInputTokens`), and `contextWindowOf`, the catalog's `contextWindowOf`, which resolves the model's alias and reads the `context_window` its provider lists for it, through the listing's cache; a run without tools reads no window, and a test that gives no `reading` has the default bound and no window. In the adapter, the AI SDK's loop:

- gives the model the tools in the function's own output mode, text or JSON, beside the `json` tool the Anthropic and Bedrock providers add for a JSON output they do not take in the output mode itself (`@ai-sdk/anthropic` 4.0.70 and `@ai-sdk/amazon-bedrock` 5.0.103 name it `json`), a name with no `__`, so no tool of a tool server takes it (`src/tools/tool-loop.test.ts` pins both), and returns each answer to the model as a tool result, an error result for a tool error, giving each call the room its answer has (`src/tools/turn-meter.ts`): the step is measured where the AI SDK announces it, the bytes of its instructions, messages and tools as it starts, and the input and output tokens the provider counted and the tool calls it holds as it ends, before any tool runs; the step's own bytes a token, its bytes sent over its input tokens, turn the room into bytes, the smaller of the window and what `mostInputTokens` leaves after every step made, less the step's input and output tokens, shared equally by the step's calls, so an answer the model's context cannot hold is cut where it stays valid JSON, with a note, and read whole when no window is known or the provider counted no input tokens; nothing is taken from the window for the output, since the catalog's window is the most input tokens a model takes;
- gives every model call its own deadline, the request's `timeout_ms`, which the time the tools take does not count against, armed when the call starts and ended however it settles, even when the AI SDK reports no end for a call that threw, and bounds the whole run by ten minutes, or one call's deadline when that is longer;
Expand Down
29 changes: 20 additions & 9 deletions docs/assets/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1165,9 +1165,10 @@
"key_refused",
"connection_pending",
"connection_broken",
"connection_not_allowed"
"connection_not_allowed",
"connection_unavailable"
],
"description": "key_refused when the server did not accept the key this server gives it, which only whoever runs this server can put right; failing, rate_limited or unreachable when asking again later may work; connection_pending when nobody has approved the connection yet, connection_broken when its credential cannot be read, so it is removed and added again, and connection_not_allowed when a rule of whoever runs this server no longer allows it"
"description": "key_refused when the server did not accept the key this server gives it, which only whoever runs this server can put right; failing, rate_limited or unreachable when asking again later may work; connection_pending when nobody has approved the connection yet, connection_broken when its credential is gone from the secret store or is not the tokens of a consent, its consent was revoked or has ended, or its client is no longer registered, so it is removed and added again, connection_not_allowed when a rule of whoever runs this server no longer allows it, and connection_unavailable when its credential cannot be read just now, so asking again later may work"
}
},
"required": [
Expand Down Expand Up @@ -6807,6 +6808,7 @@
"connection_pending",
"connection_broken",
"connection_not_allowed",
"connection_unavailable",
"failing",
"rate_limited",
"unreachable",
Expand All @@ -6823,7 +6825,7 @@
"not_in_order",
"baseline_check"
],
"description": "Why. With model_not_offered: provider_not_configured when its provider is not set up on this server while others are, model_not_allowed when it is outside the models the operator allows. With tool_not_offered: tool_server_not_configured, tool_not_allowed or tool_not_listed, or connection_pending, connection_broken or connection_not_allowed for a connection a person added. With tool_server_failed: failing, rate_limited, unreachable or key_refused. With tools_unfinished: server_failed, tool_error, model_unavailable, run_bound or no_answer"
"description": "Why. With model_not_offered: provider_not_configured when its provider is not set up on this server while others are, model_not_allowed when it is outside the models the operator allows. With tool_not_offered: tool_server_not_configured, tool_not_allowed or tool_not_listed, or connection_pending, connection_broken, connection_not_allowed or connection_unavailable for a connection a person added. With tool_server_failed: failing, rate_limited, unreachable or key_refused. With tools_unfinished: server_failed, tool_error, model_unavailable, run_bound or no_answer"
}
},
"required": [
Expand Down Expand Up @@ -6879,6 +6881,7 @@
"connection_pending",
"connection_broken",
"connection_not_allowed",
"connection_unavailable",
"failing",
"rate_limited",
"unreachable",
Expand Down Expand Up @@ -7211,6 +7214,7 @@
"connection_pending",
"connection_broken",
"connection_not_allowed",
"connection_unavailable",
"failing",
"rate_limited",
"unreachable",
Expand All @@ -7227,7 +7231,7 @@
"not_in_order",
"baseline_check"
],
"description": "Why. With model_not_offered: provider_not_configured when its provider is not set up on this server while others are, model_not_allowed when it is outside the models the operator allows. With tool_not_offered: tool_server_not_configured, tool_not_allowed or tool_not_listed, or connection_pending, connection_broken or connection_not_allowed for a connection a person added. With tool_server_failed: failing, rate_limited, unreachable or key_refused. With tools_unfinished: server_failed, tool_error, model_unavailable, run_bound or no_answer"
"description": "Why. With model_not_offered: provider_not_configured when its provider is not set up on this server while others are, model_not_allowed when it is outside the models the operator allows. With tool_not_offered: tool_server_not_configured, tool_not_allowed or tool_not_listed, or connection_pending, connection_broken, connection_not_allowed or connection_unavailable for a connection a person added. With tool_server_failed: failing, rate_limited, unreachable or key_refused. With tools_unfinished: server_failed, tool_error, model_unavailable, run_bound or no_answer"
}
},
"required": [
Expand Down Expand Up @@ -7283,6 +7287,7 @@
"connection_pending",
"connection_broken",
"connection_not_allowed",
"connection_unavailable",
"failing",
"rate_limited",
"unreachable",
Expand Down Expand Up @@ -7630,6 +7635,7 @@
"connection_pending",
"connection_broken",
"connection_not_allowed",
"connection_unavailable",
"failing",
"rate_limited",
"unreachable",
Expand All @@ -7646,7 +7652,7 @@
"not_in_order",
"baseline_check"
],
"description": "Why. With model_not_offered: provider_not_configured when its provider is not set up on this server while others are, model_not_allowed when it is outside the models the operator allows. With tool_not_offered: tool_server_not_configured, tool_not_allowed or tool_not_listed, or connection_pending, connection_broken or connection_not_allowed for a connection a person added. With tool_server_failed: failing, rate_limited, unreachable or key_refused. With tools_unfinished: server_failed, tool_error, model_unavailable, run_bound or no_answer"
"description": "Why. With model_not_offered: provider_not_configured when its provider is not set up on this server while others are, model_not_allowed when it is outside the models the operator allows. With tool_not_offered: tool_server_not_configured, tool_not_allowed or tool_not_listed, or connection_pending, connection_broken, connection_not_allowed or connection_unavailable for a connection a person added. With tool_server_failed: failing, rate_limited, unreachable or key_refused. With tools_unfinished: server_failed, tool_error, model_unavailable, run_bound or no_answer"
}
},
"required": [
Expand Down Expand Up @@ -7702,6 +7708,7 @@
"connection_pending",
"connection_broken",
"connection_not_allowed",
"connection_unavailable",
"failing",
"rate_limited",
"unreachable",
Expand Down Expand Up @@ -8096,6 +8103,7 @@
"connection_pending",
"connection_broken",
"connection_not_allowed",
"connection_unavailable",
"failing",
"rate_limited",
"unreachable",
Expand Down Expand Up @@ -9857,9 +9865,10 @@
"key_refused",
"connection_pending",
"connection_broken",
"connection_not_allowed"
"connection_not_allowed",
"connection_unavailable"
],
"description": "key_refused when the server did not accept the key this server gives it, which only whoever runs this server can put right; failing, rate_limited or unreachable when asking again later may work; connection_pending when nobody has approved the connection yet, connection_broken when its credential cannot be read, so it is removed and added again, and connection_not_allowed when a rule of whoever runs this server no longer allows it"
"description": "key_refused when the server did not accept the key this server gives it, which only whoever runs this server can put right; failing, rate_limited or unreachable when asking again later may work; connection_pending when nobody has approved the connection yet, connection_broken when its credential is gone from the secret store or is not the tokens of a consent, its consent was revoked or has ended, or its client is no longer registered, so it is removed and added again, connection_not_allowed when a rule of whoever runs this server no longer allows it, and connection_unavailable when its credential cannot be read just now, so asking again later may work"
}
},
"required": [
Expand Down Expand Up @@ -10429,9 +10438,10 @@
"key_refused",
"connection_pending",
"connection_broken",
"connection_not_allowed"
"connection_not_allowed",
"connection_unavailable"
],
"description": "Why it could not be asked: key_refused when it did not accept the key this server gives it, which only whoever runs this server can put right; failing, rate_limited or unreachable when asking again later may work; connection_not_allowed when a rule of whoever runs this server no longer allows the connection"
"description": "Why it could not be asked: key_refused when it did not accept the key this server gives it, which only whoever runs this server can put right; failing, rate_limited or unreachable when asking again later may work; connection_not_allowed when a rule of whoever runs this server no longer allows the connection; connection_unavailable when the credential of the connection cannot be read just now, so asking again later may work"
}
},
"required": [
Expand Down Expand Up @@ -12171,6 +12181,7 @@
"connection_pending",
"connection_broken",
"connection_not_allowed",
"connection_unavailable",
"failing",
"rate_limited",
"unreachable",
Expand Down
Loading
Loading