SDK Reference
Local Engine

Local Engine

LocalEngine is a thin wrapper around AgentLoop that runs an AgentConfig locally. It does not call any LLM provider on your behalf — the caller is responsible for supplying a ModelClient on AgentConfig.model. Papayya does not ship provider adapters.

import { LocalEngine } from "papayya";

How it works

The engine runs the step loop defined by AgentLoop:

  1. Ask the caller-supplied ModelClient.chat(messages, tools, system) for the next response
  2. If the model returns a tool call → execute the tool, record the step, append the result
  3. If the model returns a text response → record the final step, return the result
  4. After each step, check budget and step limits
  5. Repeat until the agent produces a final response, exceeds limits, or is cancelled

Methods

engine.execute(config, options)

Run a full agent execution loop.

import { LocalEngine } from "papayya";
import type { AgentConfig } from "papayya";
 
const engine = new LocalEngine();
const result = await engine.execute(
  agentConfig, // must include a ModelClient on `.model`
  { input: "Research AI trends", mode: "local" },
);

Parameters:

FieldTypeDescription
configAgentConfigThe agent configuration, including a ModelClient on config.model
optionsRunOptionsInput text and execution mode

Returns: Promise<TaskResult>

When to use LocalEngine directly

Most users should use the Agent class or @agent decorator. Use LocalEngine directly if you need to:

  • Bypass the Agent class and work with a raw AgentConfig
  • Build tooling around agent execution
  • Reuse the step loop in a custom harness