@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
35 lines • 2.16 kB
TypeScript
import type { ModelMessage, ToolCallStatus } from './types.js';
/**
* What a store knows about a tool call, read back when its message carries no result for it — see
* {@link import('./spi/agent-store.js').AgentStore.toolCallOutcomes}.
*/
export interface ToolCallOutcome {
id: string;
status: ToolCallStatus;
output?: unknown;
error?: string;
}
/** What the model is told about a call whose turn died before the call was settled. */
export declare const UNFINISHED_TOOL_CALL: string;
/** What is written on the row of a call whose run ended without settling it. */
export declare const RUN_ENDED_BEFORE_TOOL_CALL = "the run ended before this tool call was settled";
/** The ids of every tool call in `messages` that the message asking for it holds no result for. */
export declare function danglingToolCallIds(messages: readonly ModelMessage[]): string[];
/**
* Give every tool call in a thread's history a result.
*
* A turn writes its results onto the assistant message once the step's LAST tool has settled. A turn
* that dies before that — its run failed, its worker was killed, an approval was never answered and
* the run was abandoned — leaves an assistant message that asks for tools and is answered by
* nothing. A provider refuses a prompt shaped like that (a tool call must be followed by its
* result), so every LATER turn on the thread fails too, with an error about the stream rather than
* about the history: one dead turn makes the whole conversation unusable.
*
* Here each such call is settled from what is actually known: the call's own row where the store
* can read it (`outcomes` — a tool that DID run hands the model its real output, so it is not run a
* second time), and otherwise a result saying the call was never completed. Pure: the same messages
* and outcomes always produce the same prompt, so a replay composes what the first attempt did.
* Messages with nothing dangling are returned as they are.
*/
export declare function settleDanglingToolCalls(messages: ModelMessage[], outcomes?: readonly ToolCallOutcome[]): ModelMessage[];
//# sourceMappingURL=dangling-tool-calls.d.ts.map