Make the hire_agent department contract explicit

The CEO's first run hired five reports into departments "general" and
"engineering"; the hiring-policy lookup was exact-match against the
seeded names (Executive, Engineering, ...), so every hire failed and
the kickoff produced nothing. The tool schema now enumerates the
canonical departments, the policy lookup matches case-insensitively
and stores the canonical name on the agent, and an unknown department
error lists the valid choices so the model can self-correct.
This commit is contained in:
ZacharyZhang-NY committed 2026-06-09 21:21:01 -04:00
1 parent 2dd4f3976a
commit d6d6656428
4 files changed
+63 -12

No files matched your search

@@ -707,4 +707,46 @@ describe("domain services", () => {
expect(ownedKickoff.assignee_agent_id).toBe(ownerId);
connection.close();
});
test("hiring normalizes department case and rejects unknown departments with guidance", () => {
const connection = createConnection();
const organization = new OrganizationService(connection.db);
let orgId = "";
connection.transaction(() => {
orgId = organization.createOrganization({
organizationName: "Acme Operations",
employeeName: "Dana Lee",
mission: "Coordinate agents with auditable approvals.",
goal: "Ship a verified control plane.",
});
});
let agentId = "";
connection.transaction(() => {
agentId = organization.createAgent({
orgId,
name: "Zhang Hao",
role: "Algorithm Lead",
department: "engineering",
modelProviderId: null,
modelId: null,
budgetCents: 25000,
managerAgentId: null,
});
});
const hired = connection.db.prepare("select department from agents where id = ?").get(agentId) as { department: string };
expect(hired.department).toBe("Engineering");
expect(() => connection.transaction(() => organization.createAgent({
orgId,
name: "Chen Wei",
role: "Research Lead",
department: "general",
modelProviderId: null,
modelId: null,
budgetCents: 25000,
managerAgentId: null,
}))).toThrow(/Unknown department "general"\. Departments: .*Engineering.*Executive/);
connection.close();
});
});