mirror of
https://github.com/vercel-labs/fx.git
synced 2026-10-28 10:15:17 +08:00
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:
1 file changed
+3
-2
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user