The Problem
Building AI agents today is broken
Existing frameworks force you to re-describe your functions, handle auth yourself, and learn an entirely new paradigm. Your backend code can't just work.
Schema duplication
With Vercel AI SDK or LangChain, you redefine your function's schema as a "tool" — a separate z.object() definition, disconnected from your actual function. Two sources of truth that inevitably drift apart.
Auth is an afterthought
Agent frameworks don't handle auth. Your agent can call tools, but who is the user? What can they access? You end up bolting on authorization checks per-tool, with no shared context.
New framework, new paradigm
Want agents? Learn a whole new SDK — LangChain's chains/agents/tools, Vercel AI SDK's tool() API. Your existing backend functions can't be reused. You're starting over.
How It Compares
Pikku vs the alternatives
Vercel AI SDK, Mastra, and LangChain are excellent tools. Pikku's edge is simple: your functions are already tools — no translation layer needed.
Pikku | Vercel AI SDK | Mastra | LangChain | |
|---|---|---|---|---|
| Tool definition | Your existing functions | Redefine with z.object() | createTool() with z.object() | Wrap in DynamicTool |
| Auth & permissions | Inherited from function | Manual per-tool | Manual per-tool | Manual per-tool |
| Streaming | Built-in via channels | Built-in | Built-in (Vercel AI) | Callback-based |
| Multi-agent | Built-in delegation | Manual | Built-in agent network | AgentExecutor chains |
| Memory | Thread-based, configurable | Manual | Built-in thread memory | BufferMemory / etc |
| Workflows | Built-in durable workflows | Separate concern | Built-in step graphs | LangGraph |
Use Cases
What you can build
Every function you've already written is an agent tool waiting to happen.
Customer support agent
Resolve tickets, look up orders, and escalate — all using functions you already have.
Data analyst agent
Query data, generate charts, and export reports on demand.
Admin / ops agent
Monitor services, scale infrastructure, and deploy — with tool approval for safety.
Content agent
Draft, review, and publish content through your existing content pipeline.
The Basics
Define an agent
Give it a name, instructions, a model, and your Pikku functions as tools. The agent calls them automatically.
const todoAssistant = pikkuAIAgent({
name: 'todo-assistant',
description: 'A helpful assistant that manages todos',
instructions: 'You help users manage their todo lists.',
model: 'openai/gpt-4o-mini',
tools: [listTodos, createTodo, completeTodo],
memory: {
storage: 'aiStorage',
lastMessages: 20,
},
maxSteps: 5,
temperature: 0.7,
})
Functions as tools
Your existing Pikku functions become agent tools — no adapter code needed
Any LLM provider
model: "openai/gpt-4o", "anthropic/claude-3-5-sonnet" — provider/model format
Conversation memory
Built-in thread-based message storage with configurable context window
Features
Streaming, memory, approval
Everything you need to build production AI agents — built into the framework.
Streaming
Real-time text deltas, tool calls, and results via channel events. Show progress as the agent works.
Memory
Thread-based conversation history, configurable context window, and optional working memory for persistent state.
Tool approval
Require human approval before executing sensitive tools. The agent suspends and waits for your decision.
Multi-agent
Agents can delegate to sub-agents. Each sub-agent gets its own session and tools.
Structured output
Define an output schema and the agent returns validated JSON — not just free-text responses.
AI middleware
Hook into modifyInput, modifyOutput, and modifyOutputStream to transform agent behavior.
Dynamic Workflows
Agents that build workflows
Other frameworks let AI call tools in a loop — burning tokens every time. Pikku agents design actual workflow graphs that run natively after the first pass.
AI designs the workflow
The agent analyses your request and creates a workflow graph using your existing functions as steps. It proposes the workflow and waits for approval.
Runs natively — no AI
Once approved, the workflow executes as a real durable workflow. No LLM in the loop. No token cost. Full retry, sleep, and replay guarantees.
Promote to code
Use graph-to-dsl to pull runtime workflows into your codebase as real TypeScript. Version control, code review, and CI/CD — like any other code.
Why this matters: Every other agent framework re-runs the full AI loop on repeat tasks. Pikku saves the workflow — so the second run costs zero tokens, has zero AI latency, and has zero security surface from LLM decisions.
const ops = pikkuAIAgent({
name: 'ops-agent',
tools: [getMetrics, scaleService, restartPod, notify],
model: 'anthropic/claude-sonnet',
// Agent can create and run workflows
dynamicWorkflows: 'write',
})
// Agent designs a workflow graph from your request,
// asks for approval, then runs it natively — no AI in the loop.
// Next time? It reuses the saved workflow. Zero tokens.
Saved workflows
Less tokens on repeat tasks
Native execution
No AI in the loop
graph-to-dsl
Pull into your codebase
Invocation
Run or stream
Two execution modes: get the full result at once, or stream events in real time as the agent thinks and acts.
// Non-streaming: get the full result
const result = await rpc.agent.run('todo-assistant', {
message: 'Create a task for tomorrow',
threadId: 'thread-123',
resourceId: 'user-456'
})
console.log(result.result) // Agent response
console.log(result.usage) // Token usage
// Streaming: real-time events
await rpc.agent.stream('todo-assistant', {
message: 'Create a task',
threadId: 'thread-123',
resourceId: 'user-456'
})
// Channel receives events:
// { type: 'text-delta', text: '...' }
// { type: 'tool-call', toolName: 'createTodo', args: {...} }
// { type: 'tool-result', result: {...} }
// { type: 'usage', tokens: { input: 150, output: 42 } }
// { type: 'done' }
Start building AI agents in 5 minutes
One command to scaffold a project with AI agent wiring already configured.
MIT Licensed · Works with OpenAI, Anthropic & more