Implementation:ANative Lab EvoAgentX CodeActions
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Actions, Code_Generation |
| Last Updated | 2026-10-21 00:00 GMT |
Overview
Concrete actions for extracting and verifying LLM-generated code blocks in code generation workflows.
Description
- CodeExtraction — Action that extracts and saves code blocks from text. Takes `code_string`, `target_directory`, optional `project_name`. Uses LLM to identify code blocks (language, filename, content), saves them to disk, and identifies the main entry file. `CodeBlockList` parses the structured LLM output.
- CodeVerification — Action that verifies and corrects code using LLM. Takes code string and optional requirements. Uses LLM to analyze code, identify issues, and produce corrected code. Output includes `analysis_summary`, `issues_identified`, `thought_process`, `modification_strategy`, `verified_code`. Falls back to extracting code blocks if title parsing fails.
Usage
- Code generation workflows: Use `CodeExtraction` to save LLM-generated code to files.
- Code verification: Use `CodeVerification` to verify and correct generated code before use.
- Autoconstruction pipeline: Both actions are part of the code generation pipeline.
Code Reference
Source Location
- Repository: EvoAgentX
- Extraction: evoagentx/actions/code_extraction.py (L1-276)
- Verification: evoagentx/actions/code_verification.py (L1-63)
Signature
class CodeExtraction(Action):
# CodeExtractionInput: code_string, target_directory, project_name
# CodeExtractionOutput: code_blocks (CodeBlockList), main_file
...
class CodeVerification(Action):
# CodeVerificationInput: code, requirements
# CodeVerificationOutput: analysis_summary, issues_identified, verified_code
...
Import
from evoagentx.actions.code_extraction import CodeExtraction
from evoagentx.actions.code_verification import CodeVerification
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| code_string | str | Yes | Text containing code blocks |
| target_directory | str | Yes (extraction) | Directory to save code files |
| code | str | Yes (verification) | Code to verify |
| requirements | str | No | Optional code requirements |
Outputs
| Name | Type | Description |
|---|---|---|
| code_blocks | CodeBlockList | List of extracted code blocks |
| verified_code | str | Corrected code |
| issues_identified | List[str] | Issues found in code |
Usage Examples
Extract and Verify Code
from evoagentx.actions.code_extraction import CodeExtraction
from evoagentx.actions.code_verification import CodeVerification
# 1. Extract code blocks from LLM output
extraction = CodeExtraction(llm=llm)
result = extraction(code_string=llm_output, target_directory="./project")
# 2. Verify the extracted code
verification = CodeVerification(llm=llm)
verified = verification(code=result.code_blocks.to_code())
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment