惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
腾讯CDC
Jina AI
Jina AI
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
小众软件
小众软件
M
MIT News - Artificial intelligence
MyScale Blog
MyScale Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
月光博客
月光博客
L
LangChain Blog
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
C
Check Point Blog
U
Unit 42
人人都是产品经理
人人都是产品经理

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(providers): quarantine unreadable Anthropic payload t...
steipete · 2026-06-14 · via Recent Commits to openclaw:main
1+

import OpenAI from "openai";

2+

import type { StreamFn } from "openclaw/plugin-sdk/agent-core";

3+

import type { Model } from "openclaw/plugin-sdk/llm";

4+

import { createAssistantMessageEventStream } from "openclaw/plugin-sdk/llm";

5+

import { describe, expect, it } from "vitest";

6+

import { isLiveTestEnabled } from "../../../agents/live-test-helpers.js";

7+

import { createOpenAIAnthropicToolPayloadCompatibilityWrapper } from "./anthropic-family-tool-payload-compat.js";

8+9+

const OPENAI_KEY = process.env.OPENAI_API_KEY ?? "";

10+

const LIVE = isLiveTestEnabled(["OPENAI_LIVE_TEST"]) && Boolean(OPENAI_KEY);

11+

const describeLive = LIVE ? describe : describe.skip;

12+13+

describeLive("OpenAI-compatible Anthropic tool payload wrapper live", () => {

14+

it("sends a healthy pinned tool after quarantining an unreadable sibling", async () => {

15+

const liveModelId = process.env.OPENCLAW_LIVE_OPENAI_CHAT_TOOL_MODEL || "gpt-5.5";

16+

let projectedPayload: Record<string, unknown> | undefined;

17+

const baseStreamFn: StreamFn = (model, context, options) => {

18+

const payload: Record<string, unknown> = {

19+

model: liveModelId,

20+

messages: [

21+

{

22+

role: "user",

23+

content: "Call live_probe with value exactly OPENAI_WRAPPER_OK.",

24+

},

25+

],

26+

tools: [

27+

{

28+

name: "unreadable_probe",

29+

parameters: {

30+

type: "object",

31+

properties: {

32+

get value(): never {

33+

throw new Error("live unreadable nested schema getter");

34+

},

35+

},

36+

},

37+

},

38+

{

39+

name: "live_probe",

40+

description: "Return the requested probe value.",

41+

input_schema: {

42+

type: "object",

43+

properties: { value: { type: "string" } },

44+

required: ["value"],

45+

},

46+

},

47+

],

48+

tool_choice: { type: "tool", name: "live_probe" },

49+

max_completion_tokens: 128,

50+

};

51+

options?.onPayload?.(payload, model);

52+

projectedPayload = structuredClone(payload);

53+

return createAssistantMessageEventStream();

54+

};

55+

const wrapped = createOpenAIAnthropicToolPayloadCompatibilityWrapper(baseStreamFn);

56+

const model = {

57+

api: "anthropic-messages",

58+

provider: "openai-compatible-anthropic",

59+

id: liveModelId,

60+

compat: { requiresOpenAiAnthropicToolPayload: true },

61+

} as unknown as Model<"anthropic-messages">;

62+63+

void wrapped(model, { messages: [] }, {});

64+

if (!projectedPayload) {

65+

throw new Error("wrapper did not produce a payload");

66+

}

67+68+

const client = new OpenAI({ apiKey: OPENAI_KEY });

69+

const response = await client.chat.completions.create(

70+

projectedPayload as unknown as OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming,

71+

);

72+

const toolCall = response.choices[0]?.message.tool_calls?.[0];

73+74+

if (!toolCall || toolCall.type !== "function") {

75+

throw new Error("OpenAI did not return the expected function tool call");

76+

}

77+

expect(toolCall.function.name).toBe("live_probe");

78+

expect(JSON.parse(toolCall.function.arguments)).toEqual({

79+

value: "OPENAI_WRAPPER_OK",

80+

});

81+

}, 45_000);

82+

});