diff options
| author | t <t@tjp.lol> | 2026-06-07 10:57:49 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-07 10:57:49 -0600 |
| commit | d36a51358efbc48de3d5b732727455efc60acae1 (patch) | |
| tree | 21d6218c1c8d4b7aad706d70f65449019edc6b87 /src | |
| parent | 032d27b18597ee3f10222963b53625208c84f571 (diff) | |
R1: move tool registry off Config onto Agent
The tool set is no longer part of the per-turn Config snapshot. Agent now
owns a ToolRegistry (created empty at init), populated via the new
Agent.registerTool / registerToolSource methods. openStream and
OpenStreamFn take the registry as an explicit parameter rather than reading
it from cfg.registry, so swapping provider/model between turns (setConfig)
no longer disturbs the tool set.
CLI migrated to register the Lua tool source onto the agent instead of a
locally-owned registry. Test harnesses updated to stage tools on the agent.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.zig | 17 | ||||
| -rw-r--r-- | src/system_prompt.zig | 13 |
2 files changed, 11 insertions, 19 deletions
diff --git a/src/main.zig b/src/main.zig index ff00689..46b6320 100644 --- a/src/main.zig +++ b/src/main.zig @@ -365,21 +365,16 @@ pub fn main(init: std.process.Init) !void { ); } - // The tool registry is owned here and referenced by the active config - // snapshot. Extensions register their tool source into it *after* the - // agent is built; the agent holds a `*const Config` pointing at this - // registry, so in-place registration before the first turn is visible. - var registry = panto.ToolRegistry.init(alloc); - defer registry.deinit(); - // Assemble the active configuration snapshot and build the agent now, // before luarocks bootstrap and extension loading. The agent adopts the // store (for free persistence) and the resumed conversation (or starts - // fresh). System-prompt seeding/reconciliation below runs *through* the - // agent so those entries persist. + // fresh). The agent owns its own tool registry (post-R1); extensions + // register their tool source onto it *after* the agent is built but + // before the first turn, so in-place registration is visible. + // System-prompt seeding/reconciliation below runs *through* the agent + // so those entries persist. const active_config: panto.config.Config = .{ .provider = provider_config, - .registry = ®istry, .compaction = compaction_cfg, }; var agent = panto.agent.Agent.init( @@ -468,7 +463,7 @@ pub fn main(init: std.process.Init) !void { std.log.debug("extensions: {d} tool(s) registered", .{n_ext_tools}); if (n_ext_tools > 0) { - try registry.registerSource(rt.toolSource()); + try agent.registerToolSource(rt.toolSource()); } // Resolve the compaction system prompt (COMPACTION.md across layers, diff --git a/src/system_prompt.zig b/src/system_prompt.zig index b5423f8..6104034 100644 --- a/src/system_prompt.zig +++ b/src/system_prompt.zig @@ -467,12 +467,12 @@ fn openTmpSession(arena: Allocator, root: []const u8) !panto.session_manager.Ses return panto.session_manager.SessionManager.init(testing.allocator, testing.io, sessions, "/cwd"); } -/// Minimal agent harness for system-prompt tests: an empty registry and a -/// throwaway provider config, wrapping a session store and (optionally) an -/// adopted conversation. Holds the registry/config so the agent's borrowed -/// pointers stay valid for the agent's lifetime. +/// Minimal agent harness for system-prompt tests: a throwaway provider +/// config wrapping a session store and (optionally) an adopted +/// conversation. Post-R1 the agent owns its own (empty) tool registry, so +/// the harness only holds the config to keep the agent's borrowed pointer +/// valid for its lifetime. const SPAgentHarness = struct { - registry: panto.ToolRegistry, config: panto.config.Config, agent: panto.agent.Agent, @@ -481,17 +481,14 @@ const SPAgentHarness = struct { store: panto.session_store.SessionStore, adopted: ?panto.conversation.Conversation, ) void { - self.registry = panto.ToolRegistry.init(testing.allocator); self.config = .{ .provider = .{ .openai_chat = .{ .api_key = "k", .base_url = "u", .model = "m" } }, - .registry = &self.registry, }; self.agent = panto.agent.Agent.init(testing.allocator, testing.io, &self.config, store, adopted); } fn deinit(self: *SPAgentHarness) void { self.agent.deinit(); - self.registry.deinit(); } }; |
