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:
- Ask the caller-supplied
ModelClient.chat(messages, tools, system)for the next response - If the model returns a tool call → execute the tool, record the step, append the result
- If the model returns a text response → record the final step, return the result
- After each step, check budget and step limits
- 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:
| Field | Type | Description |
|---|---|---|
config | AgentConfig | The agent configuration, including a ModelClient on config.model |
options | RunOptions | Input 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
Agentclass and work with a rawAgentConfig - Build tooling around agent execution
- Reuse the step loop in a custom harness