How to Choose an AI Model & Agent Stack
There is no universal winner: choose against a defined task, representative evaluation set, security boundary, latency target, and cost ceiling. Public benchmarks are evidence inputs, not a substitute for testing your workflow.
An agent stack is more than a model. It includes prompts, context assembly, retrieval, tools, permissions, orchestration, validation, observability, and human approval. Changing any layer can change quality and cost. Use this framework to create a shortlist and run a fair evaluation.
1. Define the outcome
Describe a successful user task in observable terms. “Good at coding” is too vague. Better definitions include “finds and fixes a defect in this repository while passing existing tests” or “extracts invoice fields with no invented values and flags uncertainty.”
Write acceptance criteria before comparing models:
- required correctness and allowed uncertainty;
- maximum latency and cost per accepted task;
- input languages, modalities, and context size;
- tools and data sources the system must use;
- actions that require human approval;
- privacy, data residency, and retention constraints.
2. Decide whether you need an agent
| Work pattern | Start with | Reason |
|---|---|---|
| One transformation with a known input and output | Single model call | Less latency, cost, and failure surface |
| Answer from changing private documents | Retrieval plus model | Grounds answers in current sources |
| Several known deterministic steps | Workflow or state machine | Explicit control and easier testing |
| Dynamic tool choice across uncertain steps | Constrained agent | Useful when the sequence cannot be fixed in advance |
Do not add autonomous loops to a task that a deterministic pipeline can solve. Each new decision point needs permissions, stop conditions, evaluation, and observability.
3. Build a model shortlist
Filter models by hard requirements first: supported input/output modalities, context, structured outputs, tool use, deployment region, data policy, and budget. Then compare capability. The model shortlist tool uses this site's reviewed model data and states its rule-based logic; it does not rank every model on the market.
Use vendor-published benchmarks only for orientation. Check whether the model version, tool allowance, prompting, pass criterion, and date match your use case. Results from different publishers are rarely directly comparable.
4. Evaluate the complete system
Create a representative set of ordinary, difficult, ambiguous, and adversarial tasks. Keep a hidden test set to reduce overfitting. For coding agents, use isolated repositories and verify changes by tests, static analysis, and human review. For factual work, require traceable sources. For structured work, validate schemas and business rules.
Record at least:
- task success and severity-weighted failure;
- human-review time and correction rate;
- input, cached-input, and output tokens;
- calls, retries, tool steps, and fallback frequency;
- latency percentiles and timeout rate;
- unsafe actions, data leakage, and policy violations.
5. Compare cost per accepted task
Token prices alone ignore agent loops and quality. Use the cost calculator for a request estimate, then add the observed number of calls, retries, tool charges, and review cost. Our cost-planning guide explains the full method.
A smaller model can handle simple traffic while difficult cases escalate to a more capable one. Validate routing against a single-model baseline; the router itself adds latency and can send hard tasks to the wrong destination.
6. Design the security boundary
Model output is untrusted input. Give tools the minimum permissions needed, separate read from write operations, validate every argument, and require confirmation for consequential actions. Protect secrets from prompts and logs. Treat retrieved documents, web pages, issues, and tool results as potentially malicious instructions.
For local deployment, include runtime hardening, model provenance, network binding, authentication, updates, and logging in the evaluation. The local deployment guide compares common runtime roles.
7. Prefer explicit orchestration
Use a state machine or bounded workflow where possible. Define maximum turns, tool budgets, timeout behavior, retry limits, and escalation to a person. Make side effects idempotent so a retry does not duplicate a payment, message, or deployment. Store enough trace data to reconstruct decisions without retaining unnecessary sensitive content.
8. Test change safely
Models and provider defaults change. Pin model versions where supported and maintain regression tests. Before switching, run the new candidate in shadow or limited traffic, compare outcome distributions, and keep a rollback path. Review price, deprecation, and data-policy changes on a schedule.
A compact scorecard
| Dimension | Example measure | Gate or trade-off? |
|---|---|---|
| Task quality | Accepted results / evaluation tasks | Usually a gate |
| Safety | Critical violations and approval bypasses | Gate |
| Privacy | Compliance with data-flow requirements | Gate |
| Latency | P50 and P95 end-to-end time | Target |
| Cost | Cost per accepted task | Target |
| Operations | Error rate, recovery, observability | Target |
Do not collapse safety and privacy gates into a weighted average where a cheap result can compensate for a critical violation.
Questions before launch
- What evidence demonstrates that the selected system meets the task?
- Which failures stop automatically, and which escalate?
- Can the model or a retrieved page cause a write without approval?
- What data leaves the application, where is it retained, and for how long?
- What happens when a provider, tool, or retrieval source is unavailable?
- Can we reproduce and roll back the deployed configuration?
Primary references
- NIST AI Risk Management Framework
- OWASP prompt injection risk
- OWASP excessive agency risk
- MCP security best practices
Bottom line
Start from a measurable outcome and hard safety constraints. Shortlist models that fit, evaluate the entire stack on representative tasks, and choose by accepted-task quality, latency, and total cost—not brand or one benchmark.