























@@ -1,3 +1,4 @@
1+// Covers extra-params stream wrapper composition across provider families.
12import type { StreamFn } from "openclaw/plugin-sdk/agent-core";
23import type { Context, Model, SimpleStreamOptions } from "openclaw/plugin-sdk/llm";
34import { createAssistantMessageEventStream } from "openclaw/plugin-sdk/llm";
@@ -115,6 +116,8 @@ function createTestXaiFastModeWrapper(
115116baseStreamFn: StreamFn | undefined,
116117fastMode: boolean,
117118): StreamFn {
119+// xAI fast mode swaps known model ids before the request reaches the base
120+// stream function, mirroring the provider wrapper without network calls.
118121return (model, context, options) => {
119122if (!fastMode || model.api !== "openai-completions" || model.provider !== "xai") {
120123return (
@@ -154,6 +157,8 @@ function stripTestXaiUnsupportedStrictFlag(tool: unknown): unknown {
154157}
155158156159function createTestXaiPayloadCompatibilityWrapper(baseStreamFn: StreamFn | undefined): StreamFn {
160+// xAI rejects OpenAI-specific reasoning and strict tool-schema fields, so the
161+// wrapper removes those from the outgoing payload.
157162return (model, context, options) => {
158163const underlying =
159164baseStreamFn ??
@@ -237,6 +242,8 @@ function isDirectAnthropicModel(model: { provider?: string; baseUrl?: string }):
237242}
238243239244function createAnthropicBetaHeadersWrapper(baseStreamFn: StreamFn | undefined, betas: string[]) {
245+// Anthropic beta headers combine OAuth-required betas, default tool/thinking
246+// betas, and user-configured betas while stripping the managed 1M marker.
240247const underlying = baseStreamFn ?? (() => ({}) as ReturnType<StreamFn>);
241248return ((model, context, options) => {
242249const configuredBetas = betas.filter((beta) => beta !== ANTHROPIC_CONTEXT_1M_BETA);
@@ -320,6 +327,8 @@ type WrapProviderStreamFnParams = Parameters<
320327>[0];
321328322329function installFullProviderRuntimeDepsForTest() {
330+// Install a test-only provider runtime that composes the same wrapper families
331+// the production provider hook layer owns.
323332extraParamsTesting.setProviderRuntimeDepsForTest({
324333prepareProviderExtraParams: (params) => {
325334if (params.provider !== "openai") {
@@ -552,6 +561,8 @@ describe("applyExtraParamsToAgent", () => {
552561payload?: Record<string, unknown>;
553562thinkingLevel?: Parameters<typeof applyExtraParamsToAgent>[5];
554563}) {
564+// Mutates a caller-owned payload through onPayload, matching how the runtime
565+// finalizes provider request bodies.
555566const payload = params.payload ?? { store: false };
556567const baseStreamFn: StreamFn = (model, _context, options) => {
557568options?.onPayload?.(payload, model);
@@ -609,6 +620,8 @@ describe("applyExtraParamsToAgent", () => {
609620extraParamsOverride?: Record<string, unknown>;
610621payload?: Record<string, unknown>;
611622}) {
623+// This bypasses provider wrappers so the test observes only core
624+// parallel_tool_calls alias handling.
612625return withMinimalProviderRuntimeDepsForTest(() => {
613626const payload = params.payload ?? {};
614627const baseStreamFn: StreamFn = (model, _context, options) => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。