evolve

package
v0.0.0-...-53bd38a Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package evolve connects Cortex to altk-evolve, a service that learns guidelines from agent trajectories (https://github.com/AgentToolkit/altk-evolve), using only the tools a stock `evolve-mcp --transport sse` server exposes.

The plugin does two things, both optional:

  • Inject. On a session's first main-agent inference request it asks evolve (get_guidelines_with_attribution) for the guidelines relevant to the session's task in the serve namespace, caches them per session, and appends them to the system instructions of every main-agent request in that session as a delimited <evolve-guidelines> block. The block is byte-stable across turns so prompt caching keeps working.
  • Learn. It records each completed main-agent turn as OpenAI chat messages and, when the session has been idle for idle_after_seconds, sends the new turns to evolve (process_trajectory) as one identified batch. Evolve generates guidelines from them into the learn namespace.

By default the two namespaces are a review gate. Session content includes tool output the agent read, so a guideline distilled from it can carry text an attacker wrote. Learned guidelines therefore land in learn_namespace, which is not injected from; a person copies the ones worth keeping into serve_namespace. Setting the two to the same namespace skips the review: whatever evolve learns is served to the next session.

Every failure fails open. Evolve unreachable, slow, or returning nonsense means the request goes upstream untouched; the guidelines are an improvement, never a dependency.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("evolve unavailable")

ErrUnavailable wraps every failure to get an answer from evolve: transport errors, timeouts, tool errors and undecodable results. The plugin fails open on all of them.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	Source         string `json:"source"`
	ConversationID string `json:"conversation_id"`
	BatchID        string `json:"batch_id"`
	Scope          string `json:"scope,omitempty"`
}

Batch is evolve's idempotency key for one bounded contribution to a conversation: re-sending the same batch is skipped by evolve.

type Evolve

type Evolve interface {
	// Guidelines returns the guidelines relevant to a task from a namespace.
	Guidelines(ctx context.Context, namespace, task, sessionID string) ([]Guideline, error)
	// Learn sends a trajectory batch to evolve, which generates guidelines from
	// it into namespace.
	Learn(ctx context.Context, namespace string, t Trajectory) error
}

Evolve is the plugin's view of an altk-evolve service. The concrete implementation (mcpEvolve) calls the stock evolve MCP server's tools; tests inject a fake.

type Guideline

type Guideline struct {
	ID       string
	Content  string
	Revision *int
	// Source is the trajectory the guideline was learned from (its source task
	// id), or several, comma-separated, for a guideline consolidated from more
	// than one.
	Source string
}

Guideline is one served guideline plus the provenance agentop shows for it.

type Plugin

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

Plugin is the evolve plugin.

func New

func New() *Plugin

func (*Plugin) Capabilities

func (p *Plugin) Capabilities() pipeline.PluginCapabilities

func (*Plugin) ConfigSchema

func (p *Plugin) ConfigSchema() []pipeline.FieldSchema

ConfigSchema implements pipeline.SchemaProvider.

func (*Plugin) Configure

func (p *Plugin) Configure(raw json.RawMessage) error

func (*Plugin) Init

func (p *Plugin) Init(context.Context) error

Init starts the idle-session sender.

func (*Plugin) Metrics

func (p *Plugin) Metrics() []pipeline.Metric

Metrics implements pipeline.MetricsProvider.

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) OnFinish

func (p *Plugin) OnFinish(_ context.Context, pctx *pipeline.Context)

OnFinish records the completed turn for learning. It runs after the response is on the wire, and only appends to the session's recorder.

func (*Plugin) OnRequest

func (p *Plugin) OnRequest(ctx context.Context, pctx *pipeline.Context) (action pipeline.Action)

func (*Plugin) OnResponse

func (*Plugin) RawConfig

func (p *Plugin) RawConfig() json.RawMessage

RawConfig implements pipeline.RawConfigProvider.

func (*Plugin) Shutdown

func (p *Plugin) Shutdown(ctx context.Context) error

Shutdown stops the sender. Unsent turns are dropped: learning is best-effort, and a restart is not worth delaying for an LLM call.

type Trajectory

type Trajectory struct {
	Messages        []map[string]any `json:"messages"`
	ContextMessages []map[string]any `json:"context_messages,omitempty"`
	Batch           *Batch           `json:"batch,omitempty"`
	TraceID         string           `json:"trace_id,omitempty"`
	Model           string           `json:"model,omitempty"`
	Metadata        map[string]any   `json:"metadata,omitempty"`
}

Trajectory is evolve's processing input (altk_evolve.processing.Trajectory).

Jump to

Keyboard shortcuts

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