Documentation
¶
Index ¶
- Constants
- func IsSessionBusy(err error) bool
- type CompactRequest
- type CompactionConfig
- type CompactionStrategy
- type CompactionSummarizeInput
- type CompactionSummarizeResult
- type Config
- type ContextUsage
- type LifecycleInfo
- type MapReduceCompactionStrategy
- type MapReduceCompactionStrategyConfig
- type RunLifecycleStatus
- type RunRequest
- type RunState
- type RunStateRequest
- type Runtime
- func (r *Runtime) Compact(ctx context.Context, req CompactRequest) (*session.Event, error)
- func (r *Runtime) ContextUsage(ctx context.Context, req UsageRequest) (ContextUsage, error)
- func (r *Runtime) Run(ctx context.Context, req RunRequest) iter.Seq2[*session.Event, error]
- func (r *Runtime) RunState(ctx context.Context, req RunStateRequest) (RunState, error)
- type SessionBusyError
- type UsageRequest
Constants ¶
const ( // ContractVersionV1 is the first stable runtime event contract version. ContractVersionV1 = "v1" // MetaContractVersion marks runtime event contract version in event meta. MetaContractVersion = "contract_version" // MetaLifecycle is the payload key for lifecycle details. MetaLifecycle = "lifecycle" )
Variables ¶
This section is empty.
Functions ¶
func IsSessionBusy ¶
Types ¶
type CompactRequest ¶
type CompactRequest struct {
AppName string
UserID string
SessionID string
Model model.LLM
Note string
ContextWindowTokens int
}
CompactRequest defines one manual compaction call.
type CompactionConfig ¶
type CompactionConfig struct {
Enabled bool
WatermarkRatio float64
MinWatermarkRatio float64
MaxWatermarkRatio float64
DefaultContextWindowTokens int
ReserveOutputTokens int
SafetyMarginTokens int
PreserveRecentTurns int
SummaryChunkTokens int
MaxModelSummaryRetries int
Strategy CompactionStrategy
}
CompactionConfig configures runtime history compaction behavior.
type CompactionStrategy ¶
type CompactionStrategy interface {
Summarize(context.Context, model.LLM, CompactionSummarizeInput) (CompactionSummarizeResult, error)
}
CompactionStrategy abstracts how runtime summarizes history chunks.
func DefaultCompactionStrategy ¶
func DefaultCompactionStrategy() CompactionStrategy
DefaultCompactionStrategy returns kernel default compaction strategy.
type CompactionSummarizeInput ¶
type CompactionSummarizeInput struct {
Events []*session.Event
InputBudget int
SummaryChunkTokens int
MaxModelSummaryRetries int
}
CompactionSummarizeInput describes compaction summarization input.
type CompactionSummarizeResult ¶
CompactionSummarizeResult is one compaction summary result.
type Config ¶
type Config struct {
Store session.Store
Compaction CompactionConfig
}
Config configures Runtime.
type ContextUsage ¶
type ContextUsage struct {
CurrentTokens int
WindowTokens int
InputBudget int
Ratio float64
EventCount int
}
ContextUsage is the estimated token usage snapshot for current session window.
type LifecycleInfo ¶
type LifecycleInfo struct {
Status RunLifecycleStatus
Phase string
Error string
ErrorCode toolexec.ErrorCode
}
LifecycleInfo is parsed lifecycle state from one lifecycle event.
func LifecycleFromEvent ¶
func LifecycleFromEvent(ev *session.Event) (LifecycleInfo, bool)
LifecycleFromEvent extracts lifecycle info from one runtime lifecycle event.
type MapReduceCompactionStrategy ¶
type MapReduceCompactionStrategy struct {
// contains filtered or unexported fields
}
MapReduceCompactionStrategy is default token-budgeted compaction strategy.
func NewMapReduceCompactionStrategy ¶
func NewMapReduceCompactionStrategy(cfg MapReduceCompactionStrategyConfig) *MapReduceCompactionStrategy
NewMapReduceCompactionStrategy builds one map-reduce compaction strategy.
func (*MapReduceCompactionStrategy) Summarize ¶
func (s *MapReduceCompactionStrategy) Summarize( ctx context.Context, llm model.LLM, in CompactionSummarizeInput, ) (CompactionSummarizeResult, error)
type MapReduceCompactionStrategyConfig ¶
type MapReduceCompactionStrategyConfig struct {
SystemPrompt string
UserPrefix string
MergePrefix string
}
MapReduceCompactionStrategyConfig configures default map-reduce compaction.
type RunLifecycleStatus ¶
type RunLifecycleStatus string
RunLifecycleStatus is a machine-readable runtime run status.
const ( RunLifecycleStatusRunning RunLifecycleStatus = "running" RunLifecycleStatusWaitingApproval RunLifecycleStatus = "waiting_approval" RunLifecycleStatusInterrupted RunLifecycleStatus = "interrupted" RunLifecycleStatusFailed RunLifecycleStatus = "failed" RunLifecycleStatusCompleted RunLifecycleStatus = "completed" )
type RunRequest ¶
type RunRequest struct {
AppName string
UserID string
SessionID string
Input string
Agent agent.Agent
Model model.LLM
Tools []tool.Tool
CoreTools tool.CoreToolsConfig
Policies []policy.Hook
LSPBroker *lspbroker.Broker
LSPActivationTools []string
AutoActivateLSP []string
PersistPartialEvents bool
ContextWindowTokens int
}
RunRequest defines one invocation input.
type RunState ¶
type RunState struct {
HasLifecycle bool
Status RunLifecycleStatus
Phase string
Error string
ErrorCode toolexec.ErrorCode
EventID string
UpdatedAt time.Time
}
RunState is the latest lifecycle status snapshot for one session.
type RunStateRequest ¶
RunStateRequest defines one run-state query.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime orchestrates session lifecycle and agent execution.
func (*Runtime) ContextUsage ¶
func (r *Runtime) ContextUsage(ctx context.Context, req UsageRequest) (ContextUsage, error)
ContextUsage returns current session context usage estimation.
type SessionBusyError ¶
SessionBusyError indicates one session already has an in-flight run.
func (*SessionBusyError) Code ¶
func (e *SessionBusyError) Code() toolexec.ErrorCode
func (*SessionBusyError) Error ¶
func (e *SessionBusyError) Error() string