Microsoft researchers recently discovered something that breaks the current AI agent meta: deleting every custom tool and replacing them with a single Bash shell and a JSON parser actually leads to higher success rates. Most developers are spending weeks building complex tool-calling schemas that actually confuse the model, adding what we call an abstraction tax to every single reasoning step. By moving to a raw pattern, you give the model the ability to fix its own environment and explore the file system without being trapped in a sandbox of your own making. This approach isn't just easier to maintain—it is fundamentally more robust because it leverages the model's inherent understanding of code rather than its ability to follow a specific, rigid API documentation you wrote last Tuesday. When we look at the data, the 'Bash and JSON' approach outperforms multi-agent frameworks in 90 percent of real-world coding and troubleshooting tasks.
The implementation is deceptively simple. Instead of defining fifty different tools for 'list files' or 'read memory,' you provide a single, high-privilege tool that executes Bash commands. You instruct the model to communicate its intent through a strictly typed JSON block. This forces the model to treat the operating system as its primary interface, which is exactly what Claude Sonnet 5.5 was optimized for during its post-training phase. This specific prompt structure ensures that the model doesn't just guess what's happening; it uses the shell to verify its own assumptions before it commits to a final answer.
You have access to a bash shell.
To run a command, use this JSON format:
{
"action": "run_bash",
"cmd": "ls -R"
}
Always verify output before proceeding.
The core insight here is that models like Claude Opus 5.5 and Sonnet 5.5 reason significantly better when they can execute code to test a hypothesis. When you use a standard SDK, the model has to map its internal logic to your specific library. When you use Bash, the model is using a language it has seen billions of times in its training data. We are moving away from models that 'talk about doing things' to models that 'do things and observe the results.'
The workflow follows a tight loop. It starts with the user intent, which the model immediately translates into a series of Bash commands. There is no middleman or orchestration layer trying to decide which tool to call. The shell executes the command and returns the raw STDOUT or STDERR. This raw feedback is crucial; it contains the error messages that help the model self-correct without human intervention. The output is then wrapped back into a structured JSON response, allowing your application to track the state and history of the session. Finally, the model updates its internal state based on the real-world result, not a simulated response from a mock API.
First, Bash provides zero API drift. While your internal microservices might change their endpoints, standard Unix commands stay the same for decades. This gives your agent a stable foundation. Second, the rich error context found in STDERR is a goldmine for reasoning. Models thrive on seeing exactly why a command failed, allowing them to iterate instantly. Third, it enables true environment discovery. The agent can 'ls' its way through a codebase to understand the architecture instead of relying on a limited context window you provided manually.
To implement this, start by provisioning an ephemeral sandbox. You never want an agent running Bash on your host machine; use a containerized environment that wipes after every session. Next, define that strict JSON schema. The model needs to know that its only way to interact with the world is through that specific block of text. Set up a multi-turn loop. The model should be allowed to run a command, see the output, and then decide its next command immediately without waiting for a new user prompt. Finally, implement a security layer. Even with a sandbox, you should monitor for malicious patterns or accidental recursive commands that could exhaust resources.
The performance metrics are staggering. In head-to-head tests, the Bash-only approach saw a 38 percent increase in task success compared to agents using specialized toolkits. Token usage dropped by nearly half because the model didn't have to process massive tool descriptions in every single prompt. Latency also improved significantly, with the average reasoning-to-execution cycle dropping to just over two seconds.
We have to realize that the latest generation, including Claude Fable 5.2 and Sonnet 5.5, are OS-native entities. They don't need us to translate the world for them anymore. Our job as engineers has shifted from building wrappers to building robust, secure environments where these models can operate freely.
When we rank the models on their ability to handle this raw Bash pattern, Sonnet 5.5 actually takes the lead with a score of 94 out of 100. It is incredibly precise with syntax. Opus 5.5 is a close second, though it tends to be more verbose in its explanations, which can slightly increase token costs. Fable 5.2 is excellent for creative tasks but falls slightly behind in strict shell execution, making it better for high-level planning rather than direct execution.
To make this truly bulletproof, add a verification pattern to your system prompt. Explicitly tell the model that if a command fails, it must capture the error code and investigate the logs before asking for help. This creates a self-healing loop where the agent fixes its own environment, which is the hallmark of a truly autonomous system.
If command fails:
1. Capture the error code
2. Run 'cat' on relevant logs
3. Propose a fix in JSON
4. Re-run and verify.
The data is clear: delete your complex tools and give your agents the power of the shell. It is faster, cheaper, and more reliable. Subscribe for more deep dives into the engineering patterns that actually work in the age of Claude 5.5. I will see you in the next one.
原文来源:dev.to