跳到正文
DEV Community· Florian·· 3 小時前AI 評分41

LiveSuggest 的前兩次模型呼叫會忽略模型選擇器

The first two model calls ignore the picker

AI 導讀

LiveSuggest 每個工作階段的前兩次模型呼叫都會強制使用 gpt-5.6-terra,包括訪客工作階段,與用戶要求的模型無關。失敗呼叫仍會消耗名額;若前兩次均失敗,第三次才會使用用戶要求的模型。每日支出檢查若無法讀取,系統會拒絕發出呼叫。

正文

Florian

Each session sends its first two model calls to gpt-5.6-terra. Guest sessions are in that count. The plan does not enter the decision, and neither does the id the picker sent. What matters is how many forced slots this session has already used.

The client still receives the id it asked for. The UI stores it as requestedModel. The suggestion-end event carries the same field. Read only those two and a forced call looks like any other call.

The slot counter moves before the stream starts, so a failed call still spends a slot. If the first two calls both fail, the third goes to the model the client requested.

A retry on that requested model happens only when nothing has reached the client yet and the error is not a timeout. Timeout on the forced model stops there. So does a failure after the client has already seen output. A retry that does run does not give the slot back.

Daily spend has a kill switch, and it fails closed. If that check cannot be read, the call is not sent. Forced slots left on the session do not change that.

const FORCED_MODEL = "gpt-5.6-terra";
const FORCED_CALLS = 2;

async function runCall(ctx, deps) {
  const spend = await deps.readDailySpend().catch(() => null);
  if (spend === null || spend.exceeded) {
    throw new Error("spend blocked");
  }

  const forced = await deps.claimSlot(ctx.sessionId, FORCED_CALLS);
  const model = forced ? FORCED_MODEL : ctx.requestedModel;
  let visible = false;

  try {
    await deps.stream(model, () => {
      visible = true;
    });
  } catch (err) {
    if (!(forced && !visible && !deps.isTimeout(err))) throw err;
    await deps.stream(ctx.requestedModel, () => {});
  }

  deps.emitSuggestionEnd({ requestedModel: ctx.requestedModel });
}

The sketch is not the production code. claimSlot runs before stream. emitSuggestionEnd always reports ctx.requestedModel. Spent slots and successful calls are different counts.

This path is how LiveSuggest picks the model for a suggestion.

來源:DEV Community · dev.to