UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

28 lines (27 loc) • 1.54 kB
import { deliverEngineNotice } from "../engine-notice.js"; import { providerReportedModel } from "../message-utils.js"; export function createResponseModelSeat(onNotice, ids) { const announced = new Set(); return { observe(message) { const reported = providerReportedModel(message); if (reported === undefined) return undefined; const requested = typeof message.model === "string" ? message.model : ""; const pair = `${requested}\u0000${reported}`; if (!announced.has(pair)) { announced.add(pair); deliverEngineNotice(onNotice, { code: "route.response_model_mismatch", message: `The provider answered with model "${reported}" for a request sent as "${requested || "(unnamed)"}". ` + `The run is unchanged — the engine keeps asking for the id the catalog names, and the served name is ` + `reported beside it on every turn (turn_end.responseModel) and on the result (TaskResult.responseModel). ` + `This is what an alias, a pool or a gateway-side substitution looks like from here; if the two were ` + `meant to be the same model, the catalog id and the gateway disagree about which one that is.`, detail: { requested, reported, sessionId: ids.sessionId, runId: ids.runId }, }); } return reported; }, }; }