What Is an Agent Scaffold?
An agent scaffold is the infrastructure layer that runs an AI agent. It is the code — or framework — that handles all the "plumbing" that turns a raw LLM into a functioning agent: managing the agent loop, routing tool calls, injecting memory into context, handling errors, and tracking state.
Building an agent without a scaffold means writing this plumbing from scratch. Using a scaffold means focusing on your agent's logic — what tools it has and how it should behave — while the scaffold handles execution.
What a Scaffold Does
A complete agent scaffold handles:
- Loop management — Executing the perceive–think–act cycle and tracking iteration count.
- LLM integration — Formatting prompts, calling the model API, and parsing responses.
- Tool registration and routing — Maintaining a list of available tools and dispatching the tool calls the model requests.
- Memory management — Injecting relevant history or retrieved context into each prompt.
- Error handling — Catching failed tool calls, malformed model outputs, and timeouts.
- Stopping logic — Detecting when the agent has reached its goal or hit a limit.
- Observability — Logging steps, inputs, outputs, and timing for debugging.
Popular Agent Scaffolds
LangChain / LangGraph
The most widely used agent framework. LangChain provides abstractions for chains, agents, and tools. LangGraph extends this with explicit graph-based state machines for complex, cyclical agent workflows.
LlamaIndex
Strong at RAG-centric agent workflows. Excellent tool integrations and query engine abstractions for knowledge-intensive agents.
CrewAI
Focused on multi-agent systems with a role-based model. Agents are defined by role, goal, and backstory; a crew of agents collaborates under an orchestrator.
AutoGen
Microsoft's framework for conversational multi-agent systems where agents communicate by passing messages to each other.
Custom / Minimal Scaffolds
For production systems, many teams write lean custom scaffolds tailored to their specific needs, avoiding the abstraction overhead of general-purpose frameworks.
Build vs. Buy
The decision to use an existing scaffold or build your own depends on:
| Factor | Use Existing Framework | Build Custom |
|---|---|---|
| Time to prototype | Fast | Slow |
| Production flexibility | Limited by abstractions | Full control |
| Debugging visibility | Varies by framework | Total visibility |
| Maintenance burden | Framework team | Your team |
Many teams prototype with LangChain or CrewAI, then migrate to a custom scaffold as requirements become specific.
Integrating KnowledgeSDK into a Scaffold
KnowledgeSDK's API can be registered as tools in any agent scaffold. For example, in a LangChain agent:
const extractTool = new DynamicTool({
name: "extract_url",
description: "Extracts structured knowledge from a URL using KnowledgeSDK.",
func: async (url: string) => {
const result = await knowledgesdk.extract({ url });
return JSON.stringify(result);
},
});
Once registered, the scaffold automatically makes the tool available to the agent and handles routing when the model requests it. The same pattern applies to /v1/scrape, /v1/search, /v1/sitemap, and other KnowledgeSDK endpoints.
Alternatively, use @knowledgesdk/mcp to expose all KnowledgeSDK tools as an MCP server, compatible with any MCP-aware scaffold without writing individual tool definitions.