AI Tool Shell Design: Runtime Environments and Interaction Patterns
Large language models can only process the content passed to them; the AI tools users interact with are applications wrapped around the model. This article explains how the shell determines what the model can see, what actions it can execute, and how users interact with it. It covers the shell’s four core responsibilities, common runtime forms, how runtime environments shape context capabilities, context assembly code, interaction trade-offs, and questions to consider during selection.
A large language model itself can only process the content handed to it. It cannot proactively inspect local files, read logs, call business interfaces, or perceive the current time. The AI tools users interact with are actually a layer of application wrapped around the model. This layer is commonly called the “shell.” The shell determines three things: what information the model can see, what actions the model can execute, and how users interact with the model.
Once the problem is split into two layers, selection and design become much clearer. The model layer focuses on reasoning capability, context length, output quality, and cost. The shell layer focuses on runtime environment, permission boundaries, context assembly, tool invocation, and interaction form. The interface between the two layers is usually a set of structured requests, including system instructions, history messages, an available tool list, and user input.
Four Core Responsibilities of the Shell
- Input assembly: combine the user’s original request and background materials into prompt content the model can understand.
- Context acquisition: determine whether the model can read files, query databases, access web pages, or obtain current state.
- Action execution: convert the model’s output invocation intent into real operations, such as running commands, issuing requests, or writing documents.
- Result presentation: organize model output into an interface, message, or file so users can review it and continue working.
Among these four responsibilities, context acquisition and action execution are the areas where different shells differ most.
Common Shell Forms and Runtime Environments
The following forms are classified by runtime environment. They describe structural characteristics only and do not refer to any specific product.
- Web chat: runs in a browser. Context mainly comes from text pasted by the user and uploaded files. It usually cannot directly access the user’s local system.
- Mobile app: runs on a phone. It can use device capabilities such as voice and images, but long-running tasks and large-scale material processing are limited.
- Editor plugin: embedded in an integrated development environment. It can read the current project’s source code, cursor position, and diagnostic information. It is suitable for code generation and refactoring.
- Terminal command line: runs in a local terminal. It can directly read and write the working directory and execute build and test commands. Its permissions are closest to those of the developer, so it requires the most careful control.
- Cloud sandbox: executes tasks in a remote isolated environment. It can install dependencies, run scripts, and browse web pages. Results are returned through an interface. It is suitable for multi-step automation tasks.
- Messaging integration: connects an agent to instant messaging or collaboration platforms. Users issue commands in a familiar chat window, and the agent accesses business systems through interfaces and replies with progress.
| Form | Runtime environment | Primary context sources | Typical interaction | Main risks |
|---|---|---|---|---|
| Web chat | Browser | User-pasted content | Multi-turn text Q&A | Information leakage; reliance on manual copying |
| Mobile app | Phone | Device sensors and user input | Voice, images, short messages | Limited device resources |
| Editor plugin | Development tools | Project files, diagnostic information | Inline completion, conversational edits | Accidental code changes |
| Terminal command line | Local terminal | Working directory, command output | Task instructions and confirmation | Accidental file deletion; unauthorized execution |
| Cloud sandbox | Isolated container | Uploaded files, web content | Task submission and result return | Limited access to resources outside the sandbox |
| Messaging integration | Server side | Chat history, business interfaces | Chat commands | Account and permission management |
How Runtime Environments Determine Context Capabilities
Whether the model can “know” something depends on whether the relevant information is provided to it. The runtime environment determines what information the shell can autonomously obtain. Context can be roughly divided into three types:
- Session context: the current conversation and history messages. Almost all forms have this.
- Workspace context: files, code, documents, configurations, and other materials. This requires the shell to have file access capabilities.
- External system context: database records, ticket status, monitoring metrics, and similar information. This requires the shell to be configured with interfaces and credentials.
The following illustrative code shows how a shell assembles context. The code only demonstrates the idea; the functions and objects in it are hypothetical placeholder implementations.
from dataclasses import dataclass, field@dataclassclass ContextBundle:system_prompt: strhistory: list[dict]sources: list[str] = field(default_factory=list)text_blocks: list[str] = field(default_factory=list)def build_context(user_input, session, workspace, external):bundle = ContextBundle(system_prompt="You are a rigorous technical assistant. Answer only based on the provided materials.",history=session.recent_messages(limit=20),)# Workspace materials: restrict to allowed directories and truncate by sizefor path in workspace.relevant_files(user_input, max_files=5):content = workspace.read_text(path, max_bytes=20_000)bundle.text_blocks.append(f"[File {path}]\n{content}")bundle.sources.append(path)# External system materials: query on demand; results also need truncation and maskingfor record in external.lookup(user_input, limit=3):bundle.text_blocks.append(f"[Record]\n{record.masked_text()}")bundle.sources.append(record.ref)return bundle
Three points in this logic require attention. First, materials must be restricted to the allowed scope; otherwise, the shell may send irrelevant sensitive files to the model. Second, individual materials must be truncated to avoid exceeding the context length limit. Third, external records must be masked before entering the model. Phone numbers, government ID numbers, access tokens, and similar fields should not appear verbatim in the prompt.
Trade-offs in Interaction Methods
Interaction methods affect users’ sense of control and task completion efficiency. There are three common trade-offs:
- Immediate Q&A versus asynchronous tasks: Q&A is suitable for short, quick questions. Asynchronous tasks are suitable for work that takes longer and requires multiple steps. Asynchronous tasks need progress queries and a cancellation entry; otherwise, users cannot judge task status.
- Step-by-step confirmation versus fully automatic execution: step-by-step confirmation reduces the risk of misoperation but interrupts the work rhythm. Fully automatic execution is efficient and suitable for reversible, low-risk operations. A common practice is to classify by risk: low-risk operations execute automatically, while high-risk operations wait for confirmation.
- General interface versus embedded interface: a general interface is suitable for cross-scenario use. An embedded interface can use information from the current work environment and reduce user switching costs.
Selection from the Shell Perspective
Before selection, you can answer the following questions:
- What materials does the task need to read? Are these materials in fixed locations?
- Does the task need to execute actions? Are the actions reversible?
- Who reviews the results? Where is the most natural place to put the review entry?
- Does the data contain sensitive information? Can masking be completed before it enters the model?
- Are the users individuals or teams? Team scenarios require account isolation and review controls.
