fix(agents): skip thinking tags in code spans

This commit is contained in:
Peter Steinberger
2026-01-15 09:23:10 +00:00
parent aac5b4673f
commit 7e1e7ba2d8
7 changed files with 275 additions and 6 deletions

View File

@@ -17,6 +17,7 @@ import {
formatReasoningMessage,
promoteThinkingTagsToBlocks,
} from "./pi-embedded-utils.js";
import { createInlineCodeState } from "../markdown/code-spans.js";
export function handleMessageStart(
ctx: EmbeddedPiSubscribeContext,
@@ -103,6 +104,7 @@ export function handleMessageUpdate(
.stripBlockTags(ctx.state.deltaBuffer, {
thinking: false,
final: false,
inlineCode: createInlineCodeState(),
})
.trim();
if (next && next !== ctx.state.lastStreamedAssistant) {
@@ -240,5 +242,6 @@ export function handleMessageEnd(
ctx.blockChunker?.reset();
ctx.state.blockState.thinking = false;
ctx.state.blockState.final = false;
ctx.state.blockState.inlineCode = createInlineCodeState();
ctx.state.lastStreamedAssistant = undefined;
}