session

package
v0.0.0-...-52774d3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionNotFound = errors.New("session not found")

ErrSessionNotFound indicates the requested persisted session does not exist.

Functions

func EventsFromSession

func EventsFromSession(sess adksession.Session) []*adksession.Event

EventsFromSession extracts the typed event slice from an adksession.Session. If the underlying session is a *localSession (as created by KAgentSessionService), it returns the slice directly. Otherwise it falls back to iterating Events().

func NewService

func NewService(dbURL string, controllerClient *controllerclient.Client) (adksession.Service, error)

NewService builds the session service a runtime should use: dbURL (AgentConfig.session_db_url, set by the controller for durable-dir sandbox agents) selects the actor-local sqlite store; otherwise controllerClient selects the controller gRPC session service; otherwise nil (caller decides; typically in-memory sessions). BYO agents building their own executor should use this to populate KAgentExecutorConfig.SessionService so they honor the same contract as the declarative runtime.

Types

type KAgentSessionService

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

func NewKAgentSessionService

func NewKAgentSessionService(client *controllerclient.Client) *KAgentSessionService

NewKAgentSessionService creates a new KAgentSessionService.

func (*KAgentSessionService) AppendEvent

func (s *KAgentSessionService) AppendEvent(ctx context.Context, adkSess adksession.Session, event *adksession.Event) error

AppendEvent implements adksession.Service. Persists the event to the KAgent backend (mirroring Python's append_event which POSTs event.model_dump_json()), then updates the in-memory localSession so subsequent reads within the same request see the new event (mirroring Python's super().append_event() call).

func (*KAgentSessionService) Create

Create implements adksession.Service.

func (*KAgentSessionService) CreateSession

func (s *KAgentSessionService) CreateSession(ctx context.Context, appName, userID string, state map[string]any, sessionID string) error

CreateSession is a convenience wrapper used by beforeExecute.

func (*KAgentSessionService) Delete

Delete implements adksession.Service.

func (*KAgentSessionService) Get

Get implements adksession.Service. Fetches the session and its events from the KAgent API, deserialising each raw event payload into a typed *adksession.Event — mirroring Python's KAgentSessionService.get_session() which calls Event.model_validate_json().

func (*KAgentSessionService) GetSession

func (s *KAgentSessionService) GetSession(ctx context.Context, appName, userID, sessionID string) (adksession.Session, error)

GetSession is a convenience wrapper used by beforeExecute to fetch a session without going through the ADK request/response envelope. Returns (nil, nil) when the session does not exist.

func (*KAgentSessionService) List

List implements adksession.Service.

type LocalSessionService

type LocalSessionService struct {
	adksession.Service
}

LocalSessionService is used by substrate sandbox agents to store ADK session state in a local sqlite DB. The DB lives inside the actor's durableDir volume (AgentConfig.session_db_url, set by the controller in the rendered config Secret).

func NewLocalSessionService

func NewLocalSessionService(dbURL string) (*LocalSessionService, error)

NewLocalSessionService opens (creating if needed) the sqlite DB named by dbURL (e.g. "sqlite:////data/sessions.db") and migrates the upstream ADK schema.

Jump to

Keyboard shortcuts

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