Skip to content

Commit 3e43573

Browse files
committed
Keep stop_reason on collected wait_agents projections
The occupancy collector is the wait_agents JSON shape. Dropping stopReason there made interrupt and incomplete-report waits look clean after collection.
1 parent 21f982e commit 3e43573

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/subagent/fleet-dry-drive.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,25 @@ describe("collectUncollectedTerminals", () => {
217217
expect(records.get("ghost")?.collected).toBe(true);
218218
});
219219

220+
test("projects mailbox stopReason as stop_reason", () => {
221+
const records = new Map<string, FleetDryMailboxRecord>([
222+
["w1", { status: "interrupted", report: "salvage", stopReason: "interrupted" }],
223+
]);
224+
const mailbox: FleetDryMailbox = {
225+
ids: () => [...records.keys()],
226+
peek: (id) => records.get(id),
227+
take: (id) => records.get(id),
228+
};
229+
expect(collectUncollectedTerminals(mailbox, [], true)).toEqual([
230+
{
231+
agent_id: "w1",
232+
status: "interrupted",
233+
report: "salvage",
234+
stop_reason: "interrupted",
235+
},
236+
]);
237+
});
238+
220239
test("clips oversized reports", () => {
221240
const records = new Map<string, FleetDryMailboxRecord>([
222241
["big", { status: "done", report: "x".repeat(FLEET_DRY_REPORT_CHARS + 40) }],

src/subagent/fleet-dry-drive.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface FleetDryMailboxRecord {
2020
readonly description?: string;
2121
readonly hint?: string;
2222
readonly providerFailure?: true;
23+
readonly stopReason?: string;
2324
}
2425

2526
export interface FleetDryMailbox {
@@ -43,6 +44,7 @@ export interface CollectedWorkerReport {
4344
error?: string;
4445
hint?: string;
4546
provider_failure?: true;
47+
stop_reason?: string;
4648
}
4749

4850
export function shouldDriveOpenTasks(input: {
@@ -85,6 +87,7 @@ export function projectMailboxRecord(
8587
...(error !== undefined ? { error } : {}),
8688
...(taken.hint !== undefined ? { hint: taken.hint } : {}),
8789
...(taken.providerFailure === true ? { provider_failure: true } : {}),
90+
...(taken.stopReason !== undefined ? { stop_reason: taken.stopReason } : {}),
8891
};
8992
}
9093

0 commit comments

Comments
 (0)