Implementing support for recitations events in responses from A2A Server (#12067)

Co-authored-by: Alisa Novikova <alisanovikova@google.com>
This commit is contained in:
Alisa
2025-10-27 11:56:08 -07:00
committed by GitHub
parent 0e4dce23b2
commit 29efebe38f
3 changed files with 88 additions and 3 deletions

View File

@@ -49,6 +49,7 @@ import type {
TaskMetadata,
Thought,
ThoughtSummary,
Citation,
} from '../types.js';
import type { PartUnion, Part as genAiPart } from '@google/genai';
@@ -638,6 +639,10 @@ export class Task {
logger.info('[Task] Sending agent thought...');
this._sendThought(event.value, traceId);
break;
case GeminiEventType.Citation:
logger.info('[Task] Received citation from LLM stream.');
this._sendCitation(event.value);
break;
case GeminiEventType.ChatCompressed:
break;
case GeminiEventType.Finished:
@@ -979,4 +984,18 @@ export class Task {
),
);
}
_sendCitation(citation: string) {
if (!citation || citation.trim() === '') {
return;
}
logger.info('[Task] Sending citation to event bus.');
const message = this._createTextMessage(citation);
const citationEvent: Citation = {
kind: CoderAgentEvent.CitationEvent,
};
this.eventBus?.publish(
this._createStatusUpdateEvent(this.taskState, citationEvent, message),
);
}
}