kagent

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: 14 Imported by: 0

Documentation

Overview

Package kagent calls the kagent controller's SessionService and the A2A service it serves, through agentgateway, as the caller: every call carries the caller's IdP token as `authorization: Bearer` and nothing else that identifies anyone. agentgateway verifies the token on the controller route and derives the identity header the controller reads from it, replacing any value a client sent; a client that set one would be dead weight through the gateway and impersonation without it.

A2A calls are addressed the way the gateway routes them: the Agent as the request's tenant (<namespace>/<name>) and the session as the message's context id (the controller keeps a session's A2A context equal to its id). The x-kagent-agent-instance-id header is the gateway's to the runtime and is never sent from here.

Index

Constants

View Source
const (
	SchemePlaintext = "grpc"
	SchemeTLS       = "grpcs"
)

Target schemes: plaintext h2c (the in-cluster agentgateway Service) and TLS (a public hostname).

Variables

View Source
var ErrNoToken = errors.New("no caller token")

ErrNoToken is returned for a call without a caller token: there is no other identity to make it with.

Functions

func ParseTarget

func ParseTarget(target string) (hostPort string, useTLS bool, err error)

ParseTarget splits a grpc:// or grpcs:// target into the host:port the gRPC client dials and whether the connection uses TLS. A grpcs target without a port is 443; a grpc target must name its port.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client speaks to one kagent controller. It is safe for concurrent use.

func Dial

func Dial(target string) (*Client, error)

Dial builds a Client for target. The connection is established lazily on the first call.

func NewClient

func NewClient(conn grpc.ClientConnInterface) *Client

NewClient builds a Client on an existing connection (tests use bufconn).

func (*Client) Close

func (c *Client) Close() error

Close releases the connection Dial opened.

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, token string, agent Ref, requestID, name string) (*apiv1alpha1.Session, error)

CreateSession is SessionService/CreateSession for agent. requestID makes a retry idempotent: the controller keys it on (creator, request_id).

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context, token, sessionID string) (*apiv1alpha1.Session, error)

GetSession is SessionService/GetSession.

func (*Client) ListSessionTasks

func (c *Client) ListSessionTasks(ctx context.Context, token string, agent Ref, contextID string) ([]*a2apb.Task, error)

ListSessionTasks is A2AService/ListTasks addressed to the session's Agent and filtered by its context, walked to the end: the conversation, oldest task first, with every task's history and artifacts.

func (*Client) ListSessions

func (c *Client) ListSessions(ctx context.Context, token string, agent Ref, allCreators bool) ([]*apiv1alpha1.Session, error)

ListSessions is SessionService/ListSessions for one Agent, walked to the end. allCreators asks for every person's sessions, which the controller grants only to a caller authorized for it.

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, token string, agent Ref, contextID, messageID, text string) (*a2apb.StreamResponse, error)

SendMessage opens A2AService/SendStreamingMessage with one user text message to the session (the Agent as tenant, the session as the message's context) and answers the first event, the gateway's acknowledgement that the runtime took the turn, then closes the stream: disconnecting an observer does not cancel the turn, and the session's tasks show it finish.

type Ref

type Ref struct {
	Namespace string
	Name      string
}

Ref names an Agent.

func (Ref) Tenant

func (r Ref) Tenant() string

Tenant is the A2A tenant the gateway resolves the Agent from.

Directories

Path Synopsis
gen
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.
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.

Jump to

Keyboard shortcuts

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