Skip to content

API Reference parrot_tools.codeinterpreter.tool

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.codeinterpreter.tool

View source

CodeInterpreterTool - Parrot Tool for comprehensive code analysis.

Agent-as-Tool that wraps an LLM agent with specialized capabilities for:

  • Code analysis with complexity metrics
  • Documentation generation
  • Test generation
  • Bug detection
  • Code explanation

Alias CODE_INTERPRETER_SYSTEM_PROMPT

Re-exported from parrot_tools.codeinterpreter.prompts.CODE_INTERPRETER_SYSTEM_PROMPT.

Alias CodeAnalysisResponse

Re-exported from parrot_tools.codeinterpreter.models.CodeAnalysisResponse.

Class CodeInterpreterArgs

Input schema for CodeInterpreterTool.

Fields:

Field Type Default Description
code str Python source code to analyze
operation Literal['analyze', 'document', 'test', 'debug', 'explain'] 'analyze' Type of operation to perform on the code
focus_areas Optional[str] Comma-separated list of areas to focus on for analysis (e.g., 'complexity,error handling')
docstring_format str 'google' Format for docstrings: 'google', 'numpy', or 'sphinx'
include_module_docs bool True Whether to generate module-level documentation
test_framework str 'pytest' Testing framework to use for test generation
coverage_target float 80.0 Target code coverage percentage for tests
include_edge_cases bool True Whether to include edge case tests
severity_threshold str 'low' Minimum severity for bug detection: 'critical', 'high', 'medium', or 'low'
include_style_issues bool False Whether to include style/formatting issues in bug detection
expertise_level str 'intermediate' User expertise level for explanations: 'beginner', 'intermediate', or 'advanced'
include_visualization bool True Whether to include ASCII visualizations in explanations

Class CodeInterpreterTool

Agent-as-Tool for comprehensive Python code analysis.

Features:

  • Code analysis with complexity metrics
  • Automatic documentation generation
  • Test generation with pytest
  • Bug detection with severity classification
  • Code explanation at various expertise levels
  • Isolated code execution for verification

This tool wraps an LLM agent with specialized capabilities and internal tools for static analysis, code execution, and file operations.

Parameter Type Default Description
llm LLM client instance (must support structured outputs via ask() method)
use_docker bool True Whether to use Docker for code execution
docker_config Optional[Dict[str, Any]] None Optional Docker configuration parameters
**kwargs {} Additional arguments for AbstractTool

Method CodeInterpreterTool.analyze_code

Convenience method for code analysis.

analyze_code(code: str, focus_areas: Optional[list[str]] = None) -> CodeAnalysisResponse

Parameter Type Default Description
code str
focus_areas Optional[list[str]] None

Returns: CodeAnalysisResponse

Method CodeInterpreterTool.generate_documentation

Convenience method for documentation generation.

generate_documentation(code: str, docstring_format: str = 'google', include_module_docs: bool = True) -> DocumentationResponse

Parameter Type Default Description
code str
docstring_format str 'google'
include_module_docs bool True

Returns: DocumentationResponse

Method CodeInterpreterTool.generate_tests

Convenience method for test generation.

generate_tests(code: str, test_framework: str = 'pytest', coverage_target: float = 80.0, include_edge_cases: bool = True) -> TestGenerationResponse

Parameter Type Default Description
code str
test_framework str 'pytest'
coverage_target float 80.0
include_edge_cases bool True

Returns: TestGenerationResponse

Method CodeInterpreterTool.detect_bugs

Convenience method for bug detection.

detect_bugs(code: str, severity_threshold: str = 'low', include_style_issues: bool = False) -> DebugResponse

Parameter Type Default Description
code str
severity_threshold str 'low'
include_style_issues bool False

Returns: DebugResponse

Method CodeInterpreterTool.explain_code

Convenience method for code explanation.

explain_code(code: str, expertise_level: str = 'intermediate', include_visualization: bool = True) -> ExplanationResponse

Parameter Type Default Description
code str
expertise_level str 'intermediate'
include_visualization bool True

Returns: ExplanationResponse

Method CodeInterpreterTool.execute_code_safely

Execute code in isolated environment (direct tool access).

execute_code_safely(code: str) -> Dict[str, Any]

Parameter Type Default Description
code str Python code to execute

Returns: Dict[str, Any] — Execution results dictionary

Method CodeInterpreterTool.cleanup

Clean up resources (Docker containers, temp files, etc.)

cleanup()

Alias DebugResponse

Re-exported from parrot_tools.codeinterpreter.models.DebugResponse.

Alias DocumentationResponse

Re-exported from parrot_tools.codeinterpreter.models.DocumentationResponse.

Alias ExecutionStatus

Re-exported from parrot_tools.codeinterpreter.models.ExecutionStatus.

Alias ExplanationResponse

Re-exported from parrot_tools.codeinterpreter.models.ExplanationResponse.

Alias FileOperationsTool

Re-exported from parrot_tools.codeinterpreter.internals.FileOperationsTool.

Alias OperationType

Re-exported from parrot_tools.codeinterpreter.models.OperationType.

Alias PythonExecutionTool

Re-exported from parrot_tools.codeinterpreter.internals.PythonExecutionTool.

Alias StaticAnalysisTool

Re-exported from parrot_tools.codeinterpreter.internals.StaticAnalysisTool.

Alias TestGenerationResponse

Re-exported from parrot_tools.codeinterpreter.models.TestGenerationResponse.

Alias calculate_code_hash

Re-exported from parrot_tools.codeinterpreter.internals.calculate_code_hash.

Alias create_executor

Re-exported from parrot_tools.codeinterpreter.executor.create_executor.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally