/** * L1-E: Autonomous continue — model-driven self-iteration continuation. * * In autonomous mode the model can signal "keep going without waiting for * user input" by either: * * 1. **Tool call** — call `continue_to_next_iteration()` with no args. * The tool returns `{ continue: true }` and sets * `ctx.meta._autonomousContinue = true`. The agent loop detects this * flag and re-runs the iteration instead of returning. * * 2. **Text marker** — include one of the below markers on its own line * in the final text output (no tool call required): * * - `[continue]` — same as calling the tool; next iteration * - `[next step]` — synonym for `[continue]` * - `[proceed]` — synonym for `[continue]` * - `[done]` — stop iterating; return to caller * * The parser matches `^\s*(?:\[continue\]|\[next step\]|\[proceed\]|\[done\])\s*$` * so the marker must occupy its own line (possibly indented). * * Text markers are checked in `processResponse()` BEFORE the loop exit * condition, so the model can emit `[continue]` as part of its final text * block and the loop re-runs seamlessly. * * The `_autonomousContinue` flag lives in `ctx.meta` — it is cleared at * the start of each iteration so a stale flag from a prior run cannot * cause spurious continuation. * * @example * ```typescript * // Enable autonomous continuation on the Agent * const agent = new Agent({ * // ... other options * autonomousContinue: true, // enable text-marker parsing * }); * * // The model can now end a response with: * // [continue] * // and the agent will immediately start the next iteration without * // returning to the caller. * ``` */ import type { Context } from './context.js'; import type { Tool } from '../types/tool.js'; /** * Directive emitted by the model to control the autonomous loop. * * `continue` — halt the current agent.run() and signal to the outer * runner (e.g. AutonomousRunner) that it should re-invoke * agent.run() immediately with a fresh continuation prompt. * * `stop` — halt and signal the outer runner to NOT continue. * The agent.run() returns `{ status: 'done' }` as normal. * * `none` — no directive present; outer runner uses its own * `doneCondition` to decide. */ export type ContinueDirective = 'continue' | 'stop' | 'none'; /** * Parse a `ContinueDirective` from raw assistant text. * * Matches markers on their own line (with optional leading/trailing * whitespace). Case-insensitive. Returns `'none'` when no marker found. * * The marker must be on its own line to avoid false positives — e.g. * "remember to use [continue] in your next email" does NOT trigger it. */ export declare function parseContinueDirective(text: string): ContinueDirective; /** * Set the autonomous continue flag in the context. * Called by `makeContinueToNextIterationTool` when the model invokes it. */ export declare function setAutonomousContinue(ctx: Context): void; /** * Clear the autonomous continue flag at the start of each iteration. * Called from `Agent.run()` before the loop body. */ export declare function clearAutonomousContinue(ctx: Context): void; /** * Read and clear the autonomous continue flag in one call. * Returns `true` if the flag was set; `false` otherwise. */ export declare function consumeAutonomousContinue(ctx: Context): boolean; /** * Built-in tool that lets the model explicitly request the next iteration. * * When called, the agent loop detects the flag and re-runs instead of * returning to the caller. This is the explicit counterpart to the * `[continue]` text marker. * * The tool has no side effects and returns `{ continue: true }`. */ export declare function makeContinueToNextIterationTool(): Tool; //# sourceMappingURL=continue-to-next-iteration.d.ts.map