diff options
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main.zig b/src/main.zig index 995735f..61a88bd 100644 --- a/src/main.zig +++ b/src/main.zig @@ -144,7 +144,7 @@ const CLIRenderer = struct { /// it terminates (`turn_complete` → `next()` returns null). A failure /// surfaces as the error from `next()`; the caller renders it. The stream is /// always `deinit`ed (persisting the turn tail) on every exit path. -fn driveTurn(agent: *panto.agent.Agent, message: panto.agent.Agent.UserMessage, renderer: *CLIRenderer) !void { +fn driveTurn(agent: panto.Agent, message: panto.UserMessage, renderer: *CLIRenderer) !void { var stream = try agent.run(message); defer stream.deinit(); while (try stream.next()) |ev| try renderer.render(ev); @@ -358,7 +358,7 @@ pub fn main(init: std.process.Init) !void { // On resume, reconstruct the conversation from the store. (The // dangling-prompt recovery feature was dropped in R2.) On a fresh // session, the agent starts with an empty conversation. - var adopted_conversation: ?panto.conversation.Conversation = null; + var adopted_conversation: ?panto.ConversationData = null; if (is_resume) { adopted_conversation = try session.load(); const sid = session.info.id; @@ -376,11 +376,11 @@ pub fn main(init: std.process.Init) !void { // 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 = .{ + var active_config: panto.Config = .{ .provider = provider_config, .compaction = compaction_cfg, }; - var agent = panto.agent.Agent.init( + const agent = try panto.Agent.init( alloc, io, &active_config, @@ -424,7 +424,7 @@ pub fn main(init: std.process.Init) !void { io, init.environ_map, luarocks_rt.layout.agent_dir, - &agent, + agent, ); } else { // Fresh session — source and install the system prompt. @@ -433,7 +433,7 @@ pub fn main(init: std.process.Init) !void { io, init.environ_map, luarocks_rt.layout.agent_dir, - &agent, + agent, ); } @@ -476,7 +476,9 @@ pub fn main(init: std.process.Init) !void { init.environ_map, luarocks_rt.layout.agent_dir, ); - agent.compaction_system_prompt = compaction_prompt; + // The compaction prompt is resolved after extension load; set it on the + // config the agent re-reads each turn (visible before the first turn). + active_config.compaction.compaction_prompt = compaction_prompt; const banner_base: []const u8 = switch (provider_config) { inline else => |c| c.base_url, @@ -521,7 +523,7 @@ pub fn main(init: std.process.Init) !void { var cmd_ctx: command.Context = .{ .allocator = alloc, - .agent = &agent, + .agent = agent, .stdout = stdout, .stdout_file = &stdout_file, .compaction_prompt = compaction_prompt, @@ -570,7 +572,7 @@ pub fn main(init: std.process.Init) !void { // auto-compaction) through its session store — the CLI no longer // touches persistence. cli_renderer.beginTurn(); - driveTurn(&agent, .{ .text = line }, &cli_renderer) catch |err| { + driveTurn(agent, .{ .text = line }, &cli_renderer) catch |err| { cli_renderer.renderError(err); try stdout.print("\n[error: {s}]\n", .{@errorName(err)}); }; |
