Skip to content

Commit f8601f8

Browse files
committed
Updates made to allow Orchestrator UI to display which A2A Agent was in charge of putting together the reponse message.
See https://screenshot.googleplex.com/7FX9rvH4sEpezdq for demo.
1 parent c2a753a commit f8601f8

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

angular/projects/a2a-chat-canvas/src/lib/services/chat-service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,17 @@ export class ChatService {
146146
(part): UiMessageContent => convertPartToUiMessageContent(part, this.partResolvers),
147147
);
148148

149+
const adkAuthor = response.result.metadata?.['adk_author'];
150+
const additionalMetadata = adkAuthor ? {'adk_author': adkAuthor} : null;
151+
149152
this.updateLastMessage((msg) => ({
150153
...msg,
151154
contents: [...msg.contents, ...newContents],
152155
status: 'completed',
153156
lastUpdated: new Date().toISOString(),
157+
...(additionalMetadata
158+
? { metadata: {...msg.metadata, ...additionalMetadata} }
159+
: {}),
154160
}));
155161

156162
// Let A2UI Renderer process the A2UI data parts in agent response.

angular/projects/a2a-chat-canvas/src/lib/types/ui-message.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export interface UiMessage {
1919
readonly created: string;
2020
/** ISO timestamp of when the message was last updated. */
2121
readonly lastUpdated: string;
22+
/** Optional metadata for auxiliar data related to the message. */
23+
readonly metadata?: {
24+
[k: string]: unknown;
25+
}
2226
}
2327

2428
/**

angular/projects/orchestrator/src/message-decorator/demo-message-decorator.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
<ng-container *ngTemplateOutlet="coreContentTemplateRef()"></ng-container>
1818

1919
@if (message().role.type === 'ui_agent' && message().status === 'completed') {
20+
@if (agentName()) {
21+
<div class="agent-credit">
22+
Response generated by {{agentName()}}
23+
</div>
24+
}
2025
<div class="message-actions">
2126
<button matIconButton>
2227
<mat-icon fontSet="material-icons-outlined">thumb_up</mat-icon>

angular/projects/orchestrator/src/message-decorator/demo-message-decorator.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
.agent-credit {
16+
display: flex;
17+
flex-direction: row;
18+
font-size: 0.8rem;
19+
color: var(--n-60);
20+
}
21+
1522
.message-actions {
1623
display: flex;
1724
flex-direction: row;

angular/projects/orchestrator/src/message-decorator/demo-message-decorator.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from '@a2a_chat_canvas/components/chat/chat-history/message-decorator/types';
2121
import { UiMessage } from '@a2a_chat_canvas/types/ui-message'; // Assuming path based on context
2222
import { NgTemplateOutlet } from '@angular/common';
23-
import { Component, input, TemplateRef } from '@angular/core';
23+
import { Component, computed, input, TemplateRef, Signal } from '@angular/core';
2424
import { MatIconButton } from '@angular/material/button';
2525
import { MatIcon } from '@angular/material/icon';
2626

@@ -31,9 +31,18 @@ import { MatIcon } from '@angular/material/icon';
3131
imports: [MatIcon, MatIconButton, NgTemplateOutlet],
3232
})
3333
export class DemoMessageDecoratorComponent implements MessageDecoratorComponent {
34-
readonly message = input.required<UiMessage>();
34+
private readonly adkAuthorToAgentName: Record<string, string> = {
35+
'orchestrator_agent': 'Orchestrator Agent',
36+
'Ecommerce_Dashboard_Agent': 'Ecommerce Dashboard Agent',
37+
'Restaurant_Agent': 'Restaurant Agent',
38+
'Contact_Lookup_Agent': 'Contact Lookup Agent',
39+
} as const;
3540

41+
readonly message = input.required<UiMessage>();
3642
readonly coreContentTemplateRef = input.required<TemplateRef<unknown>>();
43+
44+
readonly agentName: Signal<string | null> = computed(() => this.adkAuthor() ? this.adkAuthorToAgentName[this.adkAuthor()!] : null);
45+
private readonly adkAuthor: Signal<string | null> = computed(() => this.message().metadata?.['adk_author'] as string | null);
3746
}
3847

3948
export const demoMessageDecorator: MessageDecorator = async () => {

0 commit comments

Comments
 (0)