learning

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CancelAllBackgroundReviews added in v0.3.13

func CancelAllBackgroundReviews()

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

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 FormatCaptureResult added in v0.3.13

func FormatCaptureResult(out CaptureOutput) (string, error)

FormatCaptureResult JSON-encodes CaptureOutput for Tool.Call.

func FormatPolicyStatus added in v0.3.13

func FormatPolicyStatus(memoryWrite, skillsMode string, fromFile bool) string

FormatPolicyStatus renders effective policy for /learn policy.

func FormatSessionRecall added in v0.3.13

func FormatSessionRecall(hits []capsessionindex.Hit) string

FormatSessionRecall renders FTS hits for the review digest.

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 RenderMemory

func RenderMemory(entries []MemoryEntry) string

RenderMemory serializes entries into a memory.md file body.

func RenderMemoryDocument added in v0.3.13

func RenderMemoryDocument(entries []MemoryEntry, docName string) string

RenderMemoryDocument serializes §-delimited entries with a file title header.

Types

type CaptureApplier added in v0.3.13

type CaptureApplier interface {
	CaptureMemoryAdd(ctx context.Context, text, source string) (string, error)
	CaptureMemoryRemove(ctx context.Context, oldText string) (string, error)
	CaptureSkillPropose(ctx context.Context, name, body, sessionID, focus, source string) (string, error)
}

ApplyCapture applies one learn_capture action via the learning service API.

type CaptureInput added in v0.3.13

type CaptureInput struct {
	Action  string `json:"action" jsonschema:"memory_add | memory_remove | skill_propose"`
	Content string `json:"content,omitempty" jsonschema:"Text for memory_add or skill body for skill_propose"`
	OldText string `json:"old_text,omitempty" jsonschema:"Substring for memory_remove"`
	Name    string `json:"name,omitempty" jsonschema:"Skill name for skill_propose"`
	Focus   string `json:"focus,omitempty" jsonschema:"Short focus for skill_propose"`
}

CaptureInput is the learn_capture tool schema.

type CaptureOutput added in v0.3.13

type CaptureOutput struct {
	OK      bool   `json:"ok"`
	Message string `json:"message"`
}

CaptureOutput is returned to the review model.

func ApplyCapture added in v0.3.13

func ApplyCapture(ctx context.Context, app CaptureApplier, sessionID string, in CaptureInput) (CaptureOutput, error)

type MemoryEntry

type MemoryEntry struct {
	Content string
	Meta    string
}

MemoryEntry is one §-delimited block in memory.md.

func ParseMemory

func ParseMemory(raw string) []MemoryEntry

ParseMemory splits a memory.md body into entries.

type Policy added in v0.3.13

type Policy struct {
	// MemoryWrite: approve (stage background-review) or auto (write memory.md directly).
	MemoryWrite string `json:"memoryWrite,omitempty"`
	// SkillsMode: off, propose (pending workshop), or auto (apply when scanner passes).
	SkillsMode string `json:"skillsMode,omitempty"`
}

Policy is tenant-local overrides for memory/skill write behavior (/learn policy).

func (Policy) Normalized added in v0.3.13

func (p Policy) Normalized() Policy

type PolicyStore added in v0.3.13

type PolicyStore struct {
	Path string
}

PolicyStore persists policy.json under the tenant workspace.

func (*PolicyStore) Clear added in v0.3.13

func (s *PolicyStore) Clear() error

func (*PolicyStore) Load added in v0.3.13

func (s *PolicyStore) Load() (Policy, error)

func (*PolicyStore) Save added in v0.3.13

func (s *PolicyStore) Save(p Policy) 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
}

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
}

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)

type StagedMemory added in v0.3.13

type StagedMemory struct {
	ID        string    `json:"id"`
	Content   string    `json:"content"`
	Source    string    `json:"source"`
	CreatedAt time.Time `json:"createdAt"`
}

StagedMemory is a pending memory write awaiting approval.

type StagedStore added in v0.3.13

type StagedStore struct {
	Dir string
}

StagedStore persists pending memory entries under workspace local root.

func (*StagedStore) Add added in v0.3.13

func (s *StagedStore) Add(entry StagedMemory) error

func (*StagedStore) Clear added in v0.3.13

func (s *StagedStore) Clear() error

Clear removes all staged entries.

func (*StagedStore) List added in v0.3.13

func (s *StagedStore) List() ([]StagedMemory, error)

func (*StagedStore) Remove added in v0.3.13

func (s *StagedStore) Remove(id string) (StagedMemory, error)

Jump to

Keyboard shortcuts

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