Skip to content

Commit ec194bf

Browse files
committed
fix(site/src/pages/AgentsPage): ignore inherited keys when labeling manage_automations calls
The tool label looked up the model-supplied action on a plain object, so an action such as "constructor" or "__proto__" returned an inherited value and destructuring it threw "labels is not iterable", crashing the row. The lookup now accepts only own keys, so these actions fall back to the generic "Manage automations" label like any other unknown action. A Tool test renders prototype-named actions and fails without the fix. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
1 parent 9b6fa67 commit ec194bf

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

‎site/src/pages/AgentsPage/components/ChatElements/tools/Tool.test.tsx‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import * as apiModule from "#/api/api";
66
import { API } from "#/api/api";
77
import { workspaceByIdKey } from "#/api/queries/workspaces";
88
import { MockWorkspace, MockWorkspaceAgent } from "#/testHelpers/entities";
9-
import { createTestQueryClient } from "#/testHelpers/renderHelpers";
9+
import {
10+
createTestQueryClient,
11+
renderComponent,
12+
} from "#/testHelpers/renderHelpers";
1013
import { createMockWebSocket } from "#/testHelpers/websockets";
1114
import { OneWayWebSocket } from "#/utils/OneWayWebSocket";
1215
import { ChatWorkspaceContext } from "../../../context/ChatWorkspaceContext";
@@ -94,3 +97,25 @@ describe("Tool workspace lifecycle rows", () => {
9497
},
9598
);
9699
});
100+
101+
describe("Tool manage_automations label", () => {
102+
it.each([
103+
"constructor",
104+
"toString",
105+
"__proto__",
106+
"hasOwnProperty",
107+
"unknown_action",
108+
])("falls back to the generic label for action %s", (action) => {
109+
renderComponent(
110+
<Tool
111+
name="manage_automations"
112+
status="error"
113+
isError
114+
args={{ action }}
115+
result={{ error: "unknown action" }}
116+
/>,
117+
);
118+
119+
screen.getByText("Manage automations");
120+
});
121+
});

‎site/src/pages/AgentsPage/components/ChatElements/tools/ToolLabel.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ const ManageAutomationsLabel: React.FC<ToolLabelProps> = ({
8484
isError,
8585
}) => {
8686
const parsed = parseArgs(args);
87-
const labels = manageAutomationsLabels[asString(parsed?.action).trim()];
87+
const action = asString(parsed?.action).trim();
88+
// The action comes from model output, so ignore inherited keys such as
89+
// "constructor" instead of reading them as label tuples.
90+
const labels = Object.hasOwn(manageAutomationsLabels, action)
91+
? manageAutomationsLabels[action]
92+
: undefined;
8893
const parsedResult = asRecord(result);
8994
const automationName =
9095
asString(asRecord(parsedResult?.automation)?.name) ||

0 commit comments

Comments
 (0)