Documentation
¶
Index ¶
- Variables
- func EventsFromSession(sess adksession.Session) []*adksession.Event
- func NewService(dbURL string, controllerClient *controllerclient.Client) (adksession.Service, error)
- type KAgentSessionService
- func (s *KAgentSessionService) AppendEvent(ctx context.Context, adkSess adksession.Session, event *adksession.Event) error
- func (s *KAgentSessionService) Create(ctx context.Context, req *adksession.CreateRequest) (*adksession.CreateResponse, error)
- func (s *KAgentSessionService) CreateSession(ctx context.Context, appName, userID string, state map[string]any, ...) error
- func (s *KAgentSessionService) Delete(ctx context.Context, req *adksession.DeleteRequest) error
- func (s *KAgentSessionService) Get(ctx context.Context, req *adksession.GetRequest) (*adksession.GetResponse, error)
- func (s *KAgentSessionService) GetSession(ctx context.Context, appName, userID, sessionID string) (adksession.Session, error)
- func (s *KAgentSessionService) List(_ context.Context, _ *adksession.ListRequest) (*adksession.ListResponse, error)
- type LocalSessionService
Constants ¶
This section is empty.
Variables ¶
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 ¶
func (s *KAgentSessionService) Create(ctx context.Context, req *adksession.CreateRequest) (*adksession.CreateResponse, error)
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 ¶
func (s *KAgentSessionService) Delete(ctx context.Context, req *adksession.DeleteRequest) error
Delete implements adksession.Service.
func (*KAgentSessionService) Get ¶
func (s *KAgentSessionService) Get(ctx context.Context, req *adksession.GetRequest) (*adksession.GetResponse, error)
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 ¶
func (s *KAgentSessionService) List(_ context.Context, _ *adksession.ListRequest) (*adksession.ListResponse, error)
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.