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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.
`COMPUTER_MEMORY_HIGH_PERCENT=0` and `COMPUTER_TAB_IDLE_MS=0` (Helm: `computers.memoryHighPercent`
and `computers.tabIdleMs`) keep the old behaviour.

### A tool's link and a vendor's refusal are cut between characters

When a tool answers with a link, its title, name and description are each cut to 400 characters
before the Bot reads them, and the reason a vendor gives for refusing a request is cut to 400 too.
When the cut landed inside an emoji, the Bot was handed a broken character before the "…". The cut
now drops the half character instead.

### A computer closes browsers nobody is using when its memory runs high

A computer runs one browser for each Bot that is browsing, and the only limits were a count and half
Expand Down
4 changes: 2 additions & 2 deletions server/src/plugins/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function resourceLinkText(item: {
typeof value === "string" && value.trim() !== "" ? value : null;
const bounded = (value: string) =>
value.length > LINK_FIELD_CHARS
? `${value.slice(0, LINK_FIELD_CHARS)}…`
? `${cutAtCodeUnits(value, LINK_FIELD_CHARS)}…`
: value;
const lines: string[] = [];
const uri = field(item.uri);
Expand Down Expand Up @@ -274,7 +274,7 @@ function reasonFrom(error: unknown): string | null {

/** Long enough for a sentence and a URL, short enough not to be the wall of JSON this replaced. */
const trimmed = (value: string) =>
value.length > 400 ? `${value.slice(0, 400)}…` : value;
value.length > 400 ? `${cutAtCodeUnits(value, 400)}…` : value;

/**
* A vendor's failure, as one sentence an operator can act on.
Expand Down
10 changes: 10 additions & 0 deletions server/tests/mcp-result.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ describe("a result with something in it", () => {
expect(text).toBe(`uri: file:///a.md\ndescription: ${"d".repeat(400)}…`);
});

test("cuts a resource_link's long field between characters, not inside an emoji", () => {
// 399 units of text and then an emoji: the 400-unit cut lands between its two halves.
const description = `${"d".repeat(399)}${"🙂".repeat(10)}`;
const { text } = resultText([
{ type: "resource_link", uri: "file:///a.md", description },
]);
expect(text).toBe(`uri: file:///a.md\ndescription: ${"d".repeat(399)}…`);
expect(text.isWellFormed()).toBe(true);
});

test("a resource_link that names nothing is still named, rather than dropped", () => {
expect(resultText([{ type: "resource_link" }]).text).toBe(
"[resource_link]",
Expand Down