Skip to content

Commit d58e284

Browse files
authored
Merge pull request #317 from justrach/fix/278-bundle-activity-refresh
mcp: refresh last_activity during long bundle processing (#278)
2 parents a514ea8 + 3988c1f commit d58e284

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/mcp.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,12 @@ fn handleBundle(
12701270
}
12711271

12721272
const w = cio.listWriter(out, alloc);
1273+
// Refresh the idle clock as we start the bundle — long bundles (slow
1274+
// sub-ops, many ops, remote fetches) would otherwise leave
1275+
// `last_activity` frozen at message-arrival time, and the watchdog
1276+
// would close stdin mid-processing. Repeated inside the loop so each
1277+
// completed sub-op keeps us marked active. See #278.
1278+
last_activity.store(cio.milliTimestamp(), .release);
12731279
for (ops, 0..) |op, i| {
12741280
if (op != .object) {
12751281
w.print("--- [{d}] error ---\nop must be an object\n", .{i}) catch {};
@@ -1319,6 +1325,9 @@ fn handleBundle(
13191325
w.print("--- [{d}] {s} ---\n", .{ i, tool_name }) catch {};
13201326
out.appendSlice(alloc, sub_out.items) catch {};
13211327
w.writeAll("\n") catch {};
1328+
1329+
// Per-op activity refresh — see top of this fn.
1330+
last_activity.store(cio.milliTimestamp(), .release);
13221331
}
13231332
}
13241333

0 commit comments

Comments
 (0)