integrations.codemode
Integration module for agent-codemode and agent-skills.
This module provides integration between:
- agent-runtimes: The main agent infrastructure
- agent-codemode: Code-first MCP tool composition
- agent-skills: Reusable agent skill management
It allows agents running on agent-runtimes to:
- Use Code Mode for efficient tool composition
- Access and execute skills
- Discover tools progressively
CodemodeIntegration Objects
class CodemodeIntegration()
Integration between agent-runtimes and agent-codemode.
Connects the agent-runtimes MCP infrastructure with agent-codemode's code execution capabilities.
Example:
```python
from agent_runtimes.integrations.codemode import CodemodeIntegration
integration = CodemodeIntegration()
await integration.setup()
# Execute code that uses tools
result = await integration.execute_code('''
from generated.mcp.filesystem import read_file
content = await read_file({"path": "/tmp/data.txt"})
print(content)
''')
```
__init__
def __init__(mcp_manager: Optional[MCPManager] = None,
skills_path: str = "./skills",
sandbox_variant: str = "local-eval")
Initialize the integration.
Arguments:
mcp_manager- Optional MCPManager from agent-runtimes.skills_path- Directory for skill storage.sandbox_variant- Sandbox type for code execution.
setup
async def setup() -> None
Set up the integration.
Imports agent-codemode and agent-skills, configures the tool registry with servers from agent-runtimes.
execute_code
async def execute_code(
code: str,
timeout: float = 30.0,
context: Optional[dict[str, Any]] = None) -> dict[str, Any]
Execute code that can compose tools.
Arguments:
code- Python code to execute.timeout- Execution timeout.context- Optional variables to inject.
Returns:
Execution result dictionary.
call_tool
async def call_tool(tool_name: str, arguments: dict[str, Any]) -> Any
Call a single tool.
Arguments:
tool_name- Full tool name (server__toolname).arguments- Tool arguments.
Returns:
Tool result.
search_tools
async def search_tools(query: str, limit: int = 10) -> list[dict[str, Any]]
Search for available tools.
Arguments:
query- Search query.limit- Maximum results.
Returns:
List of matching tools.
run_skill
async def run_skill(
skill_name: str,
arguments: Optional[dict[str, Any]] = None) -> dict[str, Any]
Run a skill by name.
Arguments:
skill_name- Name of the skill.arguments- Optional arguments.
Returns:
Skill execution result.
search_skills
async def search_skills(query: str, limit: int = 10) -> list[dict[str, Any]]
Search for skills.
Arguments:
query- Search query.limit- Maximum results.
Returns:
List of matching skills.
cleanup
async def cleanup() -> None
Clean up resources.
get_codemode_integration
def get_codemode_integration(
mcp_manager: Optional[MCPManager] = None) -> CodemodeIntegration
Get a CodemodeIntegration instance.
Factory function for creating integration instances.
Arguments:
mcp_manager- Optional MCPManager.
Returns:
CodemodeIntegration instance.