LLM Selection for Agent Development: Capabilities and Safeguards to Evaluate First
This article explains how large language models are used in agent-based software development, what capabilities matter for context understanding, task decomposition, and tool-calling loops, and what engineering safeguards—sandboxing, prompt and tool definitions, state management, secrets, and audit logging—are needed before integration. It also outlines a task-tiered approach to evaluating cost and performance during model selection.
The use of large language models in software development has moved from code completion toward Agents. Agents can plan steps, read and write files, execute terminal commands, and modify code based on error results. As capabilities increase, risk and cost increase as well. From an engineering perspective, this article explains what models can do in Agent scenarios, what safeguards are required, and how to approach model selection. The numerical values in this article are starting references and should be tested in your own projects.
1. Core LLM Capabilities in Agent Scenarios
1.1 Context understanding
A model’s knowledge of programming language specifications, third-party library versions, and security patches depends on its training data cutoff. Different models have different cutoff dates, so check the relevant vendor’s official documentation before selection. Knowledge updates can reduce the probability of the model producing outdated APIs, but they cannot eliminate it. Content involving version numbers and interface signatures still needs to be verified through compilation and testing.
The model can also read the working directory, dependency configuration, and environment variables in the system prompt to generate code that fits the current project. However, it can only see the information provided to it. Once sensitive variables enter the context, they may be written to logs or sent to external services, so the content passed in must be strictly controlled.
1.2 Complex task decomposition
For requests such as “refactor a module and add unit tests,” stronger models usually analyze the existing structure first, then create a plan, modify code, write tests, and run them. This process needs boundaries. It is recommended to set a maximum retry count for each task. For example, stop after the same step fails three times and hand the task to a human. Also require the Agent to write acceptance criteria before starting, such as the scope of tests that must pass, files that may be modified, and directories that must not be changed.
1.3 Tool calling and closed-loop correction
Agents call file systems, terminals, and version control tools through SDKs. They execute commands, read errors, modify code, and run again. This generate-execute-correct loop is a key metric for practical usability. But the longer the loop, the more resources it consumes and the greater the possibility of errors. Therefore, the loop needs to be used with timeouts and turn limits.
2. Engineering Preparation Before Integration
2.1 Sandbox isolation
Because Agents can execute code, they must run in an isolated environment. A common approach is to allocate a separate container for each development task and meet the following constraints:
- Mount the source code directory as read-only, with only the designated output directory writable;
- Disable network access by default and allow access only to whitelisted domains;
- Set CPU, memory, and disk quotas;
- Set a timeout for each command and a maximum runtime for the entire task.
There are no universal standards for these parameters; adjust them according to project size and test duration.
2.2 Prompts and tool definitions
The system prompt defines the Agent’s behavioral boundaries. The code below shows how environment information and a tool list are passed to the model. It is a skeleton and cannot run directly. The model client must be replaced with the real interface of the SDK you use, and the actual execution functions for tools must be written separately with permission checks.
import osimport subprocessfrom typing import Anyclass DevAgentRunner:# Only allow access under this workspace prefix to prevent path traversalALLOWED_ROOT = "/sandbox/workspace"def __init__(self, model_client: Any, workspace_path: str):if not os.path.abspath(workspace_path).startswith(self.ALLOWED_ROOT):raise ValueError("Working directory is outside the allowed root")self.model = model_clientself.workspace = workspace_pathdef get_env_context(self) -> str:# Return only non-sensitive information; do not put secret variables in contextsafe_keys = ["PYTHON_VERSION", "NODE_VERSION"]lines = [f"{k}={os.environ.get(k, 'not set')}" for k in safe_keys]result = subprocess.run(["git", "-C", self.workspace, "status", "--short"],capture_output=True, text=True, timeout=10,)return "\n".join(lines) + "\n" + result.stdoutdef get_available_tools(self) -> list[dict]:# Only expose file reading and test execution; no deletion or pushreturn [{"name": "read_file", "scope": "workspace", "readonly": True},{"name": "run_tests", "timeout_sec": 300},]def init_system_prompt(self) -> str:return ("You are a development agent running in an isolated sandbox.\n"f"Working directory: {self.workspace}\n"f"Environment information:\n{self.get_env_context()}\n""State your plan first, then execute step by step. When you encounter an error, ""analyze the logs and try to fix it. Stop after three consecutive failures and explain why.")def execute_task(self, user_prompt: str) -> Any:messages = [{"role": "system", "content": self.init_system_prompt()},{"role": "user", "content": user_prompt},]return self.model.chat(messages, tools=self.get_available_tools())
2.3 State management, secrets, and auditing
Long tasks may involve dozens of conversation turns. After the context exceeds the window, the model loses early information. Therefore, key state—such as completed steps, pending items, and the list of modified files—should be written to external storage periodically instead of being kept entirely in the conversation.
Every tool call should record the time, tool name, parameter summary, and return status. Logs must be redacted to remove tokens, passwords, and customer data. API keys should be injected through environment variables or a secret management service and must not be written into code, prompts, or logs.
Before the Agent writes files, it should commit to a separate branch or take a snapshot so that errors can be rolled back. Do not let the Agent directly force-push to or delete the main branch. These actions require human confirmation.
3. Cost and Performance Evaluation for Selection
3.1 Select models by task tier
Different tasks vary greatly in their need for reasoning depth. The table below presents a tiering approach; specific model tiers need to be determined based on vendor pricing and your own test results.
| Task type | Typical examples | Metrics to watch | Upgrade condition |
|---|---|---|---|
| Simple fixes | Syntax errors, formatting adjustments, renaming | Per-run cost, response latency |
