How the Site Skills Learning System in Ego-Lite Accumulates Knowledge Across Tasks

Ego-Lite's site skills learning system accumulates knowledge by persisting reusable skill packs to disk and merging all matching domain entries into a unified context object whenever an agent queries the site façade.

The site skills learning system in the citrolabs/ego-lite repository provides a cumulative, disk-backed layer that allows AI agents to retain and reuse domain-specific knowledge across multiple tasks. Unlike ephemeral session data, these learned skills persist as structured packs under the skills/ego-browser/learnings directory, enabling automatic knowledge aggregation every time an agent interacts with a website.

What Are Site Skills in Ego-Lite?

Site skills are reusable knowledge packs that encapsulate expertise for specific web domains. Each pack resides in its own subdirectory (e.g., skills/ego-browser/learnings/x-com/) and is defined by a manifest.json file that declares four key components:

  • Domains – Host patterns (e.g., ["x.com", "*.x.com"]) that determine which URLs trigger the skill
  • Notes – Markdown files containing human-readable knowledge and instructions
  • Node tools – Server-side functions callable from agent scripts
  • Browser tools – JavaScript snippets that execute within the page context

This structure allows the site skills learning system to treat knowledge as modular, composable units that can be developed independently and combined at runtime.

How Knowledge Accumulation Works

The accumulation process follows a three-stage pipeline implemented in the ego-browser package. When an agent calls any site.* helper, the runtime aggregates all applicable skill packs into a single coherent context.

Step 1: Domain Matching with siteSkillsForUrl

The system first identifies which skill packs apply to the current URL using the siteSkillsForUrl(url) function defined in src/helpers.ts at line 64. This helper walks the learnings directory and returns every entry whose domains array matches the supplied URL pattern.

Because the matching logic supports overlapping patterns, multiple skill packs can contribute to the same domain simultaneously. For example, both a generic google pack and a specialized google-ads pack can match https://ads.google.com, allowing their knowledge to accumulate.

Step 2: Context Loading with learnContext

Once matching entries are identified, the learnContext(url?) function (defined at line 513 of src/helpers.ts) delegates to loadLearnedContext in src/learning/index.ts at line 46. This loader performs the actual accumulation:

  • Reads every note file listed in entry.notes, storing the raw markdown content as knowledgeNotes
  • Collects tool signatures from both nodeTools and browserTools arrays, building a unified list of LearnedToolSignature objects (toolSignatures)

Step 3: Merged Knowledge Object

The learnContext function returns a single accumulated object containing all aggregated data:

{
  exists: true,
  siteId: "<primary-site-id>",
  siteName: "<human-readable-name>",
  domain: "<hostname>",
  knowledge: [ …notes from all matching packs… ],
  tools: [ …tool signatures from all matching packs… ]
}

Because the helper aggregates all matching entries, knowledge and tools accumulate automatically as more skill packs are added to the repository or created at runtime.

Cross-Task Persistence Mechanism

The site skills learning system maintains knowledge across different tasks by storing learned data on disk within the agent workspace (state.agentWorkspace()). Each task space can invoke the same site.learnContext() helper, which re-loads the current set of notes and tool definitions from the persistent skill directory.

This disk-backed approach ensures that:

  • Knowledge survives individual task sessions
  • Multiple agents or task runs share the same accumulated expertise
  • Updates to skill packs (adding new notes or tools) are immediately available to subsequent tasks without requiring system restarts

Working with Accumulated Knowledge in Agent Scripts

Agent scripts interact with the accumulated knowledge through the site façade. Here are practical examples demonstrating how to query and utilize the learned context:

Get the full learned context for the current page:

const ctx = await site.learnContext();   // uses current page URL
console.log('Notes:', ctx.knowledge.map(k => k.fileName));
console.log('Tools:', ctx.tools.map(t => t.toolName));

List available site-skill tools for a specific URL:

const tools = await site.skills('https://x.com/home');
console.log('Available tools:', tools);

Run a Node-side site tool defined in the X-Com skill pack:

const timeline = await site.runTool('x-com', 'get_timeline_posts', { maxPosts: 20 });
console.log('Timeline posts:', timeline);

Execute a browser-side tool that extracts data from the active element:

const post = await site.runBrowserTool('x-com', 'post_from_active_element');
console.log('Active post data:', post);

Summary

  • Site skills are reusable packs stored under skills/ego-browser/learnings/, defined by manifest.json files containing domains, notes, and tools.
  • Knowledge accumulation occurs through siteSkillsForUrl() matching followed by loadLearnedContext() aggregation in src/learning/index.ts.
  • Cross-task persistence is achieved by storing skill packs on disk within state.agentWorkspace(), making accumulated knowledge available to all subsequent agent tasks.
  • Multiple packs can target the same domain, allowing specialized skills to layer atop generic ones.
  • Runtime access is provided via the site.learnContext(), site.runTool(), and site.runBrowserTool() helpers defined in src/helpers.ts.

Frequently Asked Questions

How does Ego-Lite match URLs to site skills?

Ego-Lite uses the siteSkillsForUrl(url) function in src/helpers.ts (line 64) to compare the supplied URL against the domains array in each skill pack's manifest.json. The function supports wildcard patterns and returns all matching entries, enabling multiple skills to apply to a single domain.

Where is accumulated knowledge stored between tasks?

Accumulated knowledge persists on disk under the path returned by state.agentWorkspace(), specifically within the skills/ego-browser/learnings/ directory. Because the storage is filesystem-based rather than memory-based, learned skills survive task completion and remain available for future agent sessions.

Can multiple skill packs apply to the same domain?

Yes. The accumulation system is designed to merge all matching skill packs. For instance, both a generic google pack and a specialized google-ads pack can match https://ads.google.com. The loadLearnedContext function combines their notes and tools into a single context object, allowing specialized knowledge to extend general capabilities.

What is the difference between node tools and browser tools?

Node tools are server-side functions defined in the skill pack's manifest.json that execute in the Node.js runtime environment, suitable for API calls or data processing. Browser tools are JavaScript code snippets that run inside the target page's browser context, enabling direct DOM manipulation and extraction. Agent scripts invoke node tools via site.runTool() and browser tools via site.runBrowserTool().

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →