Skip to main content
Kubiya’s runtime-agnostic architecture allows you to extend the platform with custom runtimes using any Python-based AI framework. Whether you want to integrate LangChain, CrewAI, AutoGen, or build a completely custom solution, this guide shows you how.
Developer-Focused DocumentationThis page contains technical implementation details for building custom runtimes. For user-facing runtime selection and configuration, see the Runtime Comparison page.

Why Build a Custom Runtime?

Custom runtimes enable you to:
  1. Integrate specialized frameworks: Use LangChain chains, CrewAI crews, AutoGen agents, or any Python AI framework
  2. Implement custom orchestration: Build complex multi-agent systems or specialized workflow patterns
  3. Optimize for specific use cases: Create runtimes tailored to your organization’s needs
  4. Leverage existing tooling: Integrate with internal tools, APIs, and infrastructure
  5. Control execution logic: Full control over model interactions, tool calling, and conversation management
Common use cases:
  • Multi-agent collaboration systems (CrewAI, AutoGen)
  • Specialized RAG implementations (LangChain with custom retrieval)
  • Domain-specific orchestration (healthcare, finance, legal)
  • Integration with proprietary AI systems
  • Custom prompt engineering and model routing

Runtime Architecture

All runtimes in Kubiya inherit from the BaseRuntime abstract class and register via the RuntimeRegistry: Key components:

Building a Custom Runtime

1

Understand the Base Class

Review the BaseRuntime interface in /control_plane_api/worker/runtimes/base.pyKey abstract methods you must implement:
What the base class provides for free:
  • Lifecycle management (execute() and stream_execute() orchestration)
  • Automatic hook calling (before_execute, after_execute, on_error)
  • Control Plane integration (metadata caching)
  • Cancellation registration
  • Configuration validation
  • Error handling framework
2

Create Your Runtime Class

File structure for a custom runtime:
Basic runtime skeleton:
3

Implement Tool Integration

Tools are the capabilities your agent can use (Skills, MCP servers, custom functions).Option 1: Convert Kubiya Skills to your framework’s tool format
Option 2: Native MCP Server integration
Option 3: Hybrid approach
4

Add Lifecycle Hooks

Lifecycle hooks enable monitoring, logging, and integration points.
5

Register Your Runtime

Use the @RuntimeRegistry.register() decorator to make your runtime discoverable:
Runtime discovery:
6

Test Your Runtime

Unit tests for your runtime implementation:
Integration tests with real executions:

Real-World Examples

Example 1: LangChain Runtime

Key implementation patterns for LangChain integration:
Key concepts:
  • Convert Kubiya Skills to LangChain StructuredTool format
  • Use LangChain’s AgentExecutor for tool orchestration
  • Leverage LangChain callbacks for streaming
  • Map conversation history to LangChain message format

Example 2: CrewAI Runtime

Key implementation patterns for multi-agent CrewAI:
Key concepts:
  • Define multiple specialized agents with roles
  • Use CrewAI’s Process for orchestration (sequential, hierarchical)
  • Agents collaborate on tasks automatically
  • Note: CrewAI doesn’t provide token usage metrics

Configuration Schema

Define runtime-specific configuration via runtime_config in agent configuration:

Best Practices

Always populate usage in RuntimeExecutionResult for analytics:
If your framework doesn’t expose usage, estimate or use callbacks.
Use lifecycle hooks for graceful degradation:
Convert Kubiya conversation history to your framework’s format:
Use the Control Plane client for metadata, caching, and state:
Provide comprehensive documentation for users:
Write comprehensive tests:

API Reference

BaseRuntime Class

Abstract base class for all runtimes

RuntimeExecutionContext

Input context passed to runtime:

RuntimeExecutionResult

Output structure from runtime:

RuntimeCapabilities

Runtime capability flags:

RuntimeRegistry

Runtime registration and discovery:

Deployment

Steps to deploy your custom runtime:
  1. Implement your runtime class following this guide
  2. Add to RuntimeType enum in base.py (if adding new type)
  3. Register with decorator: @RuntimeRegistry.register(RuntimeType.YOUR_RUNTIME)
  4. Write tests (unit + integration)
  5. Document your runtime (README.md in runtime directory)
  6. Update agent configuration to use your runtime:
  1. Monitor execution via Kubiya dashboard and logs

Next Steps

Agno Runtime Source

Reference implementation of Agno runtime

Claude Code Runtime Source

Reference implementation of Claude Code runtime

Skills Documentation

Learn about Skills (tools) integration

Control Plane API

Control Plane integration and runtime registry