kagenttest

package
v1.11.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package kagenttest is a fake kagent controller for tests: SessionService and lf.a2a.v1.A2AService on an in-memory gRPC connection, addressed the way the A2A gateway routes (the Agent as tenant, the session as the message's context), recording every call's metadata.

Index

Constants

View Source
const Creator = "admin@lab.local"

Creator is the creator the fake records on every session it creates.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Method   string
	Metadata metadata.MD
	Request  proto.Message
}

Call is one RPC the fake served.

type Controller

type Controller struct {
	apiv1alpha1.UnimplementedSessionServiceServer
	a2apb.UnimplementedA2AServiceServer

	// NotReady holds the tenants (<namespace>/<name>) whose CreateSession
	// answers FailedPrecondition, as an Agent without a ready revision does.
	NotReady map[string]bool
	// Fail makes a method (its bare name, e.g. "ListSessions") answer the error.
	Fail map[string]error
	// contains filtered or unexported fields
}

Controller is the fake's state. Seed it before the calls; read it after.

func New

func New(t *testing.T) (*Controller, *grpc.ClientConn)

New starts the fake and answers a client connection to it. Both stop with the test.

func (*Controller) AddSession

func (c *Controller) AddSession(namespace, name string, tasks ...*a2apb.Task) *apiv1alpha1.Session

AddSession seeds a READY session of agent and its tasks; it answers the session.

func (*Controller) Calls

func (c *Controller) Calls() []Call

Calls answers the calls served so far, in order.

func (*Controller) CreateSession

CreateSession implements SessionService: idempotent on request_id, refused for a NotReady Agent.

func (*Controller) GetSession

GetSession implements SessionService.

func (*Controller) ListSessions

ListSessions implements SessionService.

func (*Controller) ListTasks

ListTasks implements A2AService: the tasks of the context, through the session's Agent.

func (*Controller) SendStreamingMessage

func (c *Controller) SendStreamingMessage(req *a2apb.SendMessageRequest, stream grpc.ServerStreamingServer[a2apb.StreamResponse]) error

SendStreamingMessage implements A2AService: the turn is accepted (a task in SUBMITTED), held open until the client hangs up, then finished with the agent's reply, as a turn outlives its observer.

func (*Controller) Tasks

func (c *Controller) Tasks(contextID string) []*a2apb.Task

Tasks answers the tasks of a session's context.

func (*Controller) TurnEnded

func (c *Controller) TurnEnded() <-chan struct{}

TurnEnded is signalled when a SendStreamingMessage stream ends: the client hung up, and the fake finishes the turn regardless, as the gateway does.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL