Skip to content

InvestigationBehavior ​

ts
type InvestigationBehavior = object;

Prompts, argument sanitization, and which built-in tools and outcomes the AI may use.

Properties ​

prompt? ​

ts
optional prompt?: string | ((ctx) => string);

Replaces the default user prompt. A function receives the investigation context with args already passed through sanitizeArgs.


systemPrompt? ​

ts
optional systemPrompt?: string;

Replaces the default system prompt.


sanitizeArgs? ​

ts
optional sanitizeArgs?: (args) => unknown[];

Transforms the call's arguments before they go into the prompt, default or custom.

Parameters ​

args ​

unknown[]

Returns ​

unknown[]


allowMethodSource? ​

ts
optional allowMethodSource?: boolean;

Whether the default prompt includes the method's code (InvestigationContext.methodSource), so the AI can see what the failed call was meant to do. It is sent to the provider (after redactConfig), so leave it off if your code must not leave your infrastructure.

Default Value ​

false


allowSafeToolbox? ​

ts
optional allowSafeToolbox?: boolean;

Whether the AI may also call the tools in trypatch's built-in safe toolbox (waiting, reading truncated parts of the failed call, encoding/decoding) alongside AiInvestigationOptions.investigationTools.

Default Value ​

true


allowDirectResultCreation? ​

ts
optional allowDirectResultCreation?: boolean;

Whether the AI may return a result directly, versus only via AiInvestigationOptions.resultTools/AiInvestigationOptions.customErrors.

Default Value ​

true


allowCannotDetermine? ​

ts
optional allowCannotDetermine?: boolean;

Whether the AI may report that there isn't enough information to work out a correct return value. Ends the investigation with TrypatchCannotDetermineError, which is logged; the method then rethrows its original error.

Default Value ​

true


allowUncertainResult? ​

ts
optional allowUncertainResult?: boolean;

Whether the AI may report that a plausible return value exists but its confidence in it is too low to return it, instead of guessing. Ends the investigation with TrypatchUncertainResultError, which is logged; the method then rethrows its original error.

Default Value ​

true


allowNoApplicableOutcome? ​

ts
optional allowNoApplicableOutcome?: boolean;

Whether the AI may report that none of the configured outcomes actually fit the situation. Ends the investigation with TrypatchNoApplicableOutcomeError, which is logged; the method then rethrows its original error.

Default Value ​

true