Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
fix(core): keep the evidence footer when a messaging answer was streamed
Salman Qureshia9c18a3c2139
diff --git a/src/core/task-surface.test.ts b/src/core/task-surface.test.tsindex 877de4b1..699217fb 100644--- a/src/core/task-surface.test.ts+++ b/src/core/task-surface.test.ts@@ -53,6 +53,14 @@ describe('TaskSurface (ROADMAP P1.1 feedback contract)', () => {expect(calls).toEqual(['endTask', 'send:answer\n\n_Verification: npm test ✓ · /trace abc123_', 'cleanup', 'resetStepCounter']);});+ it('messaging: a deferred (streamed) answer still carries the evidence footer', async () => {+ const { ch, calls } = messagingChannel();+ ch.popDeferredResponse = vi.fn(() => 'streamed answer');+ const s = createTaskSurface(ch, 'telegram', 'c');+ await s.done({ finalText: 'streamed answer', elapsedMs: 1000, stepCount: 3, meta, verificationNote: 'npm test ✓', traceId: 'abc123', alreadyStreamed: false });+ expect(calls).toContain('send:streamed answer\n\n_Verification: npm test ✓ · /trace abc123_');+ });+it('messaging: substantial turns defer (Telegram) or stream (others) then send the completion banner', async () => {const tg = messagingChannel({ deferResponse: true });await createTaskSurface(tg.ch, 'telegram', 'c').done({ finalText: 'big', elapsedMs: 60_000, stepCount: 5, meta, traceId: 't1', alreadyStreamed: false });diff --git a/src/core/task-surface.ts b/src/core/task-surface.tsindex 7be458a8..73e13201 100644--- a/src/core/task-surface.ts+++ b/src/core/task-surface.ts@@ -144,7 +144,8 @@ export function createTaskSurface(channel: Channel | undefined, channelType: Chaasync done({ finalText, elapsedMs, stepCount, meta, verificationNote, traceId }) {// Evidence used to reach the CLI only; messaging users got "done"// with nothing to back it. Carry it in the final text instead.- const text = verificationNote ? `${finalText}\n\n${evidenceFooter(verificationNote, traceId)}` : finalText;+ const footer = verificationNote ? `\n\n${evidenceFooter(verificationNote, traceId)}` : '';+ const text = `${finalText}${footer}`;if (isSubstantialTask(stepCount, elapsedMs)) {// sendCompletion owns endTask + deferred flush + cleanup on these channels.if (ch.deferResponse) {@@ -156,8 +157,11 @@ export function createTaskSurface(channel: Channel | undefined, channelType: Chareturn;}ch.endTask(channelId);+ // The streamed answer was parked while the task was active; it wins+ // over finalText, but must still carry the evidence footer (it used+ // to be dropped on every streaming messaging channel).const deferred = ch.popDeferredResponse(channelId);- const responseText = deferred || text;+ const responseText = deferred && deferred.trim() ? `${deferred}${footer}` : text;if (responseText && responseText.trim()) await ch.send(responseText, channelId, elapsedMs);if (stepCount > 0 && ch.cleanupEphemeralMessages) await ch.cleanupEphemeralMessages(channelId);ch.resetStepCounter(channelId);