Skip to content

Commit 15a3817

Browse files
committed
fix(channels): mask observe-only dispatch results
1 parent 9e560b6 commit 15a3817

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

‎extensions/matrix/src/matrix/monitor/handler.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,10 +2494,8 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
24942494
},
24952495
replyOptions: {
24962496
skillFilter: roomConfig?.skills,
2497-
// Keep block streaming enabled when explicitly requested, even
2498-
// with draft previews on. The draft remains the live preview
2499-
// for the current assistant block, while block deliveries
2500-
// finalize completed blocks into their own preserved events.
2497+
// Preserve explicit block streaming with draft previews: drafts update the live
2498+
// block, while block deliveries finalize completed blocks as separate events.
25012499
disableBlockStreaming: !blockStreamingEnabled,
25022500
onPartialReply: draftStream
25032501
? (payload) => {

‎src/channels/turn/execution.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,11 @@ async function runPreparedChannelTurnCoreInTrace<
217217
});
218218
let dispatchResult: TDispatchResult;
219219
try {
220+
if (admission.kind === "observeOnly" && !options.suppressObserveOnlyDispatch) {
221+
await params.runDispatch();
222+
}
220223
dispatchResult =
221-
options.suppressObserveOnlyDispatch && admission.kind === "observeOnly"
224+
admission.kind === "observeOnly"
222225
? resolveObserveOnlyDispatchResult(params)
223226
: await params.runDispatch();
224227
maybeWarnZeroCountVisibleDispatch({

‎src/channels/turn/kernel.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,15 @@ describe("channel turn kernel", () => {
13921392
expect(result.dispatched).toBe(true);
13931393
expect(events).toEqual(["record", "dispatch"]);
13941394
expect(deliver).not.toHaveBeenCalled();
1395+
if (!result.dispatched) {
1396+
throw new Error("expected dispatch");
1397+
}
1398+
expect(hasVisibleChannelTurnDispatch(result.dispatchResult)).toBe(false);
1399+
expect(resolveChannelTurnDispatchCounts(result.dispatchResult)).toEqual({
1400+
tool: 0,
1401+
block: 0,
1402+
final: 0,
1403+
});
13951404
expect(onFinalize).toHaveBeenCalledTimes(1);
13961405
const [finalized] = requireFirstMockCall(onFinalize, "finalize");
13971406
const finalizedResult = finalizeResult(finalized);

0 commit comments

Comments
 (0)