AI Browser Agent Extension: A Technical Guide to Adding Memory, Tools, and Scheduling to LLMs
This article explains how to build a browser-side AI agent extension that gives large language models memory, tool-calling ability, and scheduled execution. It covers a four-layer architecture, layered memory storage, the tool invocation flow, local component permission boundaries, cron-style tasks, local data ownership, and a minimal setup path with common pitfalls.
1. The Problem: The Ceiling of a Chat Box
For most people, using a large language model means opening a web page, typing a question, and copying the answer. This interaction has three built-in limitations. First, there is no cross-session memory, so users have to repeat their preferences and context every time. Second, the model cannot take action directly; it can only give suggestions rather than search, organize, or generate files for you. Third, it cannot run on its own, since every action must be triggered by a person.
A common approach in the industry is to add an extension layer in the browser: use the web interface as the host, the model as the reasoning core, and then fill in three capabilities—memory, tools, and scheduling. The essence is not to change the model, but to change the runtime environment the model lives in.
2. Overall Architecture: Four Layers of Responsibility
A workable solution is usually split into four layers with clear responsibilities and no overlap.
- Interaction layer: a sidebar or overlay injected into the page, responsible for collecting user instructions and rendering the process and results.
- Orchestration layer: maintains session state, assembles context, and decides when to call the model and when to call a tool.
- Capability layer: atomic capabilities such as reading and writing memory, fetching web pages, retrieval, file processing, and system commands.
- Execution layer: a small always-running local component that handles operations requiring an escape from the browser sandbox.
The key design principle is that the capability layer does only one thing, the orchestration layer only makes decisions, and the execution layer only performs controlled execution. This way, replacing any single layer does not affect the whole system.
3. Memory: From “Chat History” to Layered Storage
Truly effortless memory does not mean stuffing the entire conversation history back into the context. It means storing in layers.
- Facts layer: stable information the user has explicitly stated, such as a preferred output format or language habits.
- Preferences layer: tendencies inferred from past interactions, which need a confidence score and an update timestamp.
- Task layer: temporary context strongly related to the current task, which can be reclaimed once the task ends.
A sample memory structure can be written as:
{"facts": [{"k": "output_format", "v": "markdown", "ts": 1710000000}],"prefs": [{"k": "concise", "score": 0.82, "updated": 1710000000}],"session": {"task_id": "t-20240601", "ttl": 3600}}
Three engineering points matter: writes need deduplication and conflict resolution, reads need truncation by relevance, and every entry must be viewable, editable, and deletable. Memory is an asset, and the user must retain final control.
4. Tool Calling: Turning “Being Able to Talk” into “Being Able to Do”
The general pattern for tool calling is “declare—select—execute—feed back”: first declare a tool’s name, purpose, and parameter schema in a structured description; the model then produces a call intent; the runtime validates the arguments and executes; finally the result is fed back into the context to continue reasoning.
{"tool": "fetch_page", "args": {"url": "https://example.com", "max_chars": 8000}}
A common toolset usually includes web search, web page main-content extraction, reading the content of a specified tab, reading and writing local documents, executing controlled commands, and image content analysis. Each type of tool needs a timeout, a size limit, and a failure retry policy so that a single call cannot drag down the entire session.
5. Local Component and Permission Boundaries
The browser sandbox cannot read local files or execute system commands, so a small local component is needed as a bridge. Security should follow least privilege: expose only the capabilities that are genuinely needed, use a whitelist rather than a blacklist for command execution, require a second confirmation for sensitive operations, and keep auditable logs of all calls. Any action involving deletion, overwriting, or sending data externally is off by default and must be explicitly enabled by the user.
6. Scheduled Tasks: Letting the Assistant Clock In on Its Own
Scheduling is usually driven by a standard cron expression, for example triggering an organizing task once at a fixed time every day. The engineering focus is not on “whether scheduling is possible” but on isolation and observability:
- Each task has its own session and its own memory namespace to avoid context bleeding between tasks.
- Failures need retries and alerts, and outputs must be persisted to disk as a record.
- Tasks can be paused, exported, and deleted all at once.
0 8 * * * -> Summarize yesterday's information from specified sources and output a markdown summary
7. What Keeping Data Local Means
Putting keys, memory, and outputs in the user’s own browser and on their own disk brings one major benefit: a shorter chain. No intermediate server collects the data, and troubleshooting is faster. If stronger consistency is needed, you can add local encrypted storage, archive files into per-task directories, and export backups periodically. For team scenarios, exported artifacts can be placed in object storage and combined with logging services and monitoring alerts to form a traceable closed loop; model capabilities can be integrated on demand through the relevant general capabilities of Baidu AI Cloud.
8. Getting Started and Common Pitfalls
The minimal viable path has only three steps: install the extension, open the target page, and enable memory and export. Install the local component only when you need local commands and document processing. Common pitfalls include context growing too long and driving up cost, tool responses that are too large and crowd out the window, incorrect timezone settings for scheduled tasks, and permissions granted too broadly. The corresponding fixes are layered truncation, summarizing results, explicitly specifying the timezone, and defaulting to least privilege.
9. Conclusion
Adding memory, tools, and scheduling to a large language model is essentially turning a one-off question-and-answer interaction into an engineering system that runs continuously. Understanding the four-layer division of responsibility and the permission model is more valuable than memorizing any specific button—because the environment will change, but the architecture will not.
