Planning & TODOs
Built-in planning mode with structured TODO management and strict workflow rules for complex multi-step tasks.
Message-first agent loop with planning, summarization, and multi-agent orchestration
npm install @cognipeer/agent-sdk zodyarn add @cognipeer/agent-sdk zodpnpm add @cognipeer/agent-sdk zodimport { createSmartAgent, createTool, fromLangchainModel } from "@cognipeer/agent-sdk";
import { ChatOpenAI } from "@langchain/openai";
import { z } from "zod";
// Define a simple tool
const echo = createTool({
name: "echo",
description: "Echo back the input text",
schema: z.object({ text: z.string().min(1) }),
func: async ({ text }) => ({ echoed: text }),
});
// Create model adapter
const model = fromLangchainModel(new ChatOpenAI({
model: "gpt-4o-mini",
apiKey: process.env.OPENAI_API_KEY,
}));
// Create smart agent with planning
const agent = createSmartAgent({
name: "Assistant",
model,
tools: [echo],
useTodoList: true,
limits: { maxToolCalls: 5, maxToken: 6000 },
tracing: { enabled: true },
});
// Run the agent
const result = await agent.invoke({
messages: [{
role: "user",
content: "Plan a greeting and send it via the echo tool"
}],
});
console.log(result.content);asTool and runtime handoffsonEvent hooksconst agent = createSmartAgent({
model,
tools,
useTodoList: true, // Enable planning mode
});const agent = createSmartAgent({
model,
tools,
outputSchema: z.object({
summary: z.string(),
items: z.array(z.string()),
}),
});
const result = await agent.invoke({ messages });
console.log(result.output); // Parsed structured outputconst specialist = createSmartAgent({ name: "Specialist", model, tools });
const coordinator = createSmartAgent({
name: "Coordinator",
model,
tools: [specialist.asTool({ toolName: "delegate_to_specialist" })],
});createSmartAgent for batteries-included experience or createAgent for full control