class CodeExecutionTool: """Tool for executing code using a CodeExecutor.""" def __init__(self, executor: CodeExecutor) -> None: self._executor = executor async def execute_code(self, code: str, language: Literal["python", "sh"] = "python") -> str: result = await self._executor.execute_code_blocks( [CodeBlock(code=code, language=language)], CancellationToken(), ) return result.output