feat(coding-agent): add after_provider_response hook closes #3128

This commit is contained in:
Mario Zechner
2026-04-16 20:27:04 +02:00
parent aa78fa91fe
commit d131fcd4ba
19 changed files with 120 additions and 25 deletions

View File

@@ -26,6 +26,7 @@ import type {
ToolResultMessage,
} from "../types.js";
import { AssistantMessageEventStream } from "../utils/event-stream.js";
import { headersToRecord } from "../utils/headers.js";
import { parseStreamingJson } from "../utils/json-parse.js";
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
@@ -258,7 +259,10 @@ export const streamAnthropic: StreamFunction<"anthropic-messages", AnthropicOpti
if (nextParams !== undefined) {
params = nextParams as MessageCreateParamsStreaming;
}
const anthropicStream = client.messages.stream({ ...params, stream: true }, { signal: options?.signal });
const { data: anthropicStream, response } = await client.messages
.stream({ ...params, stream: true }, { signal: options?.signal })
.withResponse();
await options?.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
stream.push({ type: "start", partial: output });
type Block = (ThinkingContent | TextContent | (ToolCall & { partialJson: string })) & { index: number };