Local Agents.
In-process Intelligence.
Forget chatbots. Ship agentic AI directly inside your desktop and mobile apps — no API keys, no inference servers, and no user data leaving the device unless you want it to. LLoyal HDK gives you the entire agentic envelope (models, tools, retrieval, and multi-agent workflows) in a single import.
import { useAgent } from '@lloyal-labs/lloyal-agents';
import { SupportSource, reportTool } from './kb';
const kb = new SupportSource(db);
const agent = yield* useAgent({
systemPrompt: "Support specialist. Help users resolve technical issues.",
task: "Find the 'Error 500' fix in Version 2.0",
tools: [...kb.tools, reportTool],
terminalTool: 'report',
});
console.log(agent.result);
import { Source } from '@lloyal-labs/lloyal-agents';
import { FetchPageTool, type Reranker } from '@lloyal-labs/rig';
// Sources pair tools with late-bound runtime deps. The reranker
// makes FetchPageTool return only the verbatim top-K chunks —
// saving ~90% of KV context on long documents.
class IntranetSource extends Source<{ reranker: Reranker }> {
name = "intranet";
fetchPage = new FetchPageTool({ topK: 5, tokenBudget: 2048 });
tools = [this.fetchPage];
// Late-bind: wire the reranker once it's available.
*bind(ctx: { reranker: Reranker }) {
this.fetchPage.setReranker(ctx.reranker);
}
}
import { useAgent } from '@lloyal-labs/lloyal-agents';
import { DelegateTool } from '@lloyal-labs/rig';
import { BankSource, TradeTool, reportTool, account } from './finance';
// Recursive expert swarm. Sub-agents fork from the calling agent's branch —
// they inherit its full KV attention state (Continuous Context), so private
// account data flows through tools, not prompts.
const bank = new BankSource();
const advisor = yield* useAgent({
systemPrompt: "Senior portfolio advisor. Decompose into specialist sub-tasks.",
task: "Optimize my portfolio for tax-loss harvesting before year-end.",
tools: [
...bank.tools,
new DelegateTool({
systemPrompt: "Tax-specialized financial strategist.",
poolOpts: {
tools: [...bank.tools, reportTool],
terminalTool: 'report',
echoThreshold: 0.8, // reject sub-tasks that paraphrase the parent
checkAncestorEcho: true, // reject loops up the call chain
},
}),
new TradeTool(account),
reportTool,
],
terminalTool: 'report',
});
import { agentPool, parallel } from '@lloyal-labs/lloyal-agents';
import { FS, Xero, reportTool } from './local-app';
// Process receipts into Xero concurrently
const receipts = yield* FS.scanDir('./inbox/receipts');
const pool = yield* agentPool({
orchestrate: parallel(
receipts.map(file => ({
content: `Extract vendor and amount: ${file.name}`,
systemPrompt: "Accounting clerk. Extract data accurately."
}))
),
tools: [FS.readImage, Xero.logExpense, reportTool],
terminalTool: 'report',
});
import { agentPool, chain } from '@lloyal-labs/lloyal-agents';
import { FS, QuickBooks, reportTool } from './local-app';
// Step 2 inherits step 1's KV context in O(1) time
const pool = yield* agentPool({
systemPrompt: "Bookkeeping assistant.",
orchestrate: chain(['extract', 'log'], (step) => ({
task: { content: step, systemPrompt: "" },
userContent: `Findings from ${step}:`
})),
tools: [FS.readPdf, QuickBooks.api, reportTool],
terminalTool: 'report',
});
import { agentPool, dag } from '@lloyal-labs/lloyal-agents';
import { CMS, Gen, FS, reportTool } from './local-tools';
// copy + imagery fan out from notes, then converge on publish.
const pool = yield* agentPool({
systemPrompt: "Marketing strategist.",
orchestrate: dag([
{ id: "notes", task: { content: "Read campaign brief", systemPrompt: "" }, userContent: "Brief" },
{ id: "copy", task: { content: "Draft channel copy", systemPrompt: "" }, dependsOn: ["notes"], userContent: "Copy" },
{ id: "imagery", task: { content: "Generate hero images", systemPrompt: "" }, dependsOn: ["notes"], userContent: "Images" },
{ id: "publish", task: { content: "Publish across channels", systemPrompt: "" }, dependsOn: ["copy", "imagery"] }
]),
tools: [FS.readDir, CMS.tone, Gen.image, reportTool],
terminalTool: 'report',
});
Zero-Dependency Orchestration
Forget Docker compose and fragile promise chains. Orchestrate massive parallel swarms and multi-parent DAGs using native structured concurrency. Deterministic teardown, zero memory leaks.
Continuous Context
Agents share GPU state, not strings. This frees up compute for more external knowledge consumption and concurrent agent execution — enabling cloud-grade UX on consumer hardware.
Retrieval-Interleaved Generation
RAG but better — agents dynamically search, read, and rerank chunks during the generation loop enabling adapative tool use and multi-hop reasoning. Connect local databases or the live web instantly via the pluggable Source contract.
On-device. Multi-agent. Parallel.
Parallel agents running tools web_search and fetch_page on iPhone — no API calls, no streaming server, no cloud round-trip. The Node SDK is open source and ships anywhere Node runs — server, CLI, or desktop via Electron or Tauri. The native iOS & Android runtime is currently in commercial preview.