The agent toolkit (core/agent) lets an AI agent use the data fabric as a
brain: it retrieves the relevant slice of a large corpus on demand, forms
new memory under policy, and stays current as the world changes. It operates
only on the existing query.Fabric facade — no new
storage, no engine coupling — so everything an agent can recall or write rides
the same tenancy, eventing, and projection invariants as the rest of fabriq.
An agent's context window holds ~1 MB of text; a corpus is gigabytes (~1000×). The toolkit never loads the corpus — it returns the ranked, budget-fitted slice the model needs for the turn. Embeddings, graph edges, and projections are the compression that lets a small window reach into a large base.
The shape01
Two front doors over one core:
Import
<code>
core/agent
</code><code>
Toolkit
</code>The
<code>
forgeext/agentmcp
</code><em>
same
</em><code>
tools/list
</code><code>
tools/call
</code>import "github.com/xraph/fabriq/core/agent"
tk, err := agent.NewToolkit(f, f.Registry(), embedder, agent.Config{
Write: agent.WritePolicy{Allow: map[string][]command.Op{
"note": {command.OpCreate, command.OpUpdate},
}},
})
// Recall: the auto-context front door.
pack, err := tk.Recall(ctx, agent.RecallRequest{
Query: "overheating pumps at the north site",
Budget: 8000, // token budget for the returned context pack
Entities: []string{"asset", "note"},
})
// Remember: guarded memory formation through the command plane.
res, err := tk.Remember(ctx, agent.RememberRequest{
Entity: "note", Op: "create", Payload: []byte(`{"title":"…","body":"…"}`),
})
// Watch: react to live deltas.
deltas, err := tk.Watch(ctx, query.SubscribeScope{Entity: "asset", Scope: "tenant"})What it does02
One
<code>
recall(query, budget)
</code>Guarded writes through the command plane (deny-by-default
<code>
WritePolicy
</code>Subscribe to the conflated delta stream so the agent reacts to changes, not just polls — in-process as a Go channel, or over MCP as SSE.
The common interface:
<code>
tools/list
</code><code>
tools/call
</code>The Embedder seam03
Semantic recall and auto-indexing both need to turn text into vectors. Fabriq
stores vectors (the vector plane) but does not produce
them — the host supplies an Embedder, exactly the way it supplies auth:
// Embedder turns text into vectors. The host wires the model
// (Anthropic, OpenAI, a local model); fabriq stays model-agnostic.
type Embedder interface {
Embed(ctx context.Context, texts []string) ([][]float32, error)
Dims() int
}Dims() is validated against the vector port at NewToolkit. With no embedder
wired, recall still works — it degrades to the lexical and relational channels
and records a warning on the result, rather than failing.
The toolkit is transport-agnostic: core/agent imports no Forge, no HTTP,
and no MCP. Cognition (embedding orchestration, fusion, token-budgeting) lives
in the core; transport and auth live in the agentmcp Forge
shell — the same "primitives in core, policy in the seam" discipline as the
rest of fabriq.