The script builds a hierarchical agency like examples/emergent-hierarchical-spawning.mjs, with one specialist allowed, and gives it the sandbox-security brief from examples/single-agent-briefing.mjs. The output is from one run against the OpenAI API. Both examples are in framerslab/agentos/examples.
import { agency } from '@framers/agentos'; const team = agency({ provider: 'openai', model: 'gpt-4o', strategy: 'hierarchical', instructions: 'Coordinate a research team. If the task needs a ' + 'capability your roster does not cover, call ' + 'spawn_specialist to mint one.', agents: { researcher: { instructions: 'Find authoritative sources.' }, writer: { instructions: 'Produce concise prose.' }, }, emergent: { enabled: true, judge: true, planner: { maxSpecialists: 1, requireJustification: true, maxJudgeCalls: 3 }, }, on: { emergentForge: (e) => console.log( `[FORGE] spawned "${e.agentName}" approved=${e.approved}` ), }, }); const result = await team.generate( 'Write a 2-paragraph briefing on agentic-AI ' + 'sandbox security risks. Include a security-' + 'audit perspective on node:vm vs container ' + 'isolation. The team has no security auditor; ' + 'spawn one if needed.', ); console.log(result.text);
The team starts with researcher + writer. The prompt asks for a security audit, which neither covers. The manager calls spawn_specialist, EmergentAgentJudge approves the spec, and security_auditor joins the roster, which gives the manager a delegate_to_security_auditor tool. The agent-call list shows that in this run the manager delegated to researcher and writer only. The final answer above is what GPT-4o returned in that run. Its first paragraph misdescribes node:vm, which runs code in a V8 context inside the Node.js process; Node's documentation says it is not a security mechanism.