Files
paseo/packages/protocol/src/agent-labels.test.ts
Mohamed Boudra 14af053c66 Keep delegated agents out of workspace alerts (#1293)
* Keep delegated agents out of workspace alerts

* Share delegated agent label parsing
2026-06-02 20:55:19 +08:00

22 lines
791 B
TypeScript

import { describe, expect, test } from "vitest";
import {
getParentAgentIdFromLabels,
isDelegatedAgent,
PARENT_AGENT_ID_LABEL,
} from "./agent-labels.js";
describe("agent label policy", () => {
test("treats a non-empty parent agent label as delegation", () => {
const labels = { [PARENT_AGENT_ID_LABEL]: " parent-agent \n" };
expect(getParentAgentIdFromLabels(labels)).toBe("parent-agent");
expect(isDelegatedAgent({ labels })).toBe(true);
});
test("ignores missing, empty, and non-string parent agent labels", () => {
expect(isDelegatedAgent({ labels: {} })).toBe(false);
expect(isDelegatedAgent({ labels: { [PARENT_AGENT_ID_LABEL]: " " } })).toBe(false);
expect(isDelegatedAgent({ labels: { [PARENT_AGENT_ID_LABEL]: 42 } })).toBe(false);
});
});