feat: Propagate traceId from code assist to response metadata (Fixes … (#11360)

Co-authored-by: owenofbrien <86964623+owenofbrien@users.noreply.github.com>
This commit is contained in:
Paweł Dec
2025-10-20 22:00:24 +02:00
committed by GitHub
parent 085e5b1f4d
commit 36de686224
7 changed files with 187 additions and 6 deletions
+28
View File
@@ -624,4 +624,32 @@ describe('E2E Tests', () => {
assertUniqueFinalEventIsLast(events);
expect(events.length).toBe(10);
});
it('should include traceId in status updates when available', async () => {
const traceId = 'test-trace-id';
sendMessageStreamSpy.mockImplementation(async function* () {
yield* [
{ type: 'content', value: 'Hello', traceId },
{ type: 'thought', value: { subject: 'Thinking...' }, traceId },
];
});
const agent = request.agent(app);
const res = await agent
.post('/')
.send(createStreamMessageRequest('hello', 'a2a-trace-id-test'))
.set('Content-Type', 'application/json')
.expect(200);
const events = streamToSSEEvents(res.text);
// The first two events are task-creation and working status
const textContentEvent = events[2].result as TaskStatusUpdateEvent;
expect(textContentEvent.kind).toBe('status-update');
expect(textContentEvent.metadata?.['traceId']).toBe(traceId);
const thoughtEvent = events[3].result as TaskStatusUpdateEvent;
expect(thoughtEvent.kind).toBe('status-update');
expect(thoughtEvent.metadata?.['traceId']).toBe(traceId);
});
});