
Summary
Key points of this document
- Background and Challenges: Inference Wandering and Dialogue Loops in LLM Autonomous Agents.
- Why do "exception instructions (bypasses)" via prompts fail?
- Architectural Principle: Separation of Concerns from Probabilistic Inference to Deterministic CLI Tools
Background and Challenges: Inference Wandering and Dialogue Loops in LLM Autonomous Agents.
In the field of software engineering, the adoption of autonomous coding agents centered around Large Language Models (LLMs) is rapidly progressing. While these agents can flexibly perform advanced tasks such as code completion, bug root cause analysis, and automatic test code generation via natural language instructions, serious challenges are emerging in "execution processes with side effects," such as deployment to production environments and applying system changes.
A typical example of this occurs during emergency responses or under exceptional operational circumstances,"Inference wandering due to dialogue loops."is.
In situations with extremely tight time constraints, such as disaster recovery, engineers may have already completed integrity verification (type checking, Lint, unit tests, etc.) in their local environment and wish to temporarily skip redundant verification on the CI/CD pipeline for immediate deployment. In such cases, even if a natural language instruction like "This verification has been confirmed locally, so skip it just this once and proceed with deployment" is given to the conversational agent, the agent frequently fails to act as instructed.
Even while responding that it "understood the intent of the instruction," the agent re-verifies the integrity of predefined safety checklists and procedures, interrupts the task, and re-presents the same confirmation prompt. Each time the engineer rephrases the situation, adds context, and attempts logical persuasion, the agent brings up another constraint, falling into a circular dialogue. As a result, incidents occur where over two hours are wasted on "persuading the agent" through natural language, without the task itself progressing a single step.
This phenomenon is not merely due to poor prompt engineering or a lack of model comprehension. It is an inevitable consequence caused by the fundamental structural friction existing between the "probabilistic and flexible input space" of natural language interfaces and the "deterministic and strict execution control" required by system operations.
Why do "exception instructions (bypasses)" via prompts fail?
The reason LLM agents do not accept natural language instructions for exception handling, or appear to accept them but cannot execute them, lies in the internal architecture and alignment structure of modern LLMs.
No matter how fluent and intelligent the responses a model generates appear to be, its essence is "an inference engine that probabilistically predicts and generates the next token based on input context, system prompts, external tool definitions, and pre-trained knowledge." The model itself does not possess subjective capabilities such as "flexibility based on situational judgment" or "assuming responsibility according to context."
The following three-layered structure exists as the main factors determining the behavior of autonomous agents.
- Instruction Hierarchy:
In recent model architecture research (e.g., Wallace et al., 2024), methods for clearly separating and evaluating the priority of "System Instructions" and "User Input" within the model for prompt injection defense and safety control have become established. If immutable rules such as "unverified code must not be reflected in the environment" or "prescribed procedures must not be deviated from" are defined in the system prompt, then no matter how much the user input instructs "this is an exception just for now," system rules will be prioritized in the internal weighting evaluation, and bypass operations will be rejected.
- Tool Execution Permissions and Preconditions:
External tools provided via Function Calling or MCP (Model Context Protocol) are equipped with schema definitions and pre-validation mechanisms. If arguments are missing, or if environment variables or pre-check results are not met, the tool execution layer itself returns an error, and the agent is reverted to prompt generation.
- Non-verifiability of Self-Declared Text:
Even if an engineer states "confirmed locally" or "verified in logs," for an LLM, this is merely unverified plain text. A model that allows crossing safety gates based on such ambiguous text information is extremely vulnerable from a security perspective and inherently carries the risk of easily causing serious incidents.
In other words, the act of asking for "an exception" within a conversational prompt is to throw oneself into a conflict space between implicit rules and probabilistic inference, thereby inviting an engineering-uncontrollable state (uncertainty).
Architectural Principle: Separation of Concerns from Probabilistic Inference to Deterministic CLI Tools
The approach to fundamentally solve this dialogue wandering problem is,"Strict separation of concerns between Probabilistic Inference and Deterministic Programming."is.
In the design paradigm of AI agents (e.g., Anthropic's organization of agents and workflows), a full-agent approach that entrusts all processing to the model's dynamic judgment is noted to significantly compromise system predictability and reproducibility in exchange for flexibility. To build a robust system in practical operation, it is essential to fix areas with known processing procedures as explicitly code-defined "workflows" and utilize LLMs only for areas requiring unknown events or exploratory inference.
"Tooling" here refers to extracting a series of tasks such as routine operational procedures, testing, verification, and deployment,"as a single CLI program that can accept command-line arguments and execute independently."and managing them as code within a repository.
By converting to CLI tools, the following behaviors are guaranteed at the code level:
- Strict Type Definition of Arguments: Target environment (
--env), artifact ID (--artifact), commit hash, etc., are explicitly specified. - Deterministic Determination of Execution Conditions: Even when performing "omission due to local confirmation," it requires the submission of mechanically verifiable evidence files, not natural language excuses.
- Reproducibility and Independence: Even without an LLM, engineers can directly execute the same command from their local terminal and obtain exactly the same safety verification and execution results.
CLI Handle Design and Multi-Layered Safety Boundary Architecture
The most important design philosophy for promoting tooling is,"that human and AI agents utilize a common entry point (handle) and pass through common safety mechanisms."architecture.
If tools are implemented as agent-specific internal APIs or hidden scripts, humans cannot intervene when the agent enters an inference halt. Conversely, providing different tools for humans and AI creates double standards in security criteria and audit logs. Unifying the structure so that both humans and AI pull the same CLI handle leads to ensuring reliability.
Design Specifications for Multi-Layered Safety Boundaries (Defense-in-Depth)
In this common CLI handle, the safety boundaries for allowing human judgment-based "bypasses" must be strictly structured as follows.
| Layer | Verification Target | Behavior Specification | Exception Permission |
|---|---|---|---|
| Layer 1: Argument/Schema Inspection | Option Name, Argument Format | Unknown options or undefined omission requests are immediately rejected | No exceptions (Only items explicitly defined in code) |
| Layer 2: Proof Verification | Source hash, artifact digest, dependency lock, environment identifier | Mechanically match presented verification log evidence with current target artifacts | Conditional (Allows skipping optional verification only upon exact match) |
| Layer 3: Mandatory Safety Gate | Authentication token, protected branch, data corruption prevention, permission check, relevant STG E2E | Directly verify executor's permissions and environmental constraints | Absolutely not (Fail-Closed). Description of reasons or --force bypass is prohibited |
| Layer 4: Execution and Idempotency Management | Operation ID, Idempotency Key | Persist ID before requests with external side effects to prevent duplicate execution | Always enforced |
Fictional CLI implementation example:
release-tool deploy \
--env production \
--artifact build-20261106-prod \
--skip-verify duplicate-lint \
--verification-proof /tmp/proofs/local-verification-receipt.json \
--reason "Emergency incident response: All lint checks confirmed to pass in local environment (hash matched)"Limiting the scope of optional omissions:
Omissions are only permitted for optional verifications explicitly registered in an allowlist in the code, such as "duplicate linting" or "rebuilding from the same source," which can be proven to have been executed locally.
Exclusion of self-declaration and proof verification:
--reasonoption is metadata for audit logs, and does not itself have the power to exempt verification. The CLI calculates the Git commit hash, SHA-256 digest of the generated artifact, and dependency package lock file hash from the JSON receipt specified in--verification-proofand verifies them against the current target artifact. If there is even a single bit of mismatch, the omission is immediately rejected.Fail-Closed Mandatory Gate:
Production environment deployment permissions, protected branch constraints, and data corruption prevention rules cannot be skipped regardless of the arguments passed. If an unauthorized executor launches a command, it will stop with a non-zero exit code before any side effects such as sending to an external network or updating a database occur.
Design Specifications for Robust Operations: POSIX Exit Codes and Idempotency Management
For deterministic tools to be reliable interfaces for both humans and LLM agents, observability of execution results and recovery mechanisms for abnormal termination or communication interruptions are indispensable.
1. Systematization of POSIX Exit Codes
In natural language dialogue, determining "success or failure" requires text analysis, which carries a risk of misinterpretation. CLI tools should systematize clear exit codes compliant with POSIX standards, designed to allow scripts and agents to mechanically branch to the next action.
| Exit Code | Definition Name | Condition | Agent/Human Recommended Action |
|---|---|---|---|
0 | EXIT_SUCCESS | All verification/deployment processes completed successfully | Proceed to next task |
2 | EXIT_INVALID_INPUT | Invalid arguments, unknown omitted item specified | Argument definition (--help) to confirm and reconstruct |
3 | EXIT_PERMISSION_DENIED | Insufficient execution permissions, authentication boundary error | Privilege escalation or delegation to a privilege holder (stop before side effects) |
4 | EXIT_PROOF_MISMATCH | Proof hash mismatch, mandatory gate not met | Reconfirm proof file, or re-execute with normal validation |
5 | EXIT_RESULT_UNKNOWN | External API communication interrupted, timeout | Execute status inquiry using Operation ID (re-execution without careful consideration is prohibited) |
2. State Management with Operation ID and Idempotency Key
The most dangerous thing when applying changes to distributed systems and cloud environments is to "resend the same request when the success or failure of the process is unknown." If an agent repeatedly re-executes based on inference just because a timeout occurred, it can lead to fatal inconsistencies such as double deployments or duplicate data writes.
CLI tools generate a unique "Operation ID" and "Idempotency Key" at startup and record them locally and in external backends.
- If the response is interrupted, the tool or a human can perform a status inquiry by specifying the Operation ID (
release-tool status --operation-id <ID>). - If it is confirmed on the target side that it has "already been executed," only the result is retrieved, and it exits successfully (
0). - Only when it is confirmed as "not executed" and idempotency is guaranteed, a safe retry is performed using the same Operation ID and Idempotency Key.
- If the state is undetermined or unqueryable, it stops with exit code
5and requests human intervention for investigation.
3. --dry-run's Positioning and Limitations
The --dry-run option in CLI tools is a powerful auxiliary function for pre-validating argument parsing, schema validation, dependency resolution, proof file hash calculation, etc., without side effects.
However, from an engineering perspective, it is important to note that "The success of --dry-run does not guarantee successful execution or sufficient permissions in a production environment."Expiration of external authentication tokens, production-specific race conditions, network interruptions, etc., can only be caught at the production execution layer, which actually involves side effects.--dry-run should not be over-relied upon; a design that prioritizes error handling during production execution is required.
Summary: Guidelines for Tool Assetization in Agent-Coordinated Environments
The key to maximizing the capabilities of LLM autonomous agents and achieving safe, high-speed software delivery is not to refine the "art of persuading agents.""The design capability to identify areas where agents do not need to infer, and to extract them as deterministic tools (CLI)"lies.
In daily development and operations, the following signs indicate an opportunity for toolization:
- Repeatedly explaining the same prerequisite knowledge and constraints to the agent.
- Exception requests like 'Please skip this step just for now' are idling in natural language conversations.
- Shell commands output by the agent frequently fail due to environmental differences or incorrect argument specifications.
If these tasks are identified, immediately terminate the conversation and code them as a small CLI program equipped with an input schema, a whitelist for optional ranges, mechanical evidence matching logic, and systematic exit codes.
Leave a 'reliable handle' on the outside that humans can directly operate from the terminal, and let the agent also grasp that same handle. This architecture, where probabilistic flexibility and deterministic safety are harmonized, will be a true engineering asset in the era of AI agents.


