Skip to content

Commit f6a06ae

Browse files
committed
fix(codex): honor normalized source routes
1 parent 53ff3f7 commit f6a06ae

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

extensions/codex/src/app-server/dynamic-tools.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,57 @@ describe("createCodexDynamicToolBridge", () => {
12091209
expect(Object.keys(result)).not.toContain("terminate");
12101210
});
12111211

1212+
it("keeps normalized explicit source routes terminal", async () => {
1213+
setActivePluginRegistry(
1214+
createTestRegistry([
1215+
{
1216+
pluginId: "sms",
1217+
plugin: {
1218+
id: "sms",
1219+
messaging: {
1220+
normalizeTarget: (raw: string) => {
1221+
const digits = raw.replace(/\D/gu, "");
1222+
return digits.length === 11 && digits.startsWith("1") ? `+${digits}` : raw.trim();
1223+
},
1224+
},
1225+
},
1226+
source: "test",
1227+
},
1228+
]),
1229+
);
1230+
const bridge = createBridgeWithToolResult(
1231+
"message",
1232+
textToolResult("Sent.", { ok: true, messageId: "sms-853" }),
1233+
{
1234+
sourceReplyDeliveryMode: "message_tool_only",
1235+
currentChannelProvider: "sms",
1236+
currentChannelId: "sms:+12069106512",
1237+
currentMessagingTarget: "+12069106512",
1238+
},
1239+
);
1240+
1241+
const result = await handleMessageToolCall(bridge, {
1242+
action: "reply",
1243+
channel: "sms",
1244+
target: "+1 (206) 910-6512",
1245+
messageId: "853",
1246+
message: "visible reply",
1247+
});
1248+
1249+
expect(result).toEqual(expectInputText("Sent."));
1250+
expect(bridge.telemetry.messagingToolSentTargets).toEqual([
1251+
expect.objectContaining({
1252+
tool: "message",
1253+
provider: "sms",
1254+
to: "+12069106512",
1255+
text: "visible reply",
1256+
}),
1257+
]);
1258+
expect(result.terminate).toBe(true);
1259+
expect(bridge.telemetry.didDeliverSourceReplyViaMessageTool).toBe(true);
1260+
expect(Object.keys(result)).not.toContain("terminate");
1261+
});
1262+
12121263
it("keeps message-tool-only source replies terminal when the reply receipt matches the current message id", async () => {
12131264
const bridge = createBridgeWithToolResult(
12141265
"message",

extensions/codex/src/app-server/dynamic-tools.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ function hasExplicitNonSourceMessageRoute(
311311
) {
312312
return true;
313313
}
314+
if (messagingTarget?.to !== undefined) {
315+
return false;
316+
}
314317
if (targetValues.length === 0) {
315318
return false;
316319
}

0 commit comments

Comments
 (0)