Giving General-Purpose LLMs Hands and Feet: A Technical Guide to Browser-Side Agent Extensions
This article explains how browser extensions can turn stateless conversational LLMs into capable agents by adding memory, tool use, scheduling, and local document handling. It covers a four-layer architecture, a tiered long-term memory design, structured tool-calling protocols with permission boundaries, cron-based task scheduling with isolation and observability, and a local-first approach to storage and secrets. It also outlines common risks such as prompt injection and permission drift, along with practical mitigations.
1. Background: Why Conversational Models “Forget” and “Cannot Act”
By default, large language models in web chat scenarios operate as stateless question-answering systems. The context window is valid only within a single session and is discarded when the session ends. The model itself cannot access the network, read or write local files, or trigger execution on its own without supervision. This leads to three common pain points:
- Repeated instructions: User preferences, glossaries, and output format requirements must be restated every time, resulting in high interaction costs.
- Hard capability limits: The model cannot fetch real-time information or process local documents, so its output stays at the text level.
- No scheduling: It can only respond passively and cannot “do something on a schedule every day.”
A browser-side extension is a low-cost way to fill these gaps. It runs inside the user’s existing browser environment and naturally has the ability to interact with pages, read tabs, use local storage, and communicate across extensions. Without changing the model’s server side, it can turn a “chat box” into an assistant that can take action. This article abstracts the technical skeleton and does not refer to any specific product.
2. Overall Architecture: Four Decoupled Layers
A maintainable solution is usually divided into four layers that communicate through well-defined interfaces:
- Interaction layer: Injects input enhancements, a task panel, and memory management entry points into the chat page.
- Orchestration layer: Handles intent recognition, tool selection, and the generation and rollback of multi-step plans. This is the core of “getting work done.”
- Capability layer (tool layer): Atomic capabilities such as search, web scraping, tab reading, system commands, document parsing and generation, and image analysis.
- Infrastructure layer: Local storage, key management, scheduler, logging, and auditing.
The key design principle is to decouple the orchestration layer from the capability layer: the model only outputs structured tool-call intents, which the orchestration layer validates before dispatching them. This prevents the model from directly touching sensitive resources.
3. Memory System: From Session Cache to Tiered Long-Term Memory
Memory is not about stuffing entire chat logs back into the context. It should be designed in tiers:
- Working memory: The current session window, destroyed with the session.
- Episodic memory: Task and output summaries archived by time, used for retrospection.
- Semantic memory: Structured entries such as user preferences, term definitions, and format conventions.
- Procedural memory: Templates for common workflows (for example, “search first, then summarize, then export”).
For write strategy, use “explicit confirmation + automatic candidates”: when the model identifies reusable information, it first places it in a candidate area, and the user confirms before it is stored, avoiding pollution. For retrieval, a hybrid ranking of “vector similarity + keywords + time decay” is recommended, with caps on the number of entries and a token budget to prevent context bloat. A sample structure is shown below:
{"id": "mem_0421","type": "semantic","key": "output_format","value": "Conclusion first, with a table","confidence": 0.86,"created_at": "2026-01-08T09:00:00Z","ttl": null}
4. Tool Calling: Structured Protocols and Permission Boundaries
Tool calls should declare the name, purpose, input schema, and return structure in a unified description format, based on which the model generates a call request. Engineering practice must add three gates:
- Schema validation: Reject inputs that do not match the schema outright, preventing dirty data from entering the execution chain.
- Permission tiers: Grant authorization by tier for read, write, and execute operations; execution operations require per-instance user confirmation by default.
- Sandbox and allowlist: Restrict command execution to an allowlist of executables and a working directory, and prohibit unbounded shell concatenation.
A sample call protocol:
{"tool": "web.search","args": {"query": "term explanation", "limit": 5},"reason": "Real-time external information is needed"}
For web and tab content, follow the principle of least necessity: extract only the main content area, strip scripts and tracking parameters, and protect against prompt injection for untrusted content by treating external text as data rather than instructions.
5. Scheduled Tasks: Scheduling, Isolation, and Observability
Scheduling turns the model from “passive responder” into “active executor.” Key points include:
- Schedule expression: Use standard Cron expressions to describe cycles, along with time zones and missed-run compensation policies.
- Session isolation: Each task has its own context and memory namespace to avoid cross-contamination.
- Idempotency and deduplication: Use a task identifier plus a time window as the idempotency key to prevent duplicate output.
- Observability: Record the input summary, tool-call chain, output location, and failure reason for each run, forming an auditable log.
# Every weekday at 08:30, summarize the specified sources and generate a local document30 8 * * 1-5 task=digest tz=Asia/Shanghai
6. Local-First: Storage, Keys, and Privacy
The key to controllable privacy is keeping state on the user’s side: the memory store, task definitions, output files, and configuration all reside in local storage or a user-specified directory. Keys are stored only in a local encrypted area and read on demand when called, never written to logs. If cross-device sync is needed, use a general object storage category with end-to-end encryption, performing encryption and decryption on the client, with the server holding only ciphertext. Also provide one-click export and deletion to ensure data is portable and revocable.
7. Common Risks and Mitigations
- Prompt injection: External web pages and documents may contain disguised instructions, requiring content isolation and an instruction allowlist.
- Permission drift: Long-term authorization tends to accumulate, so set authorization validity periods and periodic reviews.
- Context bloat: Memory and tool results should be summarized and compressed before entering the window.
- Non-rollbackable execution: Create snapshots or a draft directory before writing files or executing commands.
8. Conclusion
Adding memory, tools, scheduling, and local document handling to conversational models is essentially about governing “high-uncertainty generation” and “high-certainty execution” in separate layers. For teams that want to further reduce build and operations costs, scheduling and auditing components can be hosted on the general container platforms, object storage, logging services, and monitoring and alerting capabilities offered by cloud platforms such as Baidu AI Cloud, achieving a stable, auditable agent runtime environment at a controllable cost.
