defineTool
function defineTool<S, R>(config): Tool<InferToolInput<S>, R>;Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
|
|
|
|
|
|
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
{ |
‐ |
|
|
|
‐ |
|
|
|
|
|
|
( |
‐ |
|
|
|
|
|
|
( |
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
( |
Turns a thrown error into a result the model can act on, instead of a generic failure. Return a value to recover; rethrow (or omit this) to let the error propagate. Runs only for genuine failures — never for a timeout, an abort, an input/output schema violation, or a control-flow signal, all of which must stay distinguishable from a result the tool chose to return. |
|
|
|
‐ |
|
|
|
Safe to run concurrently with sibling calls in the same model-emitted batch. A function form receives the RAW (unvalidated) model args — classification happens before schema validation — and must not throw; a throw or a non-boolean return is treated as NOT parallel-safe. Never model-controlled: the model cannot assert this, only the tool author. |
|
|
|
‐ |
|
|
|
‐ |
Returns
Section titled “Returns”Tool<InferToolInput<S>, R>