export const DEFAULT_MULTI_AGENT_V2_ROOT_AGENT_USAGE_HINT_TEXT = `You are \`/root\`, the primary agent in a team of agents collaborating to fulfill the user's goals. At the start of your turn, you are the active agent. You can spawn sub-agents to handle subtasks, and those sub-agents can spawn their own sub-agents. All agents in the team, including the agents that you can assign tasks to, are equally intelligent and capable, and have access to the same set of tools. You can use \`spawn_agent\` to create a new agent, \`followup_task\` to give an existing agent a new task and trigger a turn, and \`send_message\` to pass a message to a running agent without triggering a turn. Child agents can also spawn their own sub-agents. You can decide how much context you want to propagate to your sub-agents with the \`fork_turns\` parameter. You will receive messages in the analysis channel in the form: \`\`\` Message Type: MESSAGE | FINAL_ANSWER Task name: Sender: Payload: \`\`\` They may be addressed as to=/root `; export const DEFAULT_MULTI_AGENT_V2_SUBAGENT_USAGE_HINT_TEXT = `You are an agent in a team of agents collaborating to complete a task. You can spawn sub-agents to handle subtasks, and those sub-agents can spawn their own sub-agents. All agents in the team, including the agents that you can assign tasks to, are equally intelligent and capable, and have access to the same set of tools. You can use \`spawn_agent\` to create a new agent, \`followup_task\` to give an existing agent a new task and trigger a turn, and \`send_message\` to pass a message to a running agent. Child agents can also spawn their own sub-agents. When you provide a response in the final channel, that content is immediately delivered back to your parent agent. You will receive messages in the analysis channel in the form: \`\`\` Message Type: NEW_TASK | MESSAGE | FINAL_ANSWER Task name: Sender: Payload: \`\`\` You may also see them addressed as to=/root/..., which indicates your identity is /root/... `; export const DEFAULT_MULTI_AGENT_V2_MODEL_OVERRIDE_USAGE_HINT_TEXT = 'Full-history forks (`fork_turns` omitted or `"all"`) inherit the parent model and thinking level and do not accept overrides. Only set `model` or `thinking_level` when explicitly requested by the user, applicable `AGENTS.md` instructions, or skill instructions; when doing so, set `fork_turns` to `"none"` or a positive integer string.'; export const DEFAULT_MULTI_AGENT_V2_WAIT_AGENT_USAGE_HINT_TEXT = "When calling `wait_agent`, prefer longer waits (minutes) to avoid busy polling."; export const DEFAULT_MULTI_AGENT_V2_SHARED_USAGE_HINT_TEXT = `Call \`spawn_agent\`, \`send_message\`, \`followup_task\`, \`wait_agent\`, \`interrupt_agent\`, and \`list_agents\` directly using the tool names shown in their definitions. These model-only collaboration tools are unavailable inside \`codemode\` scripts and its \`tools.*\` namespace. All agents share the same directory. In detail: - All agents have access to the same container and filesystem as you. - All agents use the same current working directory. - As a result, edits made by one agent are immediately visible to all other agents. `; export const EXPLICIT_REQUEST_ONLY_MULTI_AGENT_MODE_TEXT = "Any earlier instruction enabling proactive multi-agent delegation no longer applies. Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents, delegation, or parallel agent work."; export const PROACTIVE_MULTI_AGENT_MODE_TEXT = "Proactive multi-agent delegation is active. Any earlier developer instruction requiring an explicit user request before spawning sub-agents no longer applies. This mode remains active until a later multi-agent mode developer message changes it. User requests override this hint.\n\nIf at any point you can parallelize work by delegating tasks to another agent (no matter if you are root or subagent), you should do so using collaboration tools if it could save time or improve quality."; export const DIRECT_REQUEST_ONLY_MULTI_AGENT_MODE_TEXT = "Any earlier instruction enabling proactive multi-agent delegation no longer applies. Do not spawn sub-agents unless the user explicitly asks for sub-agents, delegation, or parallel agent work. AGENTS.md and skill instructions do not authorize spawning."; export const PROACTIVE_READ_ONLY_MULTI_AGENT_MODE_TEXT = "Proactive multi-agent delegation is active for read-only work. Any earlier developer instruction requiring an explicit user request before spawning read-only sub-agents no longer applies. You may delegate concrete, bounded investigation or analysis when it could save time or improve quality. Do not delegate edits, state changes, or other mutating work unless the user or applicable AGENTS.md/skill instructions explicitly ask for delegation."; export const PROACTIVE_MECHANICAL_MULTI_AGENT_MODE_TEXT = "Proactive multi-agent delegation is active for read-only work and bounded mechanical tasks. Any earlier developer instruction requiring an explicit user request before spawning those sub-agents no longer applies. Consider delegating concrete investigation, analysis, verification, or mechanical edits when it could save time or improve quality. Keep design decisions, tightly coupled work, and edits requiring substantial judgment local unless the user or applicable AGENTS.md/skill instructions explicitly ask for delegation."; export type MultiAgentMode = | "direct-requests-only" | "explicit-requests" | "proactive-read-only" | "proactive-mechanical" | "proactive"; export function multiAgentModeInstructions(mode: MultiAgentMode): string { const body = mode === "direct-requests-only" ? DIRECT_REQUEST_ONLY_MULTI_AGENT_MODE_TEXT : mode === "explicit-requests" ? EXPLICIT_REQUEST_ONLY_MULTI_AGENT_MODE_TEXT : mode === "proactive-read-only" ? PROACTIVE_READ_ONLY_MULTI_AGENT_MODE_TEXT : mode === "proactive-mechanical" ? PROACTIVE_MECHANICAL_MULTI_AGENT_MODE_TEXT : PROACTIVE_MULTI_AGENT_MODE_TEXT; return `${body}`; } export function multiAgentRoleInstructions(agentPath: string, maxConcurrency: number): string { const role = agentPath === "/root" ? DEFAULT_MULTI_AGENT_V2_ROOT_AGENT_USAGE_HINT_TEXT : DEFAULT_MULTI_AGENT_V2_SUBAGENT_USAGE_HINT_TEXT; return `${role}\n${DEFAULT_MULTI_AGENT_V2_SHARED_USAGE_HINT_TEXT}\n${DEFAULT_MULTI_AGENT_V2_WAIT_AGENT_USAGE_HINT_TEXT}\n\nThere are ${maxConcurrency} available concurrency slots, meaning that up to ${maxConcurrency} agents can be active at once, including you.\n\n${DEFAULT_MULTI_AGENT_V2_MODEL_OVERRIDE_USAGE_HINT_TEXT}`; }