Introduction
Anvil is a JIT (Just-In-Time) Infrastructure SDK for AI agents. Instead of hardcoding tool implementations that break when APIs change, you define intents and Anvil generates the code on the fly.
The Problem: Tool Rot
Section titled “The Problem: Tool Rot”Every AI agent needs tools - functions to search the web, call APIs, process data. Traditional approaches have a critical flaw:
# Traditional approach - brittle, breaks when API changesdef search_notion(query: str) -> dict: response = requests.post( "https://api.notion.com/v1/search", headers={"Authorization": f"Bearer {NOTION_KEY}"}, json={"query": query} ) return response.json()This works until:
- The API endpoint changes
- Authentication requirements update
- Response format evolves
- Rate limiting is introduced
Then your agent breaks, and you’re manually fixing code.
The Solution: Intent-Based Tools
Section titled “The Solution: Intent-Based Tools”With Anvil, you describe what you want, not how to do it:
from anvil import Anvil
anvil = Anvil()
search_tool = anvil.use_tool( name="search_notion", intent="Search a Notion workspace for pages matching a query", docs_url="https://developers.notion.com/reference/post-search")Anvil:
- Fetches the latest API documentation
- Generates working Python code using an LLM
- Caches the generated code for future use
- Automatically regenerates if the tool fails
Key Features
Section titled “Key Features”JIT Code Generation
Section titled “JIT Code Generation”Tools are generated at runtime using LLMs. Provide the intent and optionally a documentation URL, and Anvil produces working code.
Self-Healing
Section titled “Self-Healing”When a tool fails, Anvil captures the error context and regenerates the code automatically. No manual intervention needed.
Multi-Provider Support
Section titled “Multi-Provider Support”Use Claude (Anthropic), GPT-4 (OpenAI), or Grok (xAI). Bring your own API keys.
Framework Adapters
Section titled “Framework Adapters”One tool works everywhere:
# LangChainlc_tool = search_tool.to_langchain()
# CrewAIcrew_tool = search_tool.to_crewai()
# AutoGenautogen_tool = search_tool.to_autogen()
# OpenAI Agents SDKoai_tool = search_tool.to_openai_agents()Glass-Box Transparency
Section titled “Glass-Box Transparency”All generated code is saved to disk, visible, and editable. You can:
- Inspect what Anvil generated
- Manually edit and “eject” tools
- Version control everything
When to Use Anvil
Section titled “When to Use Anvil”Anvil is ideal when:
- You’re building AI agents that need dynamic tool capabilities
- You want tools that adapt to API changes automatically
- You’re working with multiple AI frameworks and want portable tools
- You need transparency into what your tools are doing
Next Steps
Section titled “Next Steps”Ready to get started?