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

@@ -1,6 +1,7 @@
import type { AgentEvent, AgentMessage } from "@mariozechner/pi-agent-core";
import type { ReasoningLevel } from "../auto-reply/thinking.js";
import type { InlineCodeState } from "../markdown/code-spans.js";
import type { EmbeddedBlockChunker } from "./pi-embedded-block-chunker.js";
import type { MessagingToolSend } from "./pi-embedded-messaging.js";
import type {
@@ -27,7 +28,7 @@ export type EmbeddedPiSubscribeState = {
deltaBuffer: string;
blockBuffer: string;
blockState: { thinking: boolean; final: boolean };
blockState: { thinking: boolean; final: boolean; inlineCode: InlineCodeState };
lastStreamedAssistant?: string;
lastStreamedReasoning?: string;
lastBlockReplyText?: string;
@@ -56,7 +57,10 @@ export type EmbeddedPiSubscribeContext = {
shouldEmitToolResult: () => boolean;
emitToolSummary: (toolName?: string, meta?: string) => void;
stripBlockTags: (text: string, state: { thinking: boolean; final: boolean }) => string;
stripBlockTags: (
text: string,
state: { thinking: boolean; final: boolean; inlineCode?: InlineCodeState },
) => string;
emitBlockChunk: (text: string) => void;
flushBlockReplyBuffer: () => void;
emitReasoningStream: (text: string) => void;