learning

package
v0.3.18 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMemoryNudgeInterval = 10

DefaultMemoryNudgeInterval is Hermes memory.nudge_interval (user turns between background memory reviews).

Variables

This section is empty.

Functions

func CancelAllBackgroundReviews added in v0.3.13

func CancelAllBackgroundReviews()

CancelAllBackgroundReviews stops every in-flight review (runner shutdown).

func CountUserTurns added in v0.3.14

func CountUserTurns(messages []agentkit.ModelMessage) int

CountUserTurns counts user-role messages with non-empty text (slash commands still count as turns).

func DecideMemoryNudge added in v0.3.14

func DecideMemoryNudge(
	interval int,
	messages []agentkit.ModelMessage,
	prior NudgeSessionState,
	hydrateFromHistory bool,
) (MemoryNudgeDecision, NudgeSessionState)

DecideMemoryNudge applies Hermes-style cadence: increment per completed user turn; reset when memory tool ran; run review when turnsSince >= interval. interval <= 0 disables automatic memory review.

func DigestMessages added in v0.3.13

func DigestMessages(messages []agentkit.ModelMessage, limit int) string

DigestMessages formats recent model-visible messages for the review prompt.

func FormatSkillsPolicyStatus added in v0.3.14

func FormatSkillsPolicyStatus(skillsMode string, fromFile bool) string

FormatSkillsPolicyStatus renders /learn policy output.

func Go added in v0.3.15

func Go(fn func())

Go runs fn in a tracked goroutine (used by hook/background-review).

func RegisterGlobalReviewRuns added in v0.3.13

func RegisterGlobalReviewRuns(r *ReviewRunRegistry)

RegisterGlobalReviewRuns wires an alternate registry into process shutdown (tests only). Production code uses GlobalReviewRuns.

func TruncateEllipsis added in v0.3.14

func TruncateEllipsis(s string, max int) string

TruncateEllipsis shortens s to at most max bytes and appends an ellipsis rune.

func TurnSegmentUsedMemoryTool added in v0.3.14

func TurnSegmentUsedMemoryTool(messages []agentkit.ModelMessage) bool

TurnSegmentUsedMemoryTool reports whether the current turn (since the last user message) invoked memory.

func WaitBackgroundReviews added in v0.3.15

func WaitBackgroundReviews(ctx context.Context) error

WaitBackgroundReviews blocks until tracked review goroutines finish or ctx is done.

Types

type CaptureInput added in v0.3.13

type CaptureInput = caplearning.CaptureInput

type CaptureOutput added in v0.3.13

type CaptureOutput = caplearning.CaptureOutput

func ApplyCapture added in v0.3.13

func ApplyCapture(ctx context.Context, mem capmemory.Capture, skills caplearning.SkillProposer, sessionID string, in CaptureInput) (CaptureOutput, error)

ApplyCapture applies one learn_capture action via memory capture + skill proposer.

type MemoryNudgeDecision added in v0.3.14

type MemoryNudgeDecision struct {
	RunReview        bool
	TurnsSinceMemory int
	Reason           string
}

MemoryNudgeDecision is whether to spawn background memory review after this turn.

type NudgeFile added in v0.3.14

type NudgeFile struct {
	Sessions map[string]NudgeSessionState `json:"sessions"`
}

NudgeFile maps session IDs to nudge counters (per tenant workspace file).

type NudgeSessionState added in v0.3.14

type NudgeSessionState = caplearning.NudgeSessionState

NudgeSessionState tracks background memory review cadence for one conversation.

type NudgeStore added in v0.3.14

type NudgeStore struct {
	Path string
}

NudgeStore persists per-session memory review cadence.

func (*NudgeStore) LoadSession added in v0.3.14

func (s *NudgeStore) LoadSession(sessionID string) (NudgeSessionState, bool, error)

func (*NudgeStore) SaveSession added in v0.3.14

func (s *NudgeStore) SaveSession(sessionID string, st NudgeSessionState) error

type QuotaStore added in v0.3.13

type QuotaStore struct {
	Path string
}

QuotaStore persists review_quota.json under memory/dreaming/.

func (*QuotaStore) TryConsume added in v0.3.13

func (q *QuotaStore) TryConsume(maxPerDay int, now time.Time) (bool, error)

type ReviewConfig added in v0.3.13

type ReviewConfig struct {
	MaxSteps          int
	MaxDigestMessages int
	// SessionRecall is optional FTS hits from prior sessions (appended to the digest).
	SessionRecall string
	// SignalCandidates is optional grounded dreaming signals for consolidation.
	SignalCandidates string
}

ReviewConfig controls the background review LLM loop.

type ReviewQuota added in v0.3.13

type ReviewQuota struct {
	Date  string `json:"date"`
	Count int    `json:"count"`
}

ReviewQuota tracks per-day background review runs for throttling.

type ReviewResult added in v0.3.13

type ReviewResult struct {
	Summary      string
	Steps        int
	InputTokens  int
	OutputTokens int
	Cancelled    bool
	// Notices are user-visible lines from successful learn_capture memory/skill actions.
	Notices []string
}

ReviewResult summarizes one background review run.

func RunReview added in v0.3.13

func RunReview(
	ctx context.Context,
	cfg ReviewConfig,
	llm agentkit.LLMProvider,
	tools agentkit.ToolRuntime,
	model string,
	transcript []agentkit.ModelMessage,
) (*ReviewResult, error)

RunReview executes a isolated tool loop against the conversation digest.

type ReviewRunRegistry added in v0.3.13

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

ReviewRunRegistry cancels in-flight background reviews (per session + global shutdown).

func GlobalReviewRuns added in v0.3.13

func GlobalReviewRuns() *ReviewRunRegistry

GlobalReviewRuns is the process-wide registry used by hook/background-review.

func (*ReviewRunRegistry) Begin added in v0.3.13

func (r *ReviewRunRegistry) Begin(parent context.Context, sessionKey string) (context.Context, context.CancelFunc)

func (*ReviewRunRegistry) CancelAll added in v0.3.13

func (r *ReviewRunRegistry) CancelAll()

func (*ReviewRunRegistry) End added in v0.3.13

func (r *ReviewRunRegistry) End(sessionKey string)

func (*ReviewRunRegistry) Go added in v0.3.15

func (r *ReviewRunRegistry) Go(fn func())

func (*ReviewRunRegistry) Wait added in v0.3.15

func (r *ReviewRunRegistry) Wait(ctx context.Context) error

type SkillsPolicy added in v0.3.14

type SkillsPolicy struct {
	SkillsMode string `json:"skillsMode,omitempty"` // off | propose | auto
}

SkillsPolicy is tenant-local skill workshop capture mode.

func (SkillsPolicy) Normalized added in v0.3.14

func (p SkillsPolicy) Normalized() SkillsPolicy

type SkillsPolicyStore added in v0.3.14

type SkillsPolicyStore struct {
	Path string
}

SkillsPolicyStore persists learning/policy.json (relative to memory root).

func (*SkillsPolicyStore) Load added in v0.3.14

func (s *SkillsPolicyStore) Load() (SkillsPolicy, error)

func (*SkillsPolicyStore) Save added in v0.3.14

Jump to

Keyboard shortcuts

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