summaryrefslogtreecommitdiff
path: root/libpanto/src/provider.zig
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-06-07 10:57:49 -0600
committert <t@tjp.lol>2026-06-07 10:57:49 -0600
commitd36a51358efbc48de3d5b732727455efc60acae1 (patch)
tree21d6218c1c8d4b7aad706d70f65449019edc6b87 /libpanto/src/provider.zig
parent032d27b18597ee3f10222963b53625208c84f571 (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 'libpanto/src/provider.zig')
-rw-r--r--libpanto/src/provider.zig12
1 files changed, 7 insertions, 5 deletions
diff --git a/libpanto/src/provider.zig b/libpanto/src/provider.zig
index 0fe0ed4..8ea74f3 100644
--- a/libpanto/src/provider.zig
+++ b/libpanto/src/provider.zig
@@ -243,13 +243,14 @@ pub const ProviderStream = struct {
/// `*const Config` between turns changes provider, model, base_url, and the
/// visible tool set with no transport teardown.
///
-/// The tool registry is taken from `cfg.registry`; the serializers receive
-/// it directly. On success the caller owns the returned `ProviderStream` and
-/// must `deinit` it.
+/// The tool registry is supplied by the caller (the `Agent` owns it now,
+/// not `cfg`); the serializers receive it directly. On success the caller
+/// owns the returned `ProviderStream` and must `deinit` it.
pub fn openStream(
allocator: std.mem.Allocator,
io: std.Io,
cfg: *const config_mod.Config,
+ registry: *const ToolRegistry,
conv: *conversation.Conversation,
diag: ?*ProviderDiagnostic,
) anyerror!ProviderStream {
@@ -267,7 +268,7 @@ pub fn openStream(
.http_client = client,
.diag = diag,
};
- const rr = try req.open(conv, cfg.registry);
+ const rr = try req.open(conv, registry);
return rr.providerStream();
},
.anthropic_messages => |*c| {
@@ -278,7 +279,7 @@ pub fn openStream(
.http_client = client,
.diag = diag,
};
- const rr = try req.open(conv, cfg.registry);
+ const rr = try req.open(conv, registry);
return rr.providerStream();
},
}
@@ -291,6 +292,7 @@ pub const OpenStreamFn = *const fn (
allocator: std.mem.Allocator,
io: std.Io,
cfg: *const config_mod.Config,
+ registry: *const ToolRegistry,
conv: *conversation.Conversation,
diag: ?*ProviderDiagnostic,
) anyerror!ProviderStream;