Pickaxe: A Game-Changing Tool for Building Scalable AI Agents
In today’s rapidly evolving AI landscape, developing robust AI agents is no easy feat. It involves not only tackling core algorithms but also grappling with a host of system-level challenges, such as task scheduling, error handling, and resource allocation. Fear not! Today, I am thrilled to introduce a game-changing tool designed to simplify AI agent development—Pickaxe.
Imagine you are tasked with building a complex AI agent system. This system needs to handle various tasks, call different tools, recover effortlessly from failures, and ensure stable performance under high concurrency. Sounds daunting, doesn’t it? Well, Pickaxe is here to alleviate these burdens.
What Is Pickaxe?
Pickaxe is a streamlined TypeScript library crafted to enable the construction of fault-tolerant and scalable AI agents. It acts like a Swiss Army knife, handling intricate execution complexities such as persistent execution, queue management, and task scheduling. This allows you to concentrate on what truly matters—your core business logic.
The ethos of Pickaxe is crystal clear: Everything is a function written by you, making it seamlessly integrable with your existing codebase and business logic. With Pickaxe, you can effortlessly build AI agents that invoke tools, other agents, or any functions you define.
Core Advantages of Pickaxe
-
Persistent Execution: Leveraging a persistent task queue called Hatchet, Pickaxe creates automatic checkpoints for agents. This means that even in the face of failures or prolonged waits for external events, agents can recover seamlessly without resource waste. Much like having a thoughtful assistant who meticulously records every critical step, ensuring work can always resume from where it left off. -
Code-Centric Approach: Agents are defined through code and designed to integrate with your business logic. There’s no need to conform to rigid framework rules; instead, you can craft code that aligns with your specific business needs. -
Distributed Execution: All agents and tools operate across a fleet of machines, with Pickaxe gracefully managing scheduling. Should a machine fail, Pickaxe ensures agents are rescheduled and resumed on another machine, significantly enhancing system reliability. -
Highly Configurable: Pickaxe offers simple yet powerful configuration options for retries, rate limiting, concurrency control, and more, enabling you to tailor settings to your unique requirements. -
Platform Flexibility: Pickaxe agents can run on virtually any container-based platform, including Hatchet, Railway, Fly.io, Porter, Kubernetes, AWS ECS, and GCP Cloud Run.
Getting Started with Pickaxe
Diving into Pickaxe is as simple as running two commands:
pnpm i -g @hatchet-dev/pickaxe-cli
pickaxe create first-agent
After executing these commands, you will be guided through creating a new Pickaxe project based on a template. This will provide a concrete example of Pickaxe in action, helping you quickly grasp its functionality.
To give you a clearer idea of Pickaxe’s capabilities, here’s a concise code example:
import { pickaxe } from "@hatchet-dev/pickaxe";
import z from "zod";
import { myTool1, myTool2 } from "@/tools";
const MyAgentInput = z.object({
message: z.string(),
});
const MyAgentOutput = z.object({
message: z.string(),
});
export const myToolbox = pickaxe.toolbox({
tools: [myTool1, myTool2],
});
export const myAgent = pickaxe.agent({
name: "my-agent",
executionTimeout: "15m",
inputSchema: MyAgentInput,
outputSchema: MyAgentOutput,
description: "Description of what this agent does",
fn: async (input, ctx) => {
const result = await myToolbox.pickAndRun({
prompt: input.message,
});
switch (result.name) {
case "myTool1":
return {
message: `Result: ${result.output}`,
};
case "myTool2":
return {
message: `Another result: ${result.output}`,
};
default:
return myToolbox.assertExhaustive(result);
}
},
});
In this example, we begin by importing the essential Pickaxe modules and necessary tools. Next, we define the input and output structures for the agent. We then create a toolbox containing a set of tools. Finally, we define an agent, specifying its name, execution timeout, input/output structures, description, and a function that invokes tools from the toolbox. Depending on the results returned by the tools, the function processes and returns the corresponding output.
Pickaxe’s Expandability and Philosophical Approach
Pickaxe’s design philosophy is centered on not being a framework. It does not restrict how you design tools, call large language models (LLMs), or implement agent memory. Instead, it empowers you with the freedom to choose or build the optimal solutions for memory, knowledge, reasoning, or integration tailored to your needs. Pickaxe is opinionated about the infrastructure layer of your agents but leaves the implementation details of your agents to your discretion.
This philosophy grants Pickaxe exceptional expandability. You can construct your own agent library on top of Pickaxe to meet specific business requirements.
Application Scenarios and Patterns for Pickaxe
Pickaxe is versatile and well-suited for various scenarios and patterns:
-
Prompt Chaining: Enable sequential prompt calls to form a workflow where the output of one prompt serves as the input for the next, handling complex tasks efficiently. -
Routing: Direct tasks to different tools or agents based on conditions and inputs, achieving flexible task allocation. -
Parallelization: Execute multiple tasks concurrently to boost processing efficiency, particularly for tasks that can be parallelized. -
Evaluator-Optimizer: Evaluate task outcomes and optimize based on the results, iteratively improving task processing effectiveness. -
Multi-Agent Systems: Enable collaboration among multiple agents to jointly tackle complex tasks, akin to a team where each agent focuses on a specific aspect. -
Human-in-the-Loop: Integrate human judgment and decision-making into the task processing workflow, combining human intelligence with AI capabilities to address critical decision points.
Comparing Pickaxe with Existing Tools
Compared to other tools on the market, Pickaxe stands out with unique advantages:
-
Versus Frameworks (e.g., Mastra, Voltagent): Unlike frameworks, Pickaxe does not impose constraints on how you structure LLM calls, business logic, prompts, or context. It allows you to define these elements yourself. You can even build your own agent library on top of Pickaxe. -
Versus Temporal: While Pickaxe shares similarities with Temporal’s execution model, it surpasses Temporal in several areas. For instance, Pickaxe supports global rate limiting, event-based triggering, event streaming, DAG (Directed Acyclic Graph) support, priority queues, and complex routing logic like sticky assignments—features that Temporal lacks.
Best Practices for Developing Agents with Pickaxe
To maximize the effectiveness of developing agents with Pickaxe, consider the following best practices:
-
Stateless Reducers with No Side Effects: Agents should be designed as stateless reducers without side effects. They should not rely on external API calls, database queries, or local disk operations. Instead, their entire state should be determined by the results of their tool calls. This ensures agent stability and predictability. -
Encapsulate All Work Units as Tasks or Tool Calls: Treat every small work unit as a task or tool call. This approach simplifies management and scheduling while better leveraging Pickaxe’s capabilities. -
Treat LLM Calls as Libraries and Own Your Data Lookups: Avoid unconstrained agent tool calls for data lookups. All tool calls should validate user permissions and separate data lookups from LLM calls to ensure security and data accuracy.
Technical Deep Dive into Pickaxe
Pickaxe is built as a utility layer on top of Hatchet. At its core lies the concept of a persistent task queue, where every task executed in Hatchet is stored in a database. This design enables tasks to be easily replayed and recovered from failures, even in the event of hardware crashes.
For agents, this persistent execution model is invaluable. Agents often run for extended periods and must be resilient to hardware failures. Additionally, they need to manage third-party rate limits and implement concurrency controls to prevent system overload.
Pickaxe’s execution model allows agents to automatically “checkpoint” their state. For example, consider an agent that has called tools like search_documents
and get_document
and is currently processing extract_from_document
. If the machine running the agent crashes during this step, Pickaxe will automatically replay all steps up to the point of failure in the execution history:
Execution History:
-> Start search_documents (replayed)
-> Finish search_documents (replayed)
-> Start get_document (replayed)
-> Finish get_document (replayed)
-> Start extract_from_document (replayed)
-> (later) Finish extract_from_document
In other words, Pickaxe caches the execution history, enabling the agent to recover gracefully from failures without needing to redo previous work. This mechanism becomes even more powerful when agents need to wait for external systems, such as human reviewers or external events. In such cases, building a resilient system becomes significantly more manageable, as the event enabling execution to proceed is automatically stored and replayed.
Beyond Hatchet, Pickaxe draws inspiration from two key concepts:
-
12-Factor Agents: This serves as the foundation for Pickaxe’s advocacy of owning control flow, context windows, and prompts. -
Anthropic’s “Building Effective Agents”: Pickaxe ensures compatibility with all patterns documented in Anthropic’s article.
Pickaxe represents a groundbreaking advancement in AI agent development. Its unique advantages and flexible architecture empower developers to build intelligent, reliable, and efficient systems in the AI era. If you encounter complex challenges in developing AI agents, consider leveraging this powerful tool. It may become an indispensable ally in your development journey, propelling your projects toward success.
I hope this blog post has provided you with a comprehensive understanding of Pickaxe. Should you find yourself navigating the complexities of AI agent development, Pickaxe might just be the solution you’ve been searching for. Give it a try, and you’ll discover how it can streamline your development process and unlock new possibilities for your projects.