debug: add responsePrefix template logging

This commit is contained in:
Sebastian
2026-01-14 23:23:21 -05:00
parent 113eea5047
commit 56b3b44342
3 changed files with 16 additions and 0 deletions

View File

@@ -127,6 +127,9 @@ export async function runAgentTurnWithFallback(params: {
run: (provider, model) => {
// Notify that model selection is complete (including after fallback).
// This allows responsePrefix template interpolation with the actual model.
logVerbose(
`[responsePrefix] onModelSelected callback exists: ${!!params.opts?.onModelSelected}, provider=${provider}, model=${model}`,
);
params.opts?.onModelSelected?.({
provider,
model,

View File

@@ -1,3 +1,4 @@
import { logVerbose } from "../../globals.js";
import { stripHeartbeatToken } from "../heartbeat.js";
import { HEARTBEAT_TOKEN, isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js";
import type { ReplyPayload } from "../types.js";
@@ -43,9 +44,17 @@ export function normalizeReplyPayload(
}
// Resolve template variables in responsePrefix if context is provided
if (opts.responsePrefix?.includes("{")) {
logVerbose(
`[responsePrefix] normalizing: prefix="${opts.responsePrefix}", context=${JSON.stringify(opts.responsePrefixContext)}`,
);
}
const effectivePrefix = opts.responsePrefixContext
? resolveResponsePrefixTemplate(opts.responsePrefix, opts.responsePrefixContext)
: opts.responsePrefix;
if (opts.responsePrefix?.includes("{") && effectivePrefix !== opts.responsePrefix) {
logVerbose(`[responsePrefix] resolved to: "${effectivePrefix}"`);
}
if (
effectivePrefix &&