Skip to content

Commit 1382fb5

Browse files
committed
fix(agents): fail closed missing requester completion routes
1 parent 6956e84 commit 1382fb5

4 files changed

Lines changed: 75 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Docs: https://docs.openclaw.ai
3939
- Channels/message tool: surface Discord, Slack, and Mattermost `user:`/`channel:` target syntax in the shared message target schema and Discord ambiguity errors, so DM sends by numeric id stop burning retries before finding `user:<id>`. Fixes #72401. Thanks @garyd9, @hclsys, and @praveen9354.
4040
- Agents/tools: scope tool-loop detection history to the active run when available, so scheduled heartbeat cycles no longer inherit stale repeated-call counts from previous runs. Fixes #40144. Thanks @mattbrown319.
4141
- Agents/subagents: preserve requester delivery for completion announces when a child agent is bound to a different channel account while keeping same-channel thread completions routed to the child thread. Thanks @sfuminya.
42+
- Agents/subagents: fail closed instead of selecting a single child thread binding when completion delivery lacks requester conversation signal. Thanks @suyua9.
4243
- Control UI: show loading, reload, and retry states when a lazy dashboard panel cannot load after an upgrade, so the Logs tab no longer appears blank on stale browser bundles. Fixes #72450. Thanks @sobergou.
4344
- Gateway/plugins: start the Gateway in degraded mode when a single plugin entry has invalid schema config, and let `openclaw doctor --fix` quarantine that plugin config instead of crash-looping every channel. Fixes #62976 and #70371. Thanks @Doraemon-Claw and @pksidekyk.
4445
- Agents/plugins: skip malformed plugin tools with missing schema objects and report plugin diagnostics, so one broken tool no longer crashes Anthropic agent runs. Fixes #69423. Thanks @jmnickels.

‎src/agents/subagent-announce.format.e2e.test.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,62 @@ describe("subagent announce formatting", () => {
985985
expect(call?.params?.to).toBe("channel:thread-bound-1");
986986
});
987987

988+
it("does not use a child bound destination when completion requester conversation is missing", async () => {
989+
sessionStore = {
990+
"agent:main:subagent:test": {
991+
sessionId: "child-session-bound-missing-requester",
992+
},
993+
"agent:main:main": {
994+
sessionId: "requester-session-bound-missing-requester",
995+
},
996+
};
997+
chatHistoryMock.mockResolvedValueOnce({
998+
messages: [{ role: "assistant", content: [{ type: "text", text: "bound answer: 2" }] }],
999+
});
1000+
registerSessionBindingAdapter({
1001+
channel: "discord",
1002+
accountId: "acct-1",
1003+
listBySession: (targetSessionKey: string) =>
1004+
targetSessionKey === "agent:main:subagent:test"
1005+
? [
1006+
{
1007+
bindingId: "discord:acct-1:thread-bound-1",
1008+
targetSessionKey,
1009+
targetKind: "subagent",
1010+
conversation: {
1011+
channel: "discord",
1012+
accountId: "acct-1",
1013+
conversationId: "thread-bound-1",
1014+
parentConversationId: "parent-main",
1015+
},
1016+
status: "active",
1017+
boundAt: Date.now(),
1018+
},
1019+
]
1020+
: [],
1021+
resolveByConversation: () => null,
1022+
});
1023+
1024+
const didAnnounce = await runSubagentAnnounceFlow({
1025+
childSessionKey: "agent:main:subagent:test",
1026+
childRunId: "run-session-bound-missing-requester",
1027+
requesterSessionKey: "agent:main:main",
1028+
requesterDisplayKey: "main",
1029+
requesterOrigin: { channel: "discord", accountId: "acct-1" },
1030+
...defaultOutcomeAnnounce,
1031+
expectsCompletionMessage: true,
1032+
spawnMode: "session",
1033+
});
1034+
1035+
expect(didAnnounce).toBe(true);
1036+
expect(sendSpy).not.toHaveBeenCalled();
1037+
expect(agentSpy).toHaveBeenCalledTimes(1);
1038+
const call = agentSpy.mock.calls[0]?.[0] as { params?: Record<string, unknown> };
1039+
expect(call?.params?.deliver).toBe(false);
1040+
expect(call?.params?.to).toBeUndefined();
1041+
expect(call?.params?.threadId).toBeUndefined();
1042+
});
1043+
9881044
it("does not duplicate to main channel when two active bound sessions complete from the same requester channel", async () => {
9891045
sessionStore = {
9901046
"agent:main:subagent:child-a": {

‎src/infra/outbound/bound-delivery-router.test.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,17 @@ describe("bound delivery router", () => {
105105
expected: {
106106
binding: null,
107107
mode: "fallback",
108-
reason: "ambiguous-without-requester",
108+
reason: "missing-requester",
109+
},
110+
},
111+
{
112+
name: "fails closed when requester signal is missing even with a single binding",
113+
bindings: [createRuntimeBinding(TARGET_SESSION_KEY, "thread-1", 1)],
114+
failClosed: true,
115+
expected: {
116+
binding: null,
117+
mode: "fallback",
118+
reason: "missing-requester",
109119
},
110120
},
111121
{

‎src/infra/outbound/bound-delivery-router.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ export function createBoundDeliveryRouter(
7979
}
8080

8181
if (!input.requester) {
82+
if (input.failClosed) {
83+
return {
84+
binding: null,
85+
mode: "fallback",
86+
reason: "missing-requester",
87+
};
88+
}
8289
if (activeBindings.length === 1) {
8390
return {
8491
binding: activeBindings[0] ?? null,

0 commit comments

Comments
 (0)