Adding Memory and Tool Capabilities to General-Purpose LLMs

    This article explains how to extend a general-purpose LLM beyond a stateless chat box by layering an agent runtime on top of the web interface. It covers four capability areas: persistent memory (fact, preference, and task types, with deduplication, scope isolation, and auditability), tool calling with unified schemas, argument validation, result summarization, and idempotency, scheduled tasks with session isolation, and local-first data and key governance. It also outlines a minimal browser-extension setup path and the security precautions to take when granting page-reading and command-execution permissions.

    1. The Problem: Why Web-Based LLMs Can Only Talk, Not Act

    Most users still interact with a general-purpose LLM through a chat box in the browser. The interaction barrier is low, but the model has three structural limitations.

    The first is that it is stateless. Conversation context is bounded by the window length, and once the page is closed, preferences, glossaries, and project background are all lost, forcing users to restate the same premises over and over.

    The second is that it has no hands. The model can only emit text. It cannot proactively search, read pages, manipulate files, or run calculations, so for any task that requires action it can only describe the steps.

    The third is that it has no sense of time. Every task has to be initiated manually by the user, with no scheduling capability for something like “run automatically every day at eight.”

    Closing these three gaps essentially means adding an agent runtime on top of the chat interface: a layer responsible for state persistence, tool registration and invocation, task scheduling, and permission control. The sections below break this down by capability.

    2. Capability 1: Designing Persistent Memory and Its Boundaries

    Memory is not about storing the entire chat history. It is about structurally retaining the information worth reusing. In practice, it usually falls into three categories:

    • Fact memory: long-lived statements such as user identity, tech stack, and naming conventions;
    • Preference memory: constraints such as output language, code style, and document format;
    • Task memory: intermediate artifacts and conclusions from a specific task, usually with an expiration time.

    A practical approach is a “confirm on write, revocable on read” policy. An illustrative data structure looks like this:

    1. {
    2. "memory_id": "m_20260624_001",
    3. "type": "preference",
    4. "key": "code_style",
    5. "value": "TypeScript + semicolons + two-space indentation",
    6. "scope": "global",
    7. "created_at": "2026-06-24T09:00:00Z",
    8. "ttl_days": null
    9. }

    There are three key design points. The first is deduplication and conflict resolution: when a new value appears for the same key, keep the historical versions and mark the active one, so memories do not contradict each other. The second is scope isolation: global preferences, project-level preferences, and single-task context are stored separately to prevent cross-project contamination. The third is auditability: every memory entry should expose its source and write time and support individual deletion, which is a prerequisite for user trust.

    3. Capability 2: Tool Invocation and the Execution Loop

    Tool invocation moves the model from generating text to producing actions. A reliable tool layer needs four things.

    Unified descriptions. Every tool declares its name, purpose, inputs, and return values in a structured schema, so the model selects tools based on that declaration rather than guesswork.

    Argument validation. Arguments produced by the model cannot be trusted directly; type, range, and allowlist checks must run before execution.

    Feeding results back. Tool output has to be trimmed and summarized before re-entering the context, otherwise a single fetch can blow up the window.

    Idempotency and retryability. Write operations should carry an idempotency key so that a failed call can be retried safely.

    A typical invocation flow can be abstracted as:

    1. def run_step(user_input, ctx):
    2. plan = planner(user_input, ctx.memory)
    3. for call in plan.tool_calls:
    4. if not policy.allow(call.name, call.args): # permission and allowlist
    5. return deny(call)
    6. raw = registry[call.name](**validate(call.args))
    7. ctx.append(summarize(raw)) # feed back after compression
    8. return ctx.final_answer()

    Tools can be grouped into three risk tiers: read-only (search, fetching, reading page content), compute (running scripts, parsing spreadsheets and documents, analyzing image content), and write (modifying files, sending messages, triggering external actions). The higher the tier, the more explicit confirmation and operation logging are required.

    4. Capability 3: Scheduled Tasks and Session Isolation

    Scheduling turns the assistant from a passive responder into a proactive inspector. Rather than relying on a foreground page staying open, the implementation should use a locally resident process that parses the schedule expression and spins up an independent session when the time comes.

    1. # Every weekday at 08:30, aggregate the specified sources and generate a digest
    2. 30 8 * * 1-5 local-agent run --task=digest --session=digest_daily

    The engineering focus is session isolation: each task gets its own context and its own memory namespace, so different tasks do not bleed into each other. Timeouts, retry limits, and failure alerts should also be configured to prevent silent failures. Outputs are written to a local directory with a timestamp attached, making them easy to trace and process further.

    5. Capability 4: Local-First Data and Key Governance

    The most commendable aspect of this kind of setup is that sensitive assets stay on the user’s side: keys, the memory store, and task outputs all live in local browser storage and the local filesystem, without relaying through a third-party backend. Delivering on that promise requires a few constraints:

    • Keys are stored locally and encrypted, read on demand at call time, and never written to logs;
    • Network egress is controllable, with access limited by default to targets the user has explicitly allowed;
    • A local audit log covers the entire chain and can be exported or cleared;
    • Permissions are minimal, with write tools disabled by default and enabled as needed.

    If multi-user collaboration or cross-device sync is required, general cloud capabilities can take that on: object storage for outputs, a message queue to decouple tasks, a container platform to host executors, and logging plus monitoring and alerting services for observability. The sync scope and encryption policy, however, should be decided by the user.

    6. Getting Started and Risk Notes

    The minimal viable path needs only a browser extension: install it, open the LLM web app, and you get memory, export, and retrieval augmentation with zero configuration. Advanced capabilities (local commands, document and spreadsheet processing, image analysis) require one additional local component, with directory and execution permissions granted manually.

    One caveat: an extension that can read pages and execute commands carries a non-trivial risk level. It is advisable to try it first in an isolated environment or a low-privilege account, review memory writes one by one, keep human confirmation on write actions, and periodically clear expired memories and historical outputs.

    7. Conclusion

    Going from “can chat” to “can get work done” is not about model parameters. It is about four pieces of the engineering puzzle: memory, tools, scheduling, and permissions. Once you understand this runtime structure, whether you build your own enhancement setup or assemble storage, queues, and observability on demand on a platform such as Baidu AI Cloud, you can embed LLMs into real workflows with much more confidence.