UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

23 lines (22 loc) • 1.35 kB
import { runWithExtraBodyDropped } from "../../brain/status-sink.js"; import { deliverEngineNotice } from "../engine-notice.js"; export function createExtraBodyDroppedScope({ onNotice, sessionId, runId }) { const announced = new Set(); return (fn) => runWithExtraBodyDropped(({ api, modelId, keys }) => { if (keys.length === 0) return; const set = `${api}\u0000${[...keys].sort().join("\u0000")}`; if (announced.has(set)) return; announced.add(set); const many = keys.length > 1; deliverEngineNotice(onNotice, { code: "route.extra_body_reserved_dropped", message: `The extraBody of a ${api} request sent as "${modelId}" carried ${many ? "keys" : "a key"} the engine sets itself — ` + `${keys.map((k) => `"${k}"`).join(", ")} — and ${many ? "they were" : "it was"} dropped: the request went out ` + `with the engine's own value${many ? "s" : ""} (or without ${many ? "them" : "it"}, where the engine sends none). Remove ${many ? "them" : "it"} from extraBody; ` + `the same drop applies to every request that model spec is used on, and this notice is said once per run for this set of keys.`, detail: { keys: [...keys], api, modelId, sessionId, runId }, }); }, fn); }