refactor(channels): dedupe hook and monitor execution paths

This commit is contained in:
Peter Steinberger
2026-02-22 21:18:53 +00:00
parent 06b0a60bef
commit 2081b3a3c4
19 changed files with 347 additions and 213 deletions

View File

@@ -25,7 +25,7 @@ import {
import type { TranscriptPolicy } from "../transcript-policy.js";
import { resolveTranscriptPolicy } from "../transcript-policy.js";
import { log } from "./logger.js";
import { dropThinkingBlocks } from "./thinking.js";
import { dropThinkingBlocks, isAssistantMessageWithContent } from "./thinking.js";
import { describeUnknownError } from "./utils.js";
const GOOGLE_TURN_ORDERING_CUSTOM_TYPE = "google-turn-ordering-bootstrap";
@@ -73,15 +73,11 @@ export function sanitizeAntigravityThinkingBlocks(messages: AgentMessage[]): Age
let touched = false;
const out: AgentMessage[] = [];
for (const msg of messages) {
if (!msg || typeof msg !== "object" || msg.role !== "assistant") {
if (!isAssistantMessageWithContent(msg)) {
out.push(msg);
continue;
}
const assistant = msg;
if (!Array.isArray(assistant.content)) {
out.push(msg);
continue;
}
type AssistantContentBlock = Extract<AgentMessage, { role: "assistant" }>["content"][number];
const nextContent: AssistantContentBlock[] = [];
let contentChanged = false;