Status: Draft
Applies to: CortX v0.6.x and later
Purpose: Define the required structure and contract for all CortX
modules.
This document ensures that all modules added to the CortX ecosystem follow a consistent interface so they can be discovered, loaded, and executed safely by the runtime.
A CortX Module is a self-contained capability package that can be registered with the CortX runtime.
Modules may provide:
- Tools
- Agents
- Workflows
- Integrations
- Data adapters
- Domain logic
Modules must follow strict structural and interface requirements so that:
- The runtime can discover them automatically
- LLM coding assistants can generate them reliably
- The system remains local-first and composable
Every module must follow these design principles:
- Self Contained
- Modules should not rely on global runtime state.
- Explicit Registration
- Modules must register themselves through a module entrypoint.
- Clear Capability Declaration
- Modules must explicitly declare what capabilities they provide.
- No Hidden Side Effects
- Modules must not perform work during import.
- Local First
- Modules must function without requiring external services.
Example module layout:
modules/
example_module/
module.py
tools/
tool_a.py
tool_b.py
agents/
helper_agent.py
workflows/
workflow_x.py
config/
defaults.yaml
README.md
Required file:
module.py
Each module must expose a register() function.
Example:
def register(registry):
registry.register_tool(my_tool)
registry.register_agent(my_agent)
registry.register_workflow(my_workflow)This function is called by the CortX module loader.
The registry object will provide:
register_tool()register_agent()register_workflow()register_capability()
Modules must define metadata:
MODULE_METADATA = {
"name": "example_module",
"version": "0.1.0",
"description": "Example CortX module",
"author": "CortX",
"capabilities": [
"tools",
"workflows"
]
}Fields:
Field Description
name Unique module name version Module version description Short description author Module author capabilities Declared module capabilities
Tools must follow this structure:
def example_tool(input_text: str) -> str:
\"\"\"
Description of tool for the LLM.
\"\"\"
return "result"Optional metadata:
example_tool.metadata = {
"name": "example_tool",
"description": "Demonstration tool"
}Tools must be:
- Pure functions when possible
- Deterministic
- Side-effect minimal
Agents must expose:
run(context)
Example:
class ExampleAgent:
def run(self, context):
return "result"Agents should:
- Accept structured context
- Return structured output
Workflows orchestrate multiple tools or agents.
Example:
def example_workflow(context):
result = tool_a(context)
return resultWorkflows should:
- Be deterministic where possible
- Avoid hidden global state
Modules may declare capabilities such as:
- tools
- agents
- workflows
- integrations
- data_sources
Example:
MODULE_METADATA["capabilities"] = [
"tools",
"agents"
]The CortX runtime will:
- Scan the
modules/directory - Import
module.py - Read
MODULE_METADATA - Call
register()
Modules must not perform work at import time.
Modules must remain compatible with the CortX runtime version they target.
Example:
requires_cortx >= 0.6.0
Modules must not:
- Open network connections automatically
- Execute shell commands without explicit user request
- Modify runtime internals
- Access filesystem outside allowed paths
Each module should include tests:
tests/
test_tools.py
test_agents.py
Tests should validate:
- Tool behavior
- Agent outputs
- Workflow logic
modules/
hello/
module.py
tools/
hello.py
module.py:
from .tools.hello import hello
MODULE_METADATA = {
"name": "hello",
"version": "0.1.0",
"capabilities": ["tools"]
}
def register(registry):
registry.register_tool(hello)Planned module features:
- Module dependency graph
- Version resolution
- Sandboxed execution
- Remote module registries
- Capability permissions
- Module isolation environments
These will be introduced after CortX v0.7.x.
Modules are the core extensibility mechanism of CortX.
Strict adherence to this specification ensures:
- predictable runtime behavior
- LLM-friendly development
- safe modular expansion
This specification will evolve as CortX approaches v1.0.