{"modulePath":"github.com/rossoctl/cortex/core","version":"v0.0.0-20261203232816-53bd38a4e073","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package evolve\n\nPackage evolve connects Cortex to altk-evolve, a service that learns guidelines from agent trajectories ([https://github.com/AgentToolkit/altk-evolve](https://github.com/AgentToolkit/altk-evolve)), using only the tools a stock \\`evolve-mcp --transport sse\\` server exposes.\n\nThe plugin does two things, both optional:\n\n  - 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 \\\u003cevolve-guidelines\u003e block. The block is byte-stable across turns so prompt caching keeps working.\n  - 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.\n\nBy 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.\n\nEvery failure fails open. Evolve unreachable, slow, or returning nonsense means the request goes upstream untouched; the guidelines are an improvement, never a dependency.\n\n## Variables\n\n```go\nvar ErrUnavailable = errors.New(\"evolve unavailable\")\n```\nErrUnavailable 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.\n\n## Types\n\n```go\ntype Batch struct {\n\tSource         string `json:\"source\"`\n\tConversationID string `json:\"conversation_id\"`\n\tBatchID        string `json:\"batch_id\"`\n\tScope          string `json:\"scope,omitempty\"`\n}\n```\nBatch is evolve's idempotency key for one bounded contribution to a conversation: re-sending the same batch is skipped by evolve.\n\n```go\ntype Evolve interface {\n\t// Guidelines returns the guidelines relevant to a task from a namespace.\n\tGuidelines(ctx context.Context, namespace, task, sessionID string) ([]Guideline, error)\n\t// Learn sends a trajectory batch to evolve, which generates guidelines from\n\t// it into namespace.\n\tLearn(ctx context.Context, namespace string, t Trajectory) error\n}\n```\nEvolve 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.\n\n```go\ntype Guideline struct {\n\tID       string\n\tContent  string\n\tRevision *int\n\t// Source is the trajectory the guideline was learned from (its source task\n\t// id), or several, comma-separated, for a guideline consolidated from more\n\t// than one.\n\tSource string\n}\n```\nGuideline is one served guideline plus the provenance agentop shows for it.\n\n```go\ntype Plugin struct {\n\t// contains filtered or unexported fields\n}\n```\nPlugin is the evolve plugin.\n\n```go\nfunc New() *Plugin\n```\n\n```go\nfunc (p *Plugin) Capabilities() pipeline.PluginCapabilities\n```\n\n```go\nfunc (p *Plugin) ConfigSchema() []pipeline.FieldSchema\n```\nConfigSchema implements pipeline.SchemaProvider.\n\n```go\nfunc (p *Plugin) Configure(raw json.RawMessage) error\n```\n\n```go\nfunc (p *Plugin) Init(context.Context) error\n```\nInit starts the idle-session sender.\n\n```go\nfunc (p *Plugin) Metrics() []pipeline.Metric\n```\nMetrics implements pipeline.MetricsProvider.\n\n```go\nfunc (p *Plugin) Name() string\n```\n\n```go\nfunc (p *Plugin) OnFinish(_ context.Context, pctx *pipeline.Context)\n```\nOnFinish records the completed turn for learning. It runs after the response is on the wire, and only appends to the session's recorder.\n\n```go\nfunc (p *Plugin) OnRequest(ctx context.Context, pctx *pipeline.Context) (action pipeline.Action)\n```\n\n```go\nfunc (p *Plugin) OnResponse(context.Context, *pipeline.Context) pipeline.Action\n```\n\n```go\nfunc (p *Plugin) RawConfig() json.RawMessage\n```\nRawConfig implements pipeline.RawConfigProvider.\n\n```go\nfunc (p *Plugin) Shutdown(ctx context.Context) error\n```\nShutdown stops the sender. Unsent turns are dropped: learning is best-effort, and a restart is not worth delaying for an LLM call.\n\n```go\ntype Trajectory struct {\n\tMessages        []map[string]any `json:\"messages\"`\n\tContextMessages []map[string]any `json:\"context_messages,omitempty\"`\n\tBatch           *Batch           `json:\"batch,omitempty\"`\n\tTraceID         string           `json:\"trace_id,omitempty\"`\n\tModel           string           `json:\"model,omitempty\"`\n\tMetadata        map[string]any   `json:\"metadata,omitempty\"`\n}\n```\nTrajectory is evolve's processing input (altk\\_evolve.processing.Trajectory).\n\n","path":"github.com/rossoctl/cortex/core/plugins/evolve","name":"evolve","synopsis":"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.","isRedistributable":true}
