Understanding the Architecture of AI Agents Through the Lens of the "Shell"

    This article explores the fundamental architecture of AI agents by introducing the "Shell + Core" framework. It explains how large language models serve as the core while the surrounding shell acts as the unified interaction and runtime layer. Readers will learn about common shell forms, including web, mobile, IDE, CLI, IM, and sandboxed environments, and how the runtime environment determines an agent's ability to perceive context and execute tasks. The article also offers guidance for developers on selecting and building shells.

    1. The Core Idea: LLMs + the Shell

    No matter which AI assistant we use, the end goal is highly consistent: to complete a specific task. This could be translating a long document, developing a module, creating an animation, or simply seeking emotional companionship. Beneath the surface of the interaction, what is established between the user and the AI tool is a very simple delegation relationship—the user makes a request, and the tool returns a result.

    The core supporting this relationship is the comprehension and generation capabilities of the Large Language Model (LLM). However, what makes users perceive “a complete product” is not the model itself, but the “Shell” wrapping around the model, responsible for carrying interactions and execution. Therefore, most AI tools can be abstracted into a general formula:

    1. AI Tool ≈ Shell + LLM (Core)

    The model is the core, responsible for “thinking,” while the shell is the outer layer, responsible for “reaching” and “execution.” The same core, wrapped in different shells, will present completely different product forms and capability boundaries. Understanding the “Shell” is the key to understanding the differentiation of AI tools.

    2. What is the “Shell”: A Union of Interaction and Runtime Layers

    The “Shell” is not just a simple interface skin; it carries responsibilities at two levels:

    • Interaction Layer: How users input requirements and how the system presents results (web pages, pop-ups, dialogue bubbles, code completion, chat messages, etc.).
    • Runtime Layer: Where the program runs and what external information it can autonomously access in that environment.

    Together, these determine what the tool “looks like” and what it “can do.” A shell with only an interaction layer and no runtime capability can only passively answer questions; a shell with an open runtime environment can actively perceive context, call tools, and execute operations. This also explains why products with similar forms can have vastly different actual capabilities.

    3. An Overview of Common Shell Forms

    Different product positioning gives rise to distinct shell forms. The following are typical patterns in the industry:

    1. Web Page Shell

    Uses the browser as the runtime carrier, with the interaction interface being a web page. The advantages are cross-platform support, zero installation, and easy iteration; the limitation is that it is constrained by the browser sandbox, making it difficult to directly access the local file system or call local programs, with context mainly relying on active user input or uploads.

    2. Mobile App Shell

    Runs inside a mobile app and can access system capabilities such as the camera, photo library, location, and notifications via system permissions. The interaction is closer to personal scenarios, suitable for fragmented, on-the-go tasks, but is limited by mobile computing power and background scheduling policies.

    3. Integrated Development Environment (IDE) Shell

    Embedded as a plugin in a code editor, it can perceive real-time context such as currently open files, cursor position, and project structure. The unique advantage of this shell is “passive context acquisition”—users do not need to deliberately describe the task, as the tool can understand the code being written.

    4. Terminal Command-Line Shell

    Runs in a command-line interface, directly inheriting the terminal’s working directory, environment variables, and file access permissions. Its natural proximity to the file system, scripts, and compilation toolchains makes it highly efficient in automation tasks and batch processing scenarios.

    5. Instant Messaging (IM) Agent Shell

    Takes the form of a chatbot connected to instant messaging tools (such as common enterprise collaboration and communication applications). It embeds AI capabilities into the communication flows users are already familiar with, offering the lowest interaction barrier and the ability to combine message context and group information to provide assistance closer to collaboration scenarios.

    6. Web Shell with a Sandbox

    Adds an isolated execution sandbox on top of the web shell, allowing code or commands generated by the model to actually run in a controlled environment and return results. It compensates for the shortcoming of pure web shells that “can only generate, not execute,” making the “generate-execute-correct” loop possible.

    4. How the Runtime Environment Determines Capability Boundaries

    Among all differences, the runtime environment is the most decisive dimension. It directly answers a core question: can the tool autonomously acquire context from external sources?

    The openness of the runtime environment can be roughly divided into three levels:

    • Closed Level: Can only access input explicitly provided by the user (e.g., pure web Q&A). The tool is “passively receiving.”
    • Semi-Open Level: Can access external data to a limited extent via uploads, plugins, or authorizations. The tool is “controlled acquisition.”
    • Open Level: Runs on a file system, terminal, or real operating system and can actively read, search, and execute. The tool is “actively perceiving.”

    An intuitive criterion is: when the user has not provided all the information clearly, can the tool “take a look” at the environment to fill in the gaps? Those that can fill in the gaps have a higher capability ceiling; those that cannot rely more on the quality of the user’s prompts.

    5. Interaction Paradigms Vary with the Shell

    The form of the shell also reshapes the way humans interact with machines:

    • The web shell mainly uses a “question-and-answer” format, which is clear but has a slower pace;
    • The command-line shell emphasizes “command-based” efficiency, suitable for advanced users;
    • The IDE shell tends toward “assistance while editing,” seamlessly integrating interaction into the workflow;
    • The IM shell uses “chat” as a unified entry point, hiding complex operations behind the conversation.

    There is no absolute superiority in interaction methods; the key is whether they match the target scenario and user habits.

    6. Illustration: A Collaboration Model of Shell and Core

    The following pseudocode abstracts the collaboration process of “Shell + Core + Tools” to help understand how a request flows within the shell:

    1. class AgentShell:
    2. def __init__(self, model, toolset, runtime_env):
    3. self.model = model # Core: comprehension and generation
    4. self.toolset = toolset # Callable external capabilities
    5. self.runtime_env = runtime_env # Runtime env: determines the scope of context acquisition
    6. def handle(self, user_input):
    7. # 1. The runtime environment actively collects context (capability boundary is defined here)
    8. context = self.runtime_env.collect_context()
    9. # 2. Assemble prompt: user requirement + environment context
    10. prompt = self.build_prompt(user_input, context)
    11. # 3. Core reasoning, triggering tool calls if necessary
    12. response = self.model.generate(prompt, tools=self.toolset)
    13. # 4. The interaction layer decides how to present the result
    14. return self.runtime_env.render(response)

    The same model logic, when paired with different runtime_env (web, terminal, IM), yields products with different capabilities. This is the engineering manifestation of “the shell determines the form, and the environment determines the capability.”

    7. A Designer’s Perspective: How to Choose and Build Shells

    For developers and enterprise users, understanding the shell means making more reasonable design and selection decisions:

    • Clarify the context needs of the task: If you need to read local files or execute commands, prefer an open runtime environment; if you only need lightweight Q&A, a closed shell is sufficient.
    • Balance security and capability: An open runtime environment brings context advantages but also permission and data risks. These usually need to be constrained through means such as isolated sandboxes, least privilege, and audit logs.
    • Reuse a unified model core: Accumulate capabilities in the core and use different shells to adapt to different entry points, avoiding redundant development.
    • Leverage general cloud infrastructure: General capabilities such as logging services, monitoring alerts, message queues, object storage, and container platforms can provide a foundation for the high availability, scalability, and observability of the shell layer.

    8. Conclusion

    Returning to the initial question: what exactly is an AI tool? It is not a mysterious “black box,” but a combination of a “large language model core” and a “diverse shell.” The shell determines what form it uses to reach users, while the runtime environment determines how much context it can autonomously acquire and how far it can go. Understanding the relationship between the shell and the core allows both users choosing tools and developers building products to move beyond a list of features and grasp the fundamental logic of agent architecture.