utils.go

Overview

The utils.go file provides utility functions that facilitate the handling, inspection, and transformation of session events within the remote agent communication subsystem. It primarily supports the integration of local session events with the Agent-To-Agent (A2A) protocol by identifying specific event types, extracting relevant metadata, and preparing event content for remote invocation contexts.

Key responsibilities include:

This file is an essential helper for bridging session events with the A2A protocol operations, enabling robust event handling and context propagation in distributed agent workflows.


Types and Structs

userFunctionCall

type userFunctionCall struct {
	event     *session.Event
	taskID    a2a.TaskID
	contextID string
}

Functions

getUserFunctionCallAt

func getUserFunctionCallAt(events session.Events, index int) *userFunctionCall

isFunctionCallEvent

func isFunctionCallEvent(event *session.Event, callID string) bool

getFunctionResponseCallID

func getFunctionResponseCallID(event *session.Event) (string, bool)

toMissingRemoteSessionParts

func toMissingRemoteSessionParts(ctx agent.InvocationContext, events session.Events) ([]a2a.Part, string)

presentAsUserMessage

func presentAsUserMessage(ctx agent.InvocationContext, agentEvent *session.Event) *session.Event

Important Implementation Details


Interaction with Other System Components


Visual Diagram

flowchart TD
A[getUserFunctionCallAt] -->|uses| B[getFunctionResponseCallID]
A -->|uses| C[isFunctionCallEvent]
D[toMissingRemoteSessionParts] -->|calls| E[presentAsUserMessage]
D -->|uses| F[adk2a.ToA2AParts]
E -->|creates new| G[session.Event as User Message]
B -->|searches| H[event.Content.Parts]
subgraph Function Call Handling
A
B
C
H
end
subgraph Missing Parts Handling
D
E
F
G
end

This documentation presents a detailed view of the utils.go file’s utilities, their roles in event processing within the remote agent communication system, and their collaboration with other modules for effective distributed agent operation. For broader context, see [Remote Agent Communication (A2A)](80565) and related files such as a2a_agent.go and events.go.