Skip to content

Commit 2581814

Browse files
committed
feat(codex): enable network access for subagents
1 parent 646ebdd commit 2581814

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/local-agent-codex.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ readline.createInterface({ input: process.stdin }).on("line", (line) => {
7373
output({ method: "turn/completed", params: { threadId: message.params.threadId, turn: { id: turnId, status: "completed", items: [] } } });
7474
return;
7575
}
76-
const item = { type: "agentMessage", text: "fake response " + turn };
76+
const item = { type: "agentMessage", text: message.params.input[0].text === "policy"
77+
? JSON.stringify(message.params.sandboxPolicy)
78+
: "fake response " + turn };
7779
output({ method: "item/completed", params: { threadId: message.params.threadId, turnId, item } });
7880
output({ method: "turn/completed", params: { threadId: message.params.threadId, turn: { id: turnId, status: "completed", items: [item] } } });
7981
});
@@ -133,6 +135,15 @@ readline.createInterface({ input: process.stdin }).on("line", (line) => {
133135
assert.ok(protocolFailure.error.cause, "provider protocol cause remains available internally");
134136
assert.equal("cause" in toAgentErrorPayload(protocolFailure.error), false);
135137
}
138+
const policy = await runtime.run({
139+
prompt: "policy",
140+
workspaceRoot: "/tmp/project",
141+
writeMode: "allowed",
142+
providerSessionId: first.providerSessionId ?? undefined,
143+
});
144+
assert.equal(policy.isOk(), true);
145+
if (policy.isErr()) throw policy.error;
146+
assert.deepEqual(JSON.parse(policy.value.finalResponse), { type: "workspaceWrite", networkAccess: true });
136147
await runtime.releaseSession("thread_new");
137148
} finally {
138149
await runtime.close();

src/local-agent-codex.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,9 @@ export function sandboxFor(writeMode: LocalAgentWriteMode | undefined): string {
482482
}
483483
}
484484

485-
function sandboxPolicyFor(writeMode: LocalAgentWriteMode | undefined): Record<string, string> {
485+
function sandboxPolicyFor(writeMode: LocalAgentWriteMode | undefined): Record<string, string | boolean> {
486486
switch (writeMode) {
487-
case "allowed": return { type: "workspaceWrite" };
487+
case "allowed": return { type: "workspaceWrite", networkAccess: true };
488488
case "full_access": return { type: "dangerFullAccess" };
489489
case "read_only":
490490
case undefined: return { type: "readOnly" };

0 commit comments

Comments
 (0)