Pass the agent to the compaction bridge on cooperative hosts

The WASM terminal publishes a context compaction from the main loop. It
handed the app to a worker bridge callback that reads its context as
the agent, so the compacted history was built with a garbage allocator
and the module trapped.
This commit is contained in:
Pranit committed 2026-10-27 19:09:30 -04:00
1 parent 9044f9f647
commit d4c26f604b
1 file changed
+3 -2
+3 -2
View File
@@ -1234,14 +1234,15 @@ pub fn Bindings(comptime App: type) type {
retained_from: ?types.ContextHistoryCut,
) !void {
const agent: *AppAgent = @ptrCast(@alignCast(ctx));
const app = appOf(agent);
if (comptime runtime_profile.allows(App, .cooperative_agent)) {
// The bridge's context is the agent, as for every other
// worker bridge callback.
try agent.worker.publishContextCompaction(std.heap.c_allocator, .{
.summary = summary,
.active_prefix = active_prefix,
.retained_from = retained_from,
.max_history_turns = agent.session.max_history_turns,
}, app, workerBridgeContextCompaction);
}, @ptrCast(agent), workerBridgeContextCompaction);
return;
}
try app_worker_runtime.Runtime(App).commitContextCompaction(