forked from HAL9000/cleveragents-core
6bd1ff3401
- Pre-configured for Execute phase - Very low temperature (0.2) for precise code generation - Executor context view (focused on source code) - Includes edit_file inline tool with search/replace - High max_iterations (100) for complex implementations Refs: C1.5f
164 lines
4.6 KiB
YAML
164 lines
4.6 KiB
YAML
# Execution Actor Example
|
|
#
|
|
# Pre-configured actor for the Execute phase of plan execution.
|
|
# Execution actors implement the strategy by making precise code changes
|
|
# using available tools and skills.
|
|
#
|
|
# Use case: Execute phase - implementing the planned changes
|
|
|
|
version: "3"
|
|
name: default-executor
|
|
description: Default executor for Execute phase implementation
|
|
type: llm
|
|
|
|
# LLM configuration - low temperature for precise code generation
|
|
provider: openai
|
|
model: gpt-4-turbo
|
|
temperature: 0.2
|
|
|
|
system_prompt: |
|
|
You are a code executor. You implement strategies by making precise,
|
|
targeted changes to code using the provided tools.
|
|
|
|
## Execution Principles
|
|
|
|
1. **Read before write**: Always read files before editing
|
|
2. **Precise edits**: Use edit_file for targeted changes, not wholesale rewrites
|
|
3. **Verify syntax**: Ensure code is syntactically valid
|
|
4. **Test awareness**: Consider how changes affect tests
|
|
5. **Document changes**: Explain what you changed and why
|
|
|
|
## Available Tools
|
|
|
|
- read_file: Read file contents before editing
|
|
- write_file: Create new files
|
|
- edit_file: Make targeted edits to existing files
|
|
- delete_file: Remove files
|
|
- list_directory: Explore directory structure
|
|
- search_files: Find code patterns
|
|
|
|
## Workflow
|
|
|
|
For each step in the strategy:
|
|
1. Read relevant files to understand current state
|
|
2. Plan the specific changes needed
|
|
3. Execute changes using appropriate tools
|
|
4. Verify changes are correct (check syntax, imports, etc.)
|
|
5. Document what was changed
|
|
|
|
## Output Format
|
|
|
|
For each file operation:
|
|
|
|
OPERATION: [read_file|write_file|edit_file|delete_file]
|
|
FILE: [path]
|
|
REASON: [why this change is needed]
|
|
[Execute the tool]
|
|
RESULT: [what happened]
|
|
|
|
After all operations:
|
|
SUMMARY: [overall changes made]
|
|
|
|
## Rules
|
|
|
|
- NEVER make changes without reading the file first (except new files)
|
|
- ALWAYS verify imports after adding new code
|
|
- ALWAYS preserve existing code style and conventions
|
|
- NEVER delete code without understanding its purpose
|
|
- ALWAYS provide clear error messages if something fails
|
|
|
|
# Inline tool for file editing
|
|
tools:
|
|
- name: edit_file
|
|
description: Make targeted edits to an existing file using search/replace
|
|
parameters:
|
|
- name: path
|
|
type: string
|
|
description: Path to file to edit
|
|
required: true
|
|
- name: edits
|
|
type: array
|
|
description: List of {old_text, new_text} edit operations
|
|
required: true
|
|
code: |
|
|
# Apply each edit sequentially
|
|
file_path = input_data["path"]
|
|
edits = input_data["edits"]
|
|
|
|
# Read current content
|
|
content = context.get_file(file_path)
|
|
|
|
# Apply edits
|
|
for edit in edits:
|
|
old_text = edit.get("old_text", "")
|
|
new_text = edit.get("new_text", "")
|
|
if old_text in content:
|
|
content = content.replace(old_text, new_text, 1)
|
|
else:
|
|
result = {"error": f"Text not found: {old_text[:50]}..."}
|
|
break
|
|
else:
|
|
# Write back modified content
|
|
context.write_file(file_path, content)
|
|
result = {"success": True, "edits_applied": len(edits)}
|
|
timeout: 30
|
|
|
|
# Reference to built-in file operation tools
|
|
metadata:
|
|
builtin_tools:
|
|
- read_file
|
|
- write_file
|
|
- delete_file
|
|
- list_directory
|
|
- search_files
|
|
- run_command # For running tests, linters, etc.
|
|
|
|
# Memory - executors need more history to track changes
|
|
memory:
|
|
enabled: true
|
|
max_turns: 30
|
|
include_system_messages: false
|
|
|
|
# Context - executor view for focused, precise work
|
|
context:
|
|
view: executor
|
|
include_files:
|
|
# Source code
|
|
- "src/**/*.py"
|
|
- "lib/**/*.py"
|
|
- "**/*.js"
|
|
- "**/*.ts"
|
|
# Tests (to understand requirements)
|
|
- "tests/**/*.py"
|
|
- "**/*.test.js"
|
|
- "**/*.spec.ts"
|
|
# Configuration
|
|
- "pyproject.toml"
|
|
- "setup.py"
|
|
- "package.json"
|
|
- "tsconfig.json"
|
|
exclude_files:
|
|
- "**/__pycache__/**"
|
|
- "**/node_modules/**"
|
|
- "**/.git/**"
|
|
- "**/build/**"
|
|
- "**/dist/**"
|
|
max_file_size_kb: 200 # Larger files OK for implementation
|
|
|
|
# Metadata - executor-specific configuration
|
|
metadata:
|
|
timeout_seconds: 600 # 10 minutes for implementation
|
|
max_iterations: 100 # Allow many iterations for complex implementations
|
|
|
|
# Execution-specific settings
|
|
execution_config:
|
|
# Verify syntax after each file operation
|
|
verify_syntax: true
|
|
# Run linter after changes (if available)
|
|
run_linter: true
|
|
# Backup files before editing
|
|
create_backups: false # Rely on git instead
|
|
# Maximum file size to edit (KB)
|
|
max_edit_size_kb: 500
|
|
|