Framework Adapters
AG-Kit provides bidirectional adapters to seamlessly integrate with popular AI frameworks like LangChain and LlamaIndex. Convert AG-Kit tools to framework-specific tools and vice versa.Overview
The adapter system enables:- AG-Kit → LangChain: Convert any AG-Kit tool to LangChain
StructuredTool - AG-Kit → LlamaIndex: Convert any AG-Kit tool to LlamaIndex
FunctionTool - LangChain → AG-Kit: Import LangChain tools into AG-Kit
- LlamaIndex → AG-Kit: Import LlamaIndex tools into AG-Kit
- Universal Compatibility: All AG-Kit tools (Code Executors, Bash, File System) work with both frameworks
Quick Start
LangChain Integration
LlamaIndex Integration
Installation
LangChain Support
LlamaIndex Support
Supported Tools
All AG-Kit tools are compatible with both frameworks:| Tool Category | Tools | LangChain | LlamaIndex |
|---|---|---|---|
| Code Executors | UnsafeLocalCodeExecutor, BuiltInCodeExecutor | ✅ | ✅ |
| Bash Tools | create_bash_tool, create_multi_command_tool | ✅ | ✅ |
| File System | create_read_tool, create_write_tool, create_edit_tool, etc. | ✅ | ✅ |
LangChain Adapter
Converting AG-Kit Tools to LangChain
Converting LangChain Tools to AG-Kit
LangChain with LangGraph
LlamaIndex Adapter
Converting AG-Kit Tools to LlamaIndex
Converting LlamaIndex Tools to AG-Kit
Bidirectional Conversion
Convert tools back and forth between frameworks:Complete Examples
Example 1: Code Executor with Both Frameworks
Example 2: Bash Tools with Both Frameworks
Example 3: File System Tools with Both Frameworks
Example 4: Workflow Integration
API Reference
AGKitTool
Wrapper class for converting AG-Kit tools to other frameworks.Conversion Functions
Error Handling
Both adapters preserve error handling behavior:Best Practices
- Choose the right framework: Use LangChain for complex agent workflows, LlamaIndex for RAG applications
- Reuse contexts: Create contexts once and reuse for multiple tools
- Handle errors gracefully: Check tool results for errors
- Clean up resources: Properly dispose of file operators and bash contexts
- Test conversions: Verify tool behavior after conversion
- Use type hints: Leverage Python type hints for better IDE support
Performance Considerations
- Conversion overhead: Minimal - adapters are lightweight wrappers
- Execution performance: Identical to native AG-Kit tools
- Memory usage: No significant overhead from adapters
- Async support: Full async/await support in both frameworks
Troubleshooting
Common Issues
Tool not found after conversionExamples Repository
Find complete working examples at:Related Documentation
Code Executor
Execute Python code
Bash Tools
Execute shell commands
Filesystem Tools
File system operations
MCP Integration
Model Context Protocol