Structure
Nodes
Each node represents a discrete action:Edges
Edges connect nodes with typed dependencies:| Edge kind | Meaning |
|---|---|
data | Output of the source node feeds into the target node |
control | Target node may only execute after the source node completes |
Metrics
Plan extraction during consolidation
Plan graphs are extracted automatically byPlanGraphConsolidator during each consolidation run:
Select eligible episodes
Only episodic records with a
tool_graph containing 3 or more nodes are considered (minToolGraphNodes = 3). Trivial single-tool invocations are excluded.Avoid duplicates
The consolidator checks existing plan graph records for
derived_from relations. If a plan graph already exists for a given episodic source, that episode is skipped.Convert tool graph to plan graph
Each
ToolNode becomes a PlanNode (ID → ID, Tool → Op, Args → Params). Each DependsOn relationship in the tool graph becomes a control edge.Infer intent
The intent label is derived from the first timeline event kind in the source episode. If no timeline events exist, it defaults to
"unknown".Plan reuse and execution tracking
Plan graphs accumulate execution statistics across uses viaPlanMetrics:
ExecutionCountincrements each time the plan is applied.FailureRatetracks the proportion of failed executions.AvgLatencyMstracks average wall-clock time.
plan_reuse_frequency observability metric reports the average execution_count across all plan graph records:
Selector applicability scoring
At retrieval time, plan graphs are scored by theSelector using three equally weighted signals:
- Applicability —
record.Confidencefield, or vector cosine similarity against the query embedding when pgvector is enabled. - Success rate — derived from
1.0 − PlanMetrics.FailureRate:
- Recency — exponential decay on time since
last_reinforced_at(30-day half-life).
SelectionConfidenceThreshold (default 0.7), SelectionResult.NeedsMore is set to true.
Example: multi-step workflow
Plan graph lifecycle
Auto-extracted
Created by the consolidation pipeline from episodic tool graphs with 3+ nodes. No manual authoring required.
Execution-tracked
Tracks
execution_count, failure_rate, and avg_latency_ms across uses.Revisable
Can be superseded, forked, contested, retracted, or merged like any non-episodic record.
Vector-scored
On Postgres + pgvector, applicability is scored via embedding similarity against the task descriptor.
Relation to competence records
Plan graphs and competence records are complementary:| Aspect | Competence | Plan Graph |
|---|---|---|
| Represents | A procedure with triggers and recipe steps | A directed graph of actions with dependencies |
| Extraction trigger | 2+ successful episodes with the same tool signature | 1+ episode with a tool graph containing 3+ nodes |
| Success tracking | PerformanceStats (success_count / failure_count) | PlanMetrics (failure_rate, execution_count) |
| Applicability matching | Trigger signals and conditions | Intent label and constraint matching |
| Graph structure | Ordered list of steps | Directed acyclic graph with typed edges |