This prompt is a core component of an orchestrator's control loop, not a general-purpose chatbot interface. Its job-to-be-done is to make a defensible, auditable routing decision when a new task arrives. The ideal user is an AI architect or platform engineer building a compound AI system where work must be dispatched across a pool of specialized sub-agents. The prompt requires three structured inputs to function: a machine-readable agent registry detailing each agent's capabilities, current load, and past performance; a well-formed task description with explicit constraints; and the operational parameters like latency budgets and cost limits that govern the dispatch decision. Without these, the selection logic degrades into guesswork.
Prompt
Sub-Agent Selection Criteria Prompt Template

When to Use This Prompt
A decision-support prompt for orchestrator designers who need to programmatically select the best sub-agent for a task from a registry of available agents.
Do not use this prompt for direct task execution, user-facing chat, or single-agent workflows. It is a decision-support tool whose output—a ranked agent selection with rejection reasons—must feed into downstream dispatch logic, handoff protocols, and audit trails. The prompt is designed to enforce explicit reasoning: it requires the model to document why non-selected agents were rejected, apply tie-breaking rules when capability matches are equivalent, and consider dynamic factors like agent load and recent failure rates. For high-stakes dispatch decisions, the output should be logged immutably and, where the cost of misrouting is severe, subjected to a secondary validation check or human approval before the handoff executes.
After integrating this prompt, your next step is to wire its structured output into your orchestrator's dispatch function. The ranked list should drive agent selection, the rejection reasons should populate your observability dashboards, and the tie-breaking logic should be periodically reviewed against production outcomes to detect drift in agent performance. Avoid the common failure mode of treating this as a static routing table; agent capabilities and loads change, and a prompt that worked last month may silently route tasks to overloaded or degraded agents if the registry input is stale.
Use Case Fit
Where the Sub-Agent Selection Criteria prompt works, where it fails, and what you must provide before using it in a production orchestrator.
Good Fit: Stable Agent Registry
Use when: you have a known, versioned set of sub-agents with declared capabilities, tool access, and performance profiles. Avoid when: agents are ephemeral, unregistered, or lack machine-readable capability manifests. The prompt relies on structured comparison data, not runtime discovery.
Bad Fit: Single-Step Tool Choice
Avoid when: you only need to pick a single function or API call. This prompt is over-engineered for simple tool selection. Use instead: a lightweight function-calling prompt with argument schemas. Reserve this template for multi-capability agent dispatch where trade-offs between cost, latency, and capability are real.
Required Input: Agent Capability Manifests
Risk: the model hallucinates agent capabilities or selects an agent that doesn't exist. Guardrail: provide a structured manifest per agent with agent_id, capabilities[], tool_access[], latency_profile, cost_profile, and explicit_limitations[]. Feed this into the prompt as a JSON block. Never rely on natural-language descriptions alone.
Operational Risk: Stale Performance Data
Risk: selection decisions based on outdated latency or cost data cause production degradation. Guardrail: include a data_freshness timestamp in the prompt context. If the manifest is older than your freshness threshold (e.g., 15 minutes for latency data), append a warning instruction to deprioritize stale metrics and fall back to capability matching.
Operational Risk: Tie-Breaking Ambiguity
Risk: multiple agents score identically, causing non-deterministic selection or wasted compute on re-evaluation. Guardrail: include explicit tie-breaking rules in the prompt (e.g., prefer lower cost, then lower latency, then alphabetical agent ID). Log tie events for later review of your capability definitions.
Bad Fit: Unbounded Latency Budgets
Risk: the orchestrator selects a capable but slow agent when a fast response is required. Guardrail: always pass a latency_budget_ms parameter. Instruct the model to reject any agent whose p95 latency exceeds the budget, even if it is the most capable match. Escalate to a fallback or human review if no agent fits.
Copy-Ready Prompt Template
A production-ready prompt template for selecting the best sub-agent from a registry based on weighted criteria, tie-breaking rules, and escalation logic.
This prompt template implements a deterministic orchestrator that selects a sub-agent from a registry without executing the task itself. It is designed for compound AI systems where a dispatcher must evaluate multiple candidates against capability, latency, cost, and performance constraints before routing work. The template enforces explicit selection rules, documents why agents were rejected, and escalates to a human operator when no agent meets the minimum threshold—making the decision auditable and debuggable in production.
textYou are an orchestrator selecting the best sub-agent for a task. Your output will be consumed by a dispatch system. Do not execute the task yourself. ## Agent Registry [AGENT_REGISTRY] ## Task [TASK_DESCRIPTION] ## Operational Constraints - Latency budget: [LATENCY_BUDGET_MS] ms - Cost budget: [COST_BUDGET_USD] USD - Required output format: [OUTPUT_FORMAT] - Priority: [PRIORITY_LEVEL] ## Selection Rules 1. Filter agents whose declared capabilities match all required capabilities for the task. 2. Exclude agents whose current load exceeds [MAX_LOAD_PERCENT]% or whose status is not 'available'. 3. Score remaining agents on: capability match (0-100), estimated latency fit (0-100), cost fit (0-100), and past success rate for similar tasks (0-100). 4. Apply weights: capability match 40%, latency fit 25%, cost fit 20%, past performance 15%. 5. Rank agents by weighted score descending. 6. If the top two agents are within [TIE_THRESHOLD] points, apply tie-breaker: prefer the agent with lower current load, then lower estimated cost. 7. If no agent meets the minimum score of [MINIMUM_SCORE], recommend escalation to a human operator. ## Output Format Return a JSON object with this exact structure: { "selected_agent": { "agent_id": "string", "agent_name": "string", "weighted_score": number, "selection_reason": "string" }, "ranking": [ { "rank": number, "agent_id": "string", "agent_name": "string", "weighted_score": number, "capability_score": number, "latency_score": number, "cost_score": number, "performance_score": number } ], "rejected_agents": [ { "agent_id": "string", "agent_name": "string", "rejection_reason": "string" } ], "escalation_required": boolean, "escalation_reason": "string | null" }
To adapt this template, replace each square-bracket placeholder with concrete values from your agent infrastructure. The [AGENT_REGISTRY] should contain a structured list of agents with their agent_id, agent_name, declared_capabilities, current_load_percent, status, estimated_latency_ms, estimated_cost_usd, and past_success_rate. The [TASK_DESCRIPTION] must include enough detail for capability matching—vague task descriptions produce unreliable selections. Tune the weights in rule 4 to match your operational priorities: latency-sensitive systems should increase the latency weight, while cost-constrained deployments should emphasize cost fit. The [TIE_THRESHOLD] and [MINIMUM_SCORE] values should be calibrated against historical selection quality; start with a threshold of 5 points and a minimum score of 60, then adjust based on production outcomes.
Before deploying this prompt, validate that the output JSON matches the declared schema exactly—any deviation will break the downstream dispatch system. Add a post-processing validator that checks for required fields, numeric ranges on scores, and the presence of escalation_reason when escalation_required is true. For high-stakes routing decisions, log the full ranking and rejection reasons alongside the selected agent so operators can audit selection quality over time. If the orchestrator consistently escalates or selects the same agent regardless of task, review whether the agent registry contains accurate capability declarations and whether the scoring weights reflect real-world performance rather than optimistic estimates.
Prompt Variables
Required inputs for the Sub-Agent Selection Criteria prompt. Each placeholder must be populated before the orchestrator can produce a valid, auditable selection decision.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[AGENT_REGISTRY] | Machine-readable manifest of available sub-agents with capabilities, current load, cost profile, and latency class | {"agents":[{"id":"code-reviewer","capabilities":["static-analysis","diff-review"],"load":0.4,"cost_per_1k_tokens":0.003,"latency_class":"medium"}]} | Must be valid JSON array with required fields: id, capabilities, load, cost_per_1k_tokens, latency_class. Reject if any agent missing id or capabilities. |
[TASK_SPECIFICATION] | Structured description of the work to be assigned including required capabilities, latency budget, cost ceiling, and priority | {"required_capabilities":["python","sql"],"latency_budget_ms":2000,"cost_ceiling_usd":0.05,"priority":"high"} | Must include required_capabilities as non-empty array. latency_budget_ms and cost_ceiling_usd must be positive numbers. Reject if required_capabilities is empty. |
[PERFORMANCE_HISTORY] | Recent success/failure rates per agent for similar task types, used for past-performance weighting | {"code-reviewer":{"success_rate":0.94,"avg_latency_ms":1200,"last_10_tasks":"pass,pass,fail,pass,pass,pass,pass,pass,pass,pass"}} | Must be valid JSON with agent IDs matching AGENT_REGISTRY. success_rate must be 0.0-1.0. Null allowed if no history exists for an agent. |
[TIE_BREAKING_POLICY] | Explicit rules for resolving ties when multiple agents score equally on primary criteria | {"primary":"lowest_cost","secondary":"lowest_load","tertiary":"highest_success_rate"} | Must specify at least primary tie-breaker. Allowed values: lowest_cost, lowest_load, highest_success_rate, lowest_latency, random. Reject if primary is missing or invalid. |
[REJECTION_DOCUMENTATION_REQUIREMENT] | Boolean flag controlling whether the prompt must produce explicit rejection reasons for each non-selected agent | Must be true or false. When true, output must include rejection_reasons array with an entry per non-selected agent. When false, rejection_reasons may be omitted. | |
[OUTPUT_SCHEMA] | Expected structure for the selection output including ranked list, scores, rejection reasons, and audit fields | {"selected_agent":"string","ranked_candidates":[{"agent_id":"string","score":"number","criteria_breakdown":"object"}],"rejection_reasons":[{"agent_id":"string","reason":"string"}],"decision_timestamp":"string"} | Must be valid JSON Schema or example structure. selected_agent and ranked_candidates are required. Validate that output conforms to this schema before accepting selection. |
[CONSTRAINT_OVERRIDES] | Runtime overrides that temporarily modify agent eligibility, cost limits, or capability requirements | {"excluded_agents":["legacy-analyzer"],"override_cost_ceiling_usd":0.10,"force_agent":null} | Must be valid JSON. excluded_agents must match AGENT_REGISTRY ids. force_agent bypasses selection logic entirely and must be logged. Null allowed when no overrides active. |
Implementation Harness Notes
How to wire the sub-agent selection prompt into an orchestrator with validation, fallbacks, and audit logging.
Wire this prompt into your orchestrator's agent selection function. The orchestrator should call this prompt before every dispatch decision. Pass the agent registry as a JSON array of capability manifests. Each manifest must include agent_id, agent_name, capabilities (array of strings), current_load_percent, status, estimated_latency_ms, estimated_cost_usd, and past_success_rate. The task description should be a structured object with required_capabilities, input_data_summary, and any special instructions. Parse the JSON output and validate it against the expected schema before using the selected_agent field to route the task.
Log the full ranking and rejected_agents list to your audit system for post-incident review. If escalation_required is true, route to your human review queue with the escalation_reason attached. Set a timeout on the model call; if it fails, fall back to a static routing rule or escalate. Validate that the selected agent's agent_id exists in your current registry and that its status is active before dispatch. Reject selections where the agent is overloaded (current_load_percent > 90) or where estimated_latency_ms exceeds your task's latency budget. For high-risk tasks, require a second validation pass or a human approval step before the dispatch executes.
Choose a model with strong JSON output reliability for this prompt. GPT-4o and Claude 3.5 Sonnet work well with the structured output schema. Avoid smaller models that may drop fields or hallucinate agent IDs. If you use a model that doesn't support strict JSON mode, add a post-processing step that extracts and repairs the JSON payload before validation. Cache the agent registry manifest between calls to reduce token usage, but refresh it when agent status or load changes. If your registry exceeds 20 agents, consider pre-filtering by capability match before passing the full list to the prompt to stay within context limits.
Expected Output Contract
Fields, types, and validation rules for the structured output produced by the Sub-Agent Selection Criteria Prompt. Use this contract to parse and validate the orchestrator's selection decision before executing a handoff.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
selected_agent_id | string | Must match an agent_id from the provided [AGENT_REGISTRY]. Reject if not found. | |
selection_rank | integer | Must be 1. Only the top-ranked agent is returned. Reject if value is not 1. | |
confidence_score | float | Must be between 0.0 and 1.0. If below [CONFIDENCE_THRESHOLD], trigger human review or fallback routing. | |
capability_match | array of strings | Each string must reference a capability declared in the selected agent's manifest. Reject if any capability is not in the manifest. | |
rejected_agents | array of objects | Each object must contain agent_id and rejection_reason. Reject if selected_agent_id appears in this array. | |
tie_breaking_rule | string | If present, must match one of the predefined rules in [TIE_BREAKING_POLICY]. Null allowed when no tie occurred. | |
cost_estimate | object | Must contain estimated_tokens and estimated_latency_ms. Reject if values are negative or exceed [MAX_COST_BUDGET]. | |
handoff_ready | boolean | Must be true before the orchestrator executes the handoff. If false, block the transition and log the reason. |
Common Failure Modes
What breaks first when selecting sub-agents and how to guard against it in production orchestrators.
Capability Over-Claim During Registration
What to watch: Sub-agents declare capabilities they cannot reliably deliver, causing the orchestrator to route tasks to agents that will fail. This often happens when capability manifests are hand-written rather than derived from actual tool access and tested performance. Guardrail: Validate every declared capability against the agent's actual tool list and run periodic capability probes—send known test tasks and verify the agent completes them before trusting the manifest.
Stale Load and Latency Estimates
What to watch: The orchestrator selects an agent based on load or latency metrics that are minutes old, routing work to an agent that is now overloaded or timing out. Selection criteria that look at historical averages rather than current state produce cascading failures. Guardrail: Require sub-agents to report current load and recent p99 latency in their heartbeat or registration payload. Reject selection if metrics are older than a configurable freshness threshold.
Tie-Breaking Without Documentation
What to watch: When multiple agents score equally on selection criteria, the orchestrator picks arbitrarily without recording why. This makes post-incident review impossible—you cannot determine if the right agent was chosen or if the criteria need adjustment. Guardrail: Require the selection prompt to output explicit tie-breaking rationale and log the full ranked list with scores, not just the winner. Include a rejection_reasons field for every non-selected agent.
Cost Blindness Under Load
What to watch: Under high throughput, the orchestrator defaults to the fastest or most available agent, ignoring cost constraints that were specified in the selection criteria. Latency pressure silently overrides budget controls. Guardrail: Make cost a hard constraint, not a soft preference. If no agent satisfies both latency and cost budgets, the orchestrator must escalate or queue rather than silently exceed the cost limit. Log every cost-over-budget decision.
Past Performance Amnesia
What to watch: The orchestrator repeatedly selects an agent that has recently failed similar tasks because selection criteria don't incorporate recent failure signals. Each selection is treated as independent, creating a failure loop. Guardrail: Feed recent per-agent error rates and task-type match scores into the selection prompt. Implement circuit-breaker logic: if an agent fails N tasks of a given type within a window, temporarily deprioritize or exclude it from selection for that task type.
Context Contamination Across Selections
What to watch: The orchestrator prompt leaks information about one candidate agent's capabilities or limitations into the evaluation of another agent, especially when the selection is done in a single model call with all agent manifests in context. The model confuses or merges agent profiles. Guardrail: Structure the selection prompt so each agent is evaluated independently against the task before comparison. Consider pairwise evaluation or separate scoring passes. Validate that the output does not attribute one agent's capability to another.
Evaluation Rubric
Use this rubric to evaluate the quality of the sub-agent selection output before integrating it into the orchestrator's dispatch logic. Each criterion targets a specific failure mode common in capability-matching and tie-breaking prompts.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Capability Match Accuracy | The top-ranked agent's declared capabilities in [AGENT_REGISTRY] exactly cover all required skills in [TASK_REQUIREMENTS]. No hallucinated capabilities are attributed to the agent. | Selected agent is missing a required skill, or the justification cites a capability not present in the agent's manifest. | Parse the selection justification. Cross-reference each cited capability against the agent's entry in [AGENT_REGISTRY]. Flag any capability not found in the manifest. |
Constraint Compliance | The selection respects all hard constraints in [CONSTRAINTS], including latency budget, cost ceiling, and required tool access. No constraint violation is present in the ranked list. | A selected agent exceeds the latency budget, cost limit, or lacks a required tool. The justification ignores or misinterprets a hard constraint. | Extract all numerical and boolean constraints from [CONSTRAINTS]. For each ranked agent, verify latency, cost, and tool access against the registry. Fail if any hard constraint is violated. |
Tie-Breaking Rule Adherence | When multiple agents have equal capability scores, the tie-breaking rules in [TIE_BREAKING_RULES] are applied in the specified order. The justification cites the specific rule used. | Tied agents are ranked arbitrarily, or the justification invents a tie-breaking reason not present in [TIE_BREAKING_RULES]. | Identify all agent pairs with equal capability scores. Verify the ranking order matches the priority sequence in [TIE_BREAKING_RULES]. Check that the justification text references the rule by name. |
Rejection Documentation Completeness | Every non-selected agent in [AGENT_REGISTRY] has a documented rejection reason. The reason is specific, factual, and references a capability gap, constraint violation, or lower priority score. | One or more non-selected agents are missing from the rejection list, or the rejection reason is generic (e.g., 'not suitable') without citing a specific criterion. | Count the agents in [AGENT_REGISTRY]. Verify that the output contains exactly N-1 rejection entries (where N is total agents). Check each rejection reason for a specific reference to a capability, constraint, or score. |
Current Load Consideration | The selection accounts for [AGENT_LOAD] data. An agent at capacity is deprioritized or excluded, and the justification mentions current load as a factor. | A fully loaded agent is ranked first without acknowledging its capacity status, or load data is ignored entirely in the ranking. | Parse [AGENT_LOAD] for each agent. If any agent is at or above its capacity threshold, verify it is not ranked first unless all alternatives are also at capacity. Check the justification for a load mention. |
Past Performance Integration | The selection references [PAST_PERFORMANCE] data when available. Agents with recent failure patterns or low success rates are appropriately deprioritized with a documented reason. | Past performance data is present in the input but absent from the selection reasoning. A historically unreliable agent is ranked above a reliable one without explanation. | Check if [PAST_PERFORMANCE] is non-empty. If so, verify that the justification text mentions performance history for at least the top 2 ranked agents. Flag if a low-performing agent outranks a high-performing one without a documented override reason. |
Output Schema Validity | The output strictly conforms to [OUTPUT_SCHEMA]. All required fields are present, enums match allowed values, and the ranked list is ordered correctly. | Missing required fields, invalid enum values, or the ranked list is not in descending order of preference. | Validate the output against [OUTPUT_SCHEMA] using a JSON Schema validator. Check that the 'rankings' array is sorted by the 'score' field in descending order. Fail on any schema violation. |
Confidence Score Calibration | Each ranking entry includes a confidence score between 0.0 and 1.0. The top-ranked agent has a score above the minimum threshold defined in [CONFIDENCE_THRESHOLD]. Scores are consistent with the justification. | Confidence scores are missing, outside the 0.0-1.0 range, or the top agent's score is below [CONFIDENCE_THRESHOLD] without triggering a fallback recommendation. | Parse all confidence scores. Verify range compliance. Check if the top score is below [CONFIDENCE_THRESHOLD]. If so, verify the output recommends escalation or human review. Flag if a high-confidence score contradicts a weak justification. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a small, hardcoded agent registry (3-5 agents). Replace [AGENT_REGISTRY] with a simple inline list of agent names, capabilities, and cost estimates. Skip the tie-breaking rules section initially and let the model reason freely. Run 20-30 test selections and manually review rankings before adding formal eval criteria.
Watch for
- The model fabricating agent capabilities not in your registry
- Rankings that sound plausible but ignore latency or cost constraints
- Overly verbose justifications that burn tokens without adding decision value
- No clear rejection reason for non-selected agents

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us