Skip to content

Commit d14fd96

Browse files
committed
fix(agent): keep gpt shell arguments through dispatch
1 parent 99f67eb commit d14fd96

2 files changed

Lines changed: 41 additions & 6 deletions

File tree

‎src/agent/tool-aliases.test.ts‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,43 @@ describe("hidden alias dispatch", () => {
191191
expect(seen.timeout).toBe(5000);
192192
});
193193

194+
test("gpt shell keeps run_shell cwd, timeout, background, and stop", async () => {
195+
let seen: Record<string, unknown> = {};
196+
const runner = createDynamicToolRunner([
197+
{
198+
kind: "string",
199+
definition: posixDef("run_shell"),
200+
handler: async (args) => {
201+
seen = args;
202+
return "ok";
203+
},
204+
},
205+
]);
206+
runner.setCallGate(() => true);
207+
const result = await runner.run(
208+
{
209+
id: "1",
210+
name: "shell",
211+
arguments: {
212+
command: "npm test",
213+
cwd: "/tmp/proj",
214+
timeout: 5000,
215+
background: true,
216+
stop: "sh_1",
217+
},
218+
},
219+
new AbortController().signal,
220+
);
221+
expect(result.content).toBe("ok");
222+
expect(seen).toEqual({
223+
command: "npm test",
224+
cwd: "/tmp/proj",
225+
timeout: 5000,
226+
background: true,
227+
stop: "sh_1",
228+
});
229+
});
230+
194231
test("update_plan hidden-dispatches onto manage_tasks; apply_patch does not", async () => {
195232
const runner = createDynamicToolRunner([
196233
{

‎src/agent/tool-aliases.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,18 +428,16 @@ function incomingAlias(requested: string): string {
428428
}
429429

430430
/** Coerce hidden Codex-shaped arguments onto the engine tool. Callers pass
431-
* the already-resolved engine. */
431+
* the already-resolved engine. gpt advertises `shell` with run_shell's own
432+
* arguments (`cwd`, `timeout`, `background`, `stop`); those pass through.
433+
* Only Codex argv, `workdir`, and `timeout_ms` are rewritten. */
432434
export function prepareDispatchedToolCall(
433435
call: ToolCall,
434436
engine: string,
435437
): ToolCall {
436438
const incoming = incomingAlias(call.name);
437439
let args = call.arguments;
438-
if (
439-
incoming === "shell" ||
440-
incoming.toLowerCase() === "shell" ||
441-
(engine === "run_shell" && looksLikeCodexShellArgs(args))
442-
) {
440+
if (engine === "run_shell" && looksLikeCodexShellArgs(args)) {
443441
args = coerceShellArgs(args);
444442
}
445443
if (

0 commit comments

Comments
 (0)