mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 09:23:58 +00:00
* fix(tui): show last tool-error summary on aborted runs When a run ends while looping on tool-call validation errors the TUI showed only "run aborted". Carry the last tool failure on the terminal lifecycle metadata and render a sanitized one-line summary on the abort line, e.g. "run aborted: edit tool validation failed: edits: must have required properties edits". Argument dumps are stripped; with no summary it stays "run aborted". Refs #90982 * fix(tui): secure abort validation diagnostics * docs(changelog): move TUI fix to unreleased * docs(changelog): aggregate TUI fixes * fix(tui): scope abort validation diagnostics * docs(changelog): restore unreleased spacing * fix(tui): scope abort validation diagnostics * fix(tui): scope abort validation diagnostics --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
createToolValidationErrorSummary,
|
|
readToolValidationErrorSummary,
|
|
summarizeToolValidationError,
|
|
} from "./tool-error-summary.js";
|
|
|
|
describe("createToolValidationErrorSummary", () => {
|
|
it("builds a static summary without validator details", () => {
|
|
expect(createToolValidationErrorSummary("edit")).toBe(
|
|
"edit tool validation failed: invalid arguments",
|
|
);
|
|
expect(createToolValidationErrorSummary(" custom tool ")).toBe(
|
|
"custom tool tool validation failed: invalid arguments",
|
|
);
|
|
});
|
|
|
|
it("rejects unsafe or oversized tool names", () => {
|
|
expect(createToolValidationErrorSummary("edit\nsecret")).toBeUndefined();
|
|
expect(createToolValidationErrorSummary("x".repeat(200))).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe("summarizeToolValidationError", () => {
|
|
it("accepts only a boundary-prepared summary", () => {
|
|
expect(
|
|
summarizeToolValidationError({
|
|
toolName: "edit",
|
|
validationErrorSummary: "edit tool validation failed: invalid arguments",
|
|
error:
|
|
'Validation failed for tool "edit":\n - secret-field: rejected-secret\n\nReceived arguments:\n{}',
|
|
}),
|
|
).toBe("edit tool validation failed: invalid arguments");
|
|
expect(
|
|
summarizeToolValidationError({
|
|
toolName: "edit",
|
|
error:
|
|
'Validation failed for tool "edit":\n - secret-field: rejected-secret\n\nReceived arguments:\n{}',
|
|
}),
|
|
).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe("readToolValidationErrorSummary", () => {
|
|
it("accepts generated summaries and rejects unsafe boundary values", () => {
|
|
expect(readToolValidationErrorSummary("edit tool validation failed: path: invalid")).toBe(
|
|
"edit tool validation failed: path: invalid",
|
|
);
|
|
expect(readToolValidationErrorSummary("edit failed\nsecret")).toBeUndefined();
|
|
expect(readToolValidationErrorSummary(`edit failed: ${"x".repeat(200)}`)).toBeUndefined();
|
|
});
|
|
});
|