feat: auto-delete old conversations, and stop a tool call that repeats (#15)
This commit was merged in pull request #15.
This commit is contained in:
@@ -231,6 +231,79 @@ describe("buildThreadMarkdown", () => {
|
||||
expect(reasoningOnly).toContain("Reasoning");
|
||||
});
|
||||
|
||||
it("names a refused repeat, and does not call it a failure", () => {
|
||||
const markdown = buildThreadMarkdown([
|
||||
message({
|
||||
role: "assistant",
|
||||
text: "a",
|
||||
toolCalls: [
|
||||
{ name: "web_search", arguments: {}, result: "ok", isError: false },
|
||||
{
|
||||
name: "web_search",
|
||||
arguments: {},
|
||||
result: "Refused",
|
||||
isError: true,
|
||||
repeated: true,
|
||||
},
|
||||
],
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(markdown).toContain("`web_search` (repeated, stopped)");
|
||||
expect(markdown).not.toContain("(failed)");
|
||||
});
|
||||
|
||||
it("shows a failed call even when tool calls are hidden", () => {
|
||||
// Hiding the line would leave the user with an answer they cannot account
|
||||
// for, which is worse than a quiet italic line they did not ask for.
|
||||
const markdown = buildThreadMarkdown(
|
||||
[
|
||||
message({
|
||||
role: "assistant",
|
||||
text: "a",
|
||||
toolCalls: [{ name: "web_fetch", arguments: {}, result: "boom", isError: true }],
|
||||
}),
|
||||
],
|
||||
{ showToolCalls: false, showReasoning: false },
|
||||
);
|
||||
|
||||
expect(markdown).toContain("`web_fetch` (failed)");
|
||||
});
|
||||
|
||||
it("shows a refused repeat even when tool calls are hidden", () => {
|
||||
// This is the one the user most needs to see: a model going in circles is
|
||||
// exactly the thing a hidden tool list would conceal.
|
||||
const markdown = buildThreadMarkdown(
|
||||
[
|
||||
message({
|
||||
role: "assistant",
|
||||
text: "a",
|
||||
toolCalls: [
|
||||
{ name: "web_search", arguments: {}, result: "Refused", isError: true, repeated: true },
|
||||
],
|
||||
}),
|
||||
],
|
||||
{ showToolCalls: false, showReasoning: false },
|
||||
);
|
||||
|
||||
expect(markdown).toContain("`web_search` (repeated, stopped)");
|
||||
});
|
||||
|
||||
it("still hides the ordinary calls when tool calls are off", () => {
|
||||
const markdown = buildThreadMarkdown(
|
||||
[
|
||||
message({
|
||||
role: "assistant",
|
||||
text: "a",
|
||||
toolCalls: [{ name: "get_datetime", arguments: {}, result: "ok", isError: false }],
|
||||
}),
|
||||
],
|
||||
{ showToolCalls: false, showReasoning: false },
|
||||
);
|
||||
|
||||
expect(markdown).not.toContain("_Tools:");
|
||||
});
|
||||
|
||||
it("only shows a reasoning section when there is reasoning", () => {
|
||||
expect(buildThreadMarkdown([message({ role: "assistant", text: "a" })])).not.toContain("Reasoning");
|
||||
expect(buildThreadMarkdown([message({ role: "assistant", text: "a", thinking: "hmm" })])).toContain(
|
||||
|
||||
Reference in New Issue
Block a user