Skip to content

Commit b5de838

Browse files
committed
feat: treat built-in Responses tools as first-class bridge entries
1 parent 3b251e5 commit b5de838

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

lib/request/request-transformer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ function extractRuntimeToolNames(tools: unknown): string[] {
421421
for (const tool of tools) {
422422
if (!tool || typeof tool !== "object") continue;
423423

424+
const toolType = (tool as { type?: unknown }).type;
425+
if (typeof toolType === "string" && toolType.trim() && toolType !== "function") {
426+
names.push(toolType);
427+
continue;
428+
}
429+
424430
const directName = (tool as { name?: unknown }).name;
425431
if (typeof directName === "string" && directName.trim()) {
426432
names.push(directName);

test/request-transformer.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,22 @@ describe('Request Transformer Module', () => {
754754
it('should return undefined for undefined input', () => {
755755
expect(addCodexBridgeMessage(undefined, true)).toBeUndefined();
756756
});
757+
758+
it('should list built-in Responses tools in the runtime manifest', () => {
759+
const input: InputItem[] = [
760+
{ type: 'message', role: 'user', content: 'hello' },
761+
];
762+
const result = addCodexBridgeMessage(input, true, [
763+
{ type: 'web_search_preview', search_context_size: 'medium' },
764+
{ type: 'file_search', vector_store_ids: ['vs_123'] },
765+
{ type: 'function', function: { name: 'read_file' } },
766+
]);
767+
768+
const bridgeText = (result?.[0].content as any)[0].text;
769+
expect(bridgeText).toContain('`web_search_preview`');
770+
expect(bridgeText).toContain('`file_search`');
771+
expect(bridgeText).toContain('`read_file`');
772+
});
757773
});
758774

759775
describe('transformRequestBody', () => {
@@ -1449,6 +1465,27 @@ describe('Request Transformer Module', () => {
14491465
expect(result.max_completion_tokens).toBeUndefined();
14501466
});
14511467

1468+
it('should preserve newer Responses passthrough fields', async () => {
1469+
const body: RequestBody = {
1470+
model: 'gpt-5',
1471+
input: [],
1472+
previous_response_id: 'resp_123',
1473+
parallel_tool_calls: true,
1474+
service_tier: 'auto',
1475+
metadata: { source: 'test-suite' },
1476+
tool_choice: 'auto',
1477+
truncation: 'auto',
1478+
};
1479+
const result = await transformRequestBody(body, codexInstructions);
1480+
1481+
expect(result.previous_response_id).toBe('resp_123');
1482+
expect(result.parallel_tool_calls).toBe(true);
1483+
expect(result.service_tier).toBe('auto');
1484+
expect(result.metadata).toEqual({ source: 'test-suite' });
1485+
expect(result.tool_choice).toBe('auto');
1486+
expect(result.truncation).toBe('auto');
1487+
});
1488+
14521489
it('should normalize minimal to low for gpt-5-codex', async () => {
14531490
const body: RequestBody = {
14541491
model: 'gpt-5-codex',

test/tool-utils.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ describe("cleanupToolDefinitions", () => {
1313
expect(cleanupToolDefinitions(tools)).toEqual(tools);
1414
});
1515

16+
it("preserves built-in Responses tools unchanged", () => {
17+
const tools = [
18+
{ type: "web_search_preview", search_context_size: "medium" },
19+
{ type: "file_search", vector_store_ids: ["vs_123"] },
20+
{ type: "computer_use_preview", environment: "browser" },
21+
];
22+
23+
expect(cleanupToolDefinitions(tools)).toEqual(tools);
24+
});
25+
1626
it("filters required array to only existing properties", () => {
1727
const tools = [{
1828
type: "function",

0 commit comments

Comments
 (0)