fix(channels): honor queued replies without receipts (#127667)

Restore compatibility-aware visible dispatch detection when legacy prepared runners return queued counters without a settled receipt. Preserve settled-receipt authority.

Co-authored-by: Marvinthebored <peter@lindsey.jp>
This commit is contained in:
Marvinthebored
2026-08-22 14:38:52 +08:00
committed by GitHub
parent dacfd09786
commit 2fdfd64a1a
2 changed files with 38 additions and 1 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ import { isRecentOutboundMessageIdentity } from "../message/outbound-echo.js";
import { recordChannelBotPairLoopAndCheckSuppression } from "./bot-loop-protection.js";
import {
EMPTY_CHANNEL_TURN_DISPATCH_COUNTS,
hasVisibleChannelTurnDispatchFromReceipt as hasVisibleChannelTurnDispatch,
hasVisibleChannelTurnDispatch,
type ChannelTurnDispatchResultLike,
type ChannelTurnVisibleDeliverySignals,
} from "./dispatch-result.js";
@@ -945,6 +945,43 @@ describe("channel turn pipeline", () => {
]);
});
it.each([
{
name: "accepts compatibility counters when no receipt exists",
dispatchResult: { queuedFinal: true, counts: { tool: 0, block: 0, final: 1 } },
warns: false,
},
{
name: "keeps a non-visible settled receipt authoritative",
dispatchResult: {
queuedFinal: true,
counts: { tool: 0, block: 0, final: 1 },
settledReceipt: {
anyVisibleDelivered: false,
counts: { final: { delivered: 0, failedAfterSend: 0 } },
},
},
warns: true,
},
])("$name", async ({ dispatchResult, warns }) => {
const log = vi.fn();
await runPreparedChannelTurn({
channel: "test",
routeSessionKey: "agent:main:test:peer",
storePath: "/tmp/sessions.json",
ctxPayload: createCtx(),
recordInboundSession: createRecordInboundSession(),
runDispatch: vi.fn(async () => dispatchResult),
log,
messageId: "msg-compat",
});
expect(log.mock.calls.some(([event]) => event.reason === "zero-count-visible-dispatch")).toBe(
warns,
);
});
it("does not warn for observed-path deliveries with zero queued counts", async () => {
const events: string[] = [];
const log = vi.fn();