Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/rlm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ export async function press(query: string, context: Record<string, unknown> | un
})();

pendingRlmCalls.add(promise);
promise.finally(() => pendingRlmCalls.delete(promise));
const removeFromPending = () => pendingRlmCalls.delete(promise);
promise.then(removeFromPending, removeFromPending);

return promise;
};
Expand Down
27 changes: 27 additions & 0 deletions test/rlm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,33 @@ describe("press", () => {
expect(toolResult!.content).toContain("other-component");
});

it("caught delegation failure does not surface as a phantom error", async () => {
const events: Array<{ type: string; invocationId?: string; error?: string | null }> = [];
const callLLM = mockToolCallLLM([
tc(`try { await press("child task", undefined, { model: "failer" }) } catch (e) { console.log("caught:", e.message) }`, "t1"),
tc('return "ok"', "t2"),
]);

const result = await press("parent task", undefined, {
callLLM,
maxDepth: 3,
models: {
failer: {
callLLM: async () => {
throw new Error("child boom");
},
},
},
observer: { emit: (event) => events.push(event as { type: string; invocationId?: string; error?: string | null }) },
});

expect(result.answer).toBe("ok");
const rootIterationEnds = events.filter((e) => e.type === "iteration:end" && e.invocationId === "root");
for (const event of rootIterationEnds) {
expect(event.error).toBeNull();
}
});

it("use + systemPrompt concatenated", async () => {
const systemPrompts: string[] = [];
const callLLM: CallLLM = async (messages, systemPrompt) => {
Expand Down