metadata.go

Overview

This file provides utility functions and data structures for managing and converting metadata related to agent invocation and event handling within the Agent-To-Agent (A2A) communication framework. It focuses on constructing consistent metadata keys, extracting invocation context information, and enriching event metadata with additional details required for telemetry, session tracking, and agent interaction.

Key responsibilities include:

This file plays a crucial role in bridging session and invocation context details with A2A event metadata, supporting downstream event processing and telemetry.


Functions and Types

ToA2AMetaKey

func ToA2AMetaKey(key string) string

invocationMeta (struct)

type invocationMeta struct {
    userID    string
    sessionID string
    eventMeta map[string]any
}

toInvocationMeta

func toInvocationMeta(ctx context.Context, config ExecutorConfig, reqCtx *a2asrv.RequestContext) invocationMeta

toEventMeta

func toEventMeta(meta invocationMeta, event *session.Event) (map[string]any, error)

setActionsMeta

func setActionsMeta(meta map[string]any, actions session.EventActions) map[string]any

Important Implementation Details


Interaction with Other System Components


File Structure Diagram

classDiagram
class invocationMeta {
- userID: string
- sessionID: string
- eventMeta: map[string]any
}
class ToA2AMetaKey {
<<function>>
}
class toInvocationMeta {
<<function>>
}
class toEventMeta {
<<function>>
}
class setActionsMeta {
<<function>>
}
invocationMeta <.. toInvocationMeta : returns
toInvocationMeta --> ToA2AMetaKey : uses
toEventMeta --> ToA2AMetaKey : uses
setActionsMeta ..> session.EventActions : reads

This diagram shows the primary data structure invocationMeta and the main functions operating on metadata. The dependency on the key-prefixing function ToA2AMetaKey is highlighted, illustrating how metadata keys are constructed consistently across functions. The relation to session.EventActions is indicated for action metadata management.