Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/agents/pi-embedded-subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,10 @@ export function subscribeEmbeddedPiSession(params: SubscribeEmbeddedPiSessionPar
const startTime = Date.now();
log.info(`[TRACE] stripBlockTags start textLength=${text.length} timestamp=${startTime}`);
if (!text) {
log.info(`[TRACE] stripBlockTags end textLength=${text.length}RdurationMs=${endTime - startTime} timestamp=${endTime}`);
const endTime = Date.now();
log.info(
`[TRACE] stripBlockTags end textLength=${text.length}RdurationMs=${endTime - startTime} timestamp=${endTime}`,
);
return text;
}

Expand Down Expand Up @@ -573,8 +576,11 @@ export function subscribeEmbeddedPiSession(params: SubscribeEmbeddedPiSessionPar
if (!params.enforceFinalTag) {
state.inlineCode = finalCodeSpans.inlineState;
FINAL_TAG_SCAN_RE.lastIndex = 0;
out = stripTagsOutsideCodeSpans(processed, FINAL_TAG_SCAN_RE, finalCodeSpans.isInside);
log.info(`[TRACE] stripBlockTags end textLength=${text.length}RdurationMs=${endTime - startTime} timestamp=${endTime}`);
const out = stripTagsOutsideCodeSpans(processed, FINAL_TAG_SCAN_RE, finalCodeSpans.isInside);
const endTime = Date.now();
log.info(
`[TRACE] stripBlockTags end textLength=${text.length}RdurationMs=${endTime - startTime} timestamp=${endTime}`,
);
return out;
}

Expand Down Expand Up @@ -614,7 +620,10 @@ export function subscribeEmbeddedPiSession(params: SubscribeEmbeddedPiSessionPar
// we have seen a <final> tag. Otherwise, we leak "thinking out loud" text
// (e.g. "**Locating Manulife**...") that the model emitted without <think> tags.
if (!everInFinal) {
log.info(`[TRACE] stripBlockTags end textLength=${text.length}RdurationMs=${endTime - startTime} timestamp=${endTime}`);
const endTime = Date.now();
log.info(
`[TRACE] stripBlockTags end textLength=${text.length}RdurationMs=${endTime - startTime} timestamp=${endTime}`,
);
return "";
}

Expand All @@ -623,8 +632,10 @@ export function subscribeEmbeddedPiSession(params: SubscribeEmbeddedPiSessionPar
const resultCodeSpans = buildCodeSpanIndex(result, inlineStateStart);
state.inlineCode = resultCodeSpans.inlineState;
const endTime = Date.now();
out = stripTagsOutsideCodeSpans(result, FINAL_TAG_SCAN_RE, resultCodeSpans.isInside);
log.info(`[TRACE] stripBlockTags end textLength=${text.length}RdurationMs=${endTime - startTime} timestamp=${endTime}`);
const out = stripTagsOutsideCodeSpans(result, FINAL_TAG_SCAN_RE, resultCodeSpans.isInside);
log.info(
`[TRACE] stripBlockTags end textLength=${text.length}RdurationMs=${endTime - startTime} timestamp=${endTime}`,
);
return out;
};

Expand Down