Nous.Decisions.ContextBuilder (nous v0.16.2)

View Source

Builds a text summary of the decision graph for system prompt injection.

Queries the decision store for active goals and recent decisions, then formats them into a human-readable string suitable for inclusion in an agent's system prompt.

Architecture

The context builder is a pure function module -- it reads from the store but does not modify it. It is called by Nous.Plugins.Decisions during the system_prompt/2 and before_request/3 callbacks.

Quick Start

{:ok, state} = Nous.Decisions.Store.ETS.init([])
# ... add nodes and edges ...
text = Nous.Decisions.ContextBuilder.build(Nous.Decisions.Store.ETS, state)

Summary

Functions

Build a context string from active goals and recent decisions.

Functions

build(store_mod, state, opts \\ [])

@spec build(module(), term(), keyword()) :: String.t() | nil

Build a context string from active goals and recent decisions.

Options

  • :decision_limit - max recent decisions to include (default: 5)

Examples

text = ContextBuilder.build(Store.ETS, state)
# "## Active Goals\n- [abc123] Implement auth (confidence: 0.8, status: active)\n..."

Returns nil if there are no goals or decisions to display.