Local Agent

Example: Embed a Local Agent in a Node Service

A typical embedding pattern for using a local Agent inside a Node service, and when Federation AIService belongs in the picture

Example: Embed a Local Agent in a Node Service

One very common pattern looks like this:

  1. Your Node service process creates an Agent.
  2. The service creates or loads a session at startup.
  3. An HTTP handler receives a request and turns it into session.prompt().

Minimal embedding mode

import { Agent } from "@downcity/agent";

const agent = new Agent({
  id: "repo-helper",
  path: process.cwd(),
  model,
});

const session = await agent.session_collection().create_session();