UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

34 lines (33 loc) • 2.89 kB
import type { AgentTool, SessionTreeEntry } from "../../internal/harness-types.js"; import type { Model } from "../../internal/llm.js"; import { type AdvisorFailure, type AdvisorOutcome } from "../advisor-verdict.js"; import type { CompactionForkContext } from "../auto-compaction.js"; import { type SideQueryResult } from "../side-query.js"; import type { Brain, TaskSpec } from "../types.js"; /** The advisor's own system prompt (the agent's system prompt follows it, marked as context). */ export declare const ADVISOR_SYSTEM_PROMPT = "You are the advisor: a stronger reviewer model consulted by an agent in the middle of its task. Above is the agent's conversation as it stood in the agent's last request \u2014 its task, every tool call it made and every result it saw \u2014 ending at the point where it asked for advice.\n\nReply in plain text only. Do not call tools: any tool call you make is discarded and counts as no answer. Be concrete and short: name the decision the agent is facing, say what you would do and why, point at the specific evidence in the conversation that supports it, and flag anything the agent has assumed without checking. If the agent asked before declaring the task done, review the deliverable against the task as stated and list what is missing or wrong. If something you need is not in the conversation, say what is missing and what the agent should check first \u2014 that is still guidance."; /** The closing result the projection ends on: the asking call is answered, so both wire protocols take the list. */ export declare const ADVISOR_HANDOFF = "You are the advisor now. Review everything above and reply with your guidance."; /** Everything one leg's advisor needs: the advisor model, the lane's accounted brain, and the leg's own readers. */ export interface AdvisorSeat { readonly model: Model; readonly brain: Brain; /** The request the main lane last sent on this leg (the engine-level context, before provider serialization). */ readonly lastSentRequest: () => CompactionForkContext | undefined; readonly readBranch: () => Promise<ReadonlyArray<SessionTreeEntry>>; readonly getApiKeyAndHeaders: TaskSpec["getApiKeyAndHeaders"]; /** Marks the run's totals a lower bound: a thrown request spent an amount nobody learned. */ readonly markUsageUnknown: () => void; } /** The `tool_end.structured` card of one advisor call. */ export interface AdvisorCard extends AdvisorFailure { readonly type: "advisor"; readonly outcome: AdvisorOutcome; readonly model: string; readonly servedModel?: string; readonly stopReason?: string; readonly hold?: true; readonly usage?: SideQueryResult["usage"]; } /** The leg's `advisor` tool over its seat; its label is the advisor model's id (it rides `tool_start` / `tool_end`). */ export declare function createAdvisorTool(seat: AdvisorSeat): AgentTool;