agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
60 lines • 2.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnsupportedThinkingError = void 0;
/**
* UnsupportedThinkingError — a thinking request the provider/model pair cannot honor,
* refused by name BEFORE anything is sent.
*
* Models on one wire disagree about thinking (see `ThinkingMode`), and the
* vendor's answer to the wrong shape is an HTTP 400 on every call — one that
* names the vendor's field, not the library setting that produced it. So the
* refusal happens here instead, with the fix in the message:
*
* - at `Agent.build()`, when the provider DECLARES (`LLMProvider.thinkingMode`)
* that thinking is unsupported for a model the agent will call (`reason: 'no-thinking'`);
* - in the adapter, before the request leaves, for a model chosen at run time
* and for the combinations the wire rejects whenever thinking is on
* (`'budget'`, `'temperature'`, `'forced-tool-choice'`).
*
* `retryable: false` — asking again sends the same request — so `withRetry`'s
* default policy never retries it; `withFallback` does not move the call to
* its other side and `withCircuitBreaker` does not count it, by default —
* the request is wrong, not the vendor.
*
* @example
* ```ts
* import { UnsupportedThinkingError } from 'agentfootprint/providers';
*
* try {
* agent = Agent.create({ provider, model }).thinking({ budget: 4000 }).build();
* } catch (err) {
* if (err instanceof UnsupportedThinkingError) console.error(err.model, err.reason);
* }
* ```
*/
class UnsupportedThinkingError extends Error {
/** The provider that answered for the model — `'anthropic'`, `'browser-anthropic'`, … */
provider;
/** The model the request named. */
model;
/**
* Why the request cannot be sent:
* - `'no-thinking'` — thinking is unsupported by the provider/model pair;
* - `'budget'` — the budget is not one the model's `budget_tokens` accepts;
* - `'temperature'` — a temperature other than the default, which the wire
* rejects while thinking is on;
* - `'forced-tool-choice'` — a forced tool choice, which budget thinking rejects.
*/
reason;
/** Asking again cannot mend it — read by `withRetry`'s default predicate. */
retryable = false;
constructor(args) {
super(`[${args.provider}] thinking on '${args.model}': ${args.detail}`);
this.name = 'UnsupportedThinkingError';
this.provider = args.provider;
this.model = args.model;
this.reason = args.reason;
}
}
exports.UnsupportedThinkingError = UnsupportedThinkingError;
//# sourceMappingURL=errors.js.map