AI Agent Shells: Four Execution Modes and Trajectory Design
This article explains why the agent shell has become a critical engineering layer alongside the model, and breaks down four composable execution modes: standard, code orchestration, minimal, and creation. It also covers execution trajectory design for replay and auditing, plus a practical enterprise checklist for permissions, observability, cost, and quality baselines. Readers will learn how shell design affects what a model can see, do, and recover from in real environments.
1. Why the “Shell” Has Become a Critical Engineering Layer for Agents
In the context of AI agents, the “shell” refers to the full engineering system that sits outside the model. It handles reading files, calling tools, managing context, retrying after failures, and sustaining long-running tasks that can last for hours. The model provides reasoning and decision-making; the shell is what allows an agent to understand its situation in a real environment, use tools, and keep working. As AI coding tools have been validated commercially, this layer has become a contested area for model vendors and cloud platforms, and Baidu AI Cloud continues to invest in related engineering capabilities.
It is important to stress that the shell is not a “UI skin.” It is a runtime. It determines what the model can see, what it can do, how it recovers from failure, and whether the process is auditable. A well-designed shell typically includes five elements: tool registration with permission boundaries, a context assembly strategy, an execution event stream, an error recovery mechanism, and extensible mode definitions.
2. Four Execution Modes: A Composable Shell Instead of a Single Form
1. Standard Mode: The Engineering Baseline with a Full Toolchain
Standard mode provides capabilities such as file editing, command execution, file and web search, skill invocation, task planning, goal management, sub-agent dispatch, and workflow orchestration, making it suitable for end-to-end coding tasks. Its engineering value lies in turning “capabilities” into pluggable components: tools are registered through a unified interface, permissions are constrained by declarative policies, and long tasks are broken down into verifiable intermediate states through planning and goal management.
A schematic tool registration structure is shown below (for general illustration only):
{"tools": [{"name": "read_file", "scope": "workspace", "readonly": true},{"name": "edit_file", "scope": "workspace", "requires": ["diff_preview"]},{"name": "run_command", "scope": "sandbox", "timeout_s": 120}],"policy": {"network": "allowlist", "secrets": "deny"}}
2. Code Orchestration Mode: Compressing Multiple Round Trips into a Single Execution
Traditional tool calling is a multi-turn “model-tool-model” round trip. Ten operations often mean ten context round trips, and both latency and context cost accumulate. Code orchestration mode exposes tools to the model through a software development kit (SDK), and the model writes a program directly, merging multiple tool operations into a single execution. The benefit is not just fewer round trips; it is the ability to express control flow: loops, conditionals, parallelism, and aggregation can all be completed within one piece of code.
// Pseudocode: complete search, filtering, and aggregation in a single executionconst files = await tools.search({ query: "auth", glob: "**/*.ts" });const hits = files.filter(f => f.score > 0.6).slice(0, 20);const summary = await tools.aggregate(hits.map(h => h.path));return summary;
Three points require attention in engineering practice. First, sandboxing and resource quotas are needed to prevent a program from running out of control. Second, tool-call observability is still required, and each call should still be logged individually. Third, failure semantics must be clear: define which step can be retried on failure and which step must be rolled back.
3. Minimal Mode: The “Bare Model” Baseline with the Shell Stripped Away
Minimal mode keeps only a persistent command execution environment and a file editor, removing planning, search, skills, sub-agents, and other extras. Its purpose is benchmarking: evaluating the model’s own code comprehension and generation ability under a minimal shell, avoiding the risk that shell capabilities mask model differences. For teams, this provides an important control-experiment path: the difference in pass rate for the same model between minimal and standard modes can quantify the incremental value brought by the shell.
4. Creation Mode: Defining New Modes with Natural Language
Creation mode is used to “create modes”: by describing goals and constraints in natural language, it generates a new set of tools, prompts, and process orchestration, and consolidates them into reusable configuration. It turns the shell from a “fixed product” into an “evolvable platform,” enabling teams to iterate quickly by business scenario, such as generating a mode that only does code review, or a mode that only does data migration.
3. Execution Trajectory: Giving the Agent a Built-in Black Box
One often-underestimated design is the execution trajectory. Everything the model sees—system prompts, reasoning process, tool calls and results, sub-agent dispatch, and every context injection—is written into an append-only session log. Based on this event stream, you can support session recovery, forking, retrieval, and replay. Its value shows in three areas:
- Review: pinpoint “why the model did this,” rather than only looking at the final patch;
- Forking: try different strategies from any node and compare results;
- Auditing and compliance: retain a complete evidence chain to meet enterprise internal-audit requirements.
The implementation recommendation is to adopt a structured event model and annotate each event with its source and elapsed time:
event{ id, ts, source(system|model|tool|subagent), type, payload, latency_ms }
4. Enterprise Adoption Checklist
- Least privilege: workspace isolation, network allowlist, and blocked secrets;
- Observability: connect trajectory logs to logging services and monitoring alerts, and set up alerts for abnormal tool calls;
- Cost governance: track context and call volume by mode and task type;
- Quality baseline: use minimal mode for the model baseline and standard mode to evaluate the shell’s incremental value;
- Asset consolidation: bring configuration produced by creation mode into version control and review.
In summary, agent competition has shifted from a “single model point” to a systems-engineering combination of “model + shell + observability.” Only by mastering patterned shells and trajectory design can you deliver agent capabilities in real business settings in a stable and auditable way.
