Skip to content

Commit 5fccac0

Browse files
authored
Merge pull request #90 from ndycode/feat/builtin-tools
feat: treat built-in Responses tools as first-class bridge entries
2 parents 1dc22ab + 0154614 commit 5fccac0

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

lib/request/request-transformer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,14 @@ function extractRuntimeToolNames(tools: unknown): string[] {
426426
for (const tool of tools) {
427427
if (!tool || typeof tool !== "object") continue;
428428

429+
// Pure in-memory name extraction only: no filesystem I/O, token access,
430+
// or logging side effects are introduced by recognizing built-in tool types.
431+
const toolType = (tool as { type?: unknown }).type;
432+
if (typeof toolType === "string" && toolType.trim() && toolType !== "function") {
433+
names.push(toolType);
434+
continue;
435+
}
436+
429437
const directName = (tool as { name?: unknown }).name;
430438
if (typeof directName === "string" && directName.trim()) {
431439
names.push(directName);

test/request-transformer.test.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,25 @@ describe('Request Transformer Module', () => {
784784
it('should return undefined for undefined input', () => {
785785
expect(addCodexBridgeMessage(undefined, true)).toBeUndefined();
786786
});
787+
788+
it('should list built-in Responses tools in the runtime manifest', () => {
789+
const input: InputItem[] = [
790+
{ type: 'message', role: 'user', content: 'hello' },
791+
];
792+
const result = addCodexBridgeMessage(input, true, [
793+
{ type: 'web_search_preview', search_context_size: 'medium' },
794+
{ type: 'file_search', vector_store_ids: ['vs_123'] },
795+
{ type: 'function', function: { name: 'read_file' } },
796+
]);
797+
798+
const bridgeText = (result?.[0].content as any)[0].text;
799+
expect(bridgeText).toContain('`web_search_preview`');
800+
expect(bridgeText).toContain('`file_search`');
801+
expect(bridgeText).toContain('`read_file`');
802+
});
787803
});
788804

789-
describe('transformRequestBody', () => {
805+
describe('transformRequestBody', () => {
790806
const codexInstructions = 'Test Codex Instructions';
791807

792808
it('preserves existing prompt_cache_key passed by host (OpenCode)', async () => {
@@ -1479,6 +1495,27 @@ describe('Request Transformer Module', () => {
14791495
expect(result.max_completion_tokens).toBeUndefined();
14801496
});
14811497

1498+
it('should preserve newer Responses passthrough fields', async () => {
1499+
const body: RequestBody = {
1500+
model: 'gpt-5',
1501+
input: [],
1502+
previous_response_id: 'resp_123',
1503+
parallel_tool_calls: true,
1504+
service_tier: 'auto',
1505+
metadata: { source: 'test-suite' },
1506+
tool_choice: 'auto',
1507+
truncation: 'auto',
1508+
};
1509+
const result = await transformRequestBody(body, codexInstructions);
1510+
1511+
expect(result.previous_response_id).toBe('resp_123');
1512+
expect(result.parallel_tool_calls).toBe(true);
1513+
expect(result.service_tier).toBe('auto');
1514+
expect(result.metadata).toEqual({ source: 'test-suite' });
1515+
expect(result.tool_choice).toBe('auto');
1516+
expect(result.truncation).toBe('auto');
1517+
});
1518+
14821519
it('should normalize minimal to low for gpt-5-codex', async () => {
14831520
const body: RequestBody = {
14841521
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)