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

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
T
Tailwind CSS Blog
月光博客
月光博客
爱范儿
爱范儿
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
腾讯CDC
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
U
Unit 42
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
雷峰网
雷峰网
L
LangChain Blog

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(gateway): accept file-only input on /v1/responses (pa...
yetval · 2026-06-15 · via Recent Commits to openclaw:main
1+

import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

2+3+

const extractFileContentFromSourceMock = vi.fn();

4+5+

vi.mock("../media/input-files.js", async () => {

6+

const actual =

7+

await vi.importActual<typeof import("../media/input-files.js")>("../media/input-files.js");

8+

return {

9+

...actual,

10+

extractFileContentFromSource: (...args: unknown[]) => extractFileContentFromSourceMock(...args),

11+

};

12+

});

13+14+

import {

15+

agentCommand,

16+

getFreePort,

17+

installGatewayTestHooks,

18+

startGatewayServerWithRetries,

19+

} from "./test-helpers.js";

20+21+

installGatewayTestHooks({ scope: "suite" });

22+23+

let server: Awaited<ReturnType<typeof startGatewayServerWithRetries>>["server"];

24+

let port: number;

25+26+

beforeAll(async () => {

27+

const started = await startGatewayServerWithRetries({

28+

port: await getFreePort(),

29+

opts: {

30+

host: "127.0.0.1",

31+

auth: { mode: "none" },

32+

controlUiEnabled: false,

33+

openResponsesEnabled: true,

34+

},

35+

});

36+

port = started.port;

37+

server = started.server;

38+

});

39+40+

afterAll(async () => {

41+

await server?.close({ reason: "openresponses file-only suite done" });

42+

});

43+44+

beforeEach(() => {

45+

vi.clearAllMocks();

46+

});

47+48+

async function postResponses(body: unknown) {

49+

return await fetch(`http://127.0.0.1:${port}/v1/responses`, {

50+

method: "POST",

51+

headers: {

52+

"content-type": "application/json",

53+

"x-openclaw-scopes": "operator.write",

54+

},

55+

body: JSON.stringify(body),

56+

});

57+

}

58+59+

describe("OpenResponses file-only input that renders to images", () => {

60+

it("accepts a file-only turn whose file renders to images and forwards them", async () => {

61+

extractFileContentFromSourceMock.mockResolvedValueOnce({

62+

filename: "scan.pdf",

63+

text: "",

64+

images: [

65+

{ type: "image", data: Buffer.alloc(8, 1).toString("base64"), mimeType: "image/png" },

66+

],

67+

});

68+

agentCommand.mockResolvedValueOnce({ payloads: [{ text: "ok" }] } as never);

69+70+

const res = await postResponses({

71+

model: "openclaw",

72+

instructions: "Describe the attached scan.",

73+

input: [

74+

{

75+

type: "message",

76+

role: "user",

77+

content: [

78+

{

79+

type: "input_file",

80+

source: {

81+

type: "base64",

82+

media_type: "application/pdf",

83+

data: Buffer.from("%PDF-1.4 scanned").toString("base64"),

84+

filename: "scan.pdf",

85+

},

86+

},

87+

],

88+

},

89+

],

90+

});

91+92+

expect(res.status).toBe(200);

93+

expect(agentCommand).toHaveBeenCalledTimes(1);

94+

const opts = agentCommand.mock.calls[0]?.[0] as { message?: string; images?: unknown[] };

95+

expect(opts.message ?? "").not.toBe("");

96+

expect(opts.images?.length).toBe(1);

97+

await res.text();

98+

});

99+100+

it("keeps an empty extracted file visible to the model", async () => {

101+

extractFileContentFromSourceMock.mockResolvedValueOnce({

102+

filename: "empty.txt",

103+

text: "",

104+

images: [],

105+

});

106+

agentCommand.mockResolvedValueOnce({ payloads: [{ text: "ok" }] } as never);

107+108+

const res = await postResponses({

109+

model: "openclaw",

110+

input: [

111+

{

112+

type: "message",

113+

role: "user",

114+

content: [

115+

{

116+

type: "input_file",

117+

source: {

118+

type: "base64",

119+

media_type: "text/plain",

120+

data: Buffer.from("binary-only file").toString("base64"),

121+

filename: "empty.txt",

122+

},

123+

},

124+

],

125+

},

126+

],

127+

});

128+129+

const body = await res.text();

130+

expect(res.status, body).toBe(200);

131+

expect(agentCommand).toHaveBeenCalledTimes(1);

132+

const opts = agentCommand.mock.calls[0]?.[0] as { extraSystemPrompt?: string };

133+

expect(opts.extraSystemPrompt).toContain('<file name="empty.txt">');

134+

expect(opts.extraSystemPrompt).toContain("[No extractable text]");

135+

});

136+

});