From 7127528b7f6e0e6b859db5d73c994f03e9cd63cd Mon Sep 17 00:00:00 2001 From: _Kerman Date: Tue, 28 Jul 2026 18:07:28 +0800 Subject: [PATCH] fix(agent): preserve sent message identity --- packages/core/agent-loop/src/agent.ts | 3 +-- packages/core/agent-loop/tests/interception.spec.ts | 3 ++- packages/core/agent/src/types.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/agent-loop/src/agent.ts b/packages/core/agent-loop/src/agent.ts index 21759b7480..3220c228cc 100644 --- a/packages/core/agent-loop/src/agent.ts +++ b/packages/core/agent-loop/src/agent.ts @@ -101,10 +101,9 @@ export class ReactLoopAgent implements Agent { /** Accept and route one unified send item. */ send( - input: UserMessage, + message: UserMessage, options: SendOptions, ): void { - const message = freezeMessage(input) const { target, wakeup } = options if (target === 'next-step' && !wakeup) { if (this.acceptsNextStep) { diff --git a/packages/core/agent-loop/tests/interception.spec.ts b/packages/core/agent-loop/tests/interception.spec.ts index 3a955304c1..205c1a5752 100644 --- a/packages/core/agent-loop/tests/interception.spec.ts +++ b/packages/core/agent-loop/tests/interception.spec.ts @@ -79,7 +79,7 @@ describe('agent/prompt-submit', () => { expect(userMsg?.type === 'user/message' && userMsg.data.content).toEqual([{ type: 'text', text: 'hello' }]) }) - it('snapshots and freezes input before publishing or awaiting admission', async () => { + it('publishes frozen input without replacing its identity', async () => { const adapter = new MockAdapter([textResponse('ok')]) const ctx = await harness(adapter) const agent = ctx.agentLoop.create(SessionId('owned-input'), { provider: 'mock', model: 'mock' }) @@ -123,6 +123,7 @@ describe('agent/prompt-submit', () => { await idle expect(observed).toHaveLength(1) + expect(observed[0]).toBe(input) expect(observed[0]).toMatchObject({ content: [{ type: 'text', text: 'accepted text' }], source: { kind: 'plugin', plugin: 'accepted source' }, diff --git a/packages/core/agent/src/types.ts b/packages/core/agent/src/types.ts index 168be444db..dcff0478c6 100644 --- a/packages/core/agent/src/types.ts +++ b/packages/core/agent/src/types.ts @@ -148,7 +148,7 @@ export interface Agent { * immediately without opening a turn. If admission closes without a turn, * a context-only boundary appends immediately; context staged beside * steering remains pending with it. - * The agent snapshots and freezes the identified message before publishing or queueing it. + * The agent publishes or queues the identified frozen message as-is. * @param message - identified model-facing content and its producer provenance. * @param options - target queue and wakeup decision. */