Evidence boundary
This breakdown describes the architecture of an autonomous agentic code refactoring engine (OpenAI Codex / Claude Engineer pattern). The pinned source establishes the symbol extraction, diff generation, and sandbox verification boundaries shown here.
Architecture at a glance
The code editing control loop converts user feature requests into AST symbol contexts, passes structured contexts to a model diff generator, and executes test suites inside an isolated Docker sandbox.
Multi-file diff generation
Generating precise search/replace code modifications across multiple files requires structured patch schemas. The model outputs line-anchored search blocks paired with exact replacement text.
Isolated execution sandbox
All generated patch diffs are verified inside an ephemeral Docker container before committing changes to the repository, ensuring broken code edits or failing unit tests never pollute the main branch.
Decisions and measurements
| Measurement | Decision it supports | |---|---| | AST parsing throughput (symbols/sec) | Workspace indexing latency and file scale limits | | Search/Replace patch application accuracy | Model choice and prompt context structure | | Sandbox test execution duration | Timeout thresholds and parallel worker scaling |
Failure modes
- Bypassing sandbox execution and committing unverified code edits directly to main branches.
- Passing entire 10,000-line source files to the LLM instead of targeted AST symbol context slices.
- Failing to set execution timeouts on untrusted generated code loops.
Why is tree-sitter AST symbol indexing preferred over passing full raw source files into agentic code editing prompts?
Architectural takeaway
An autonomous code editing agent requires strict separation between intent parsing, symbol indexing, diff generation, and sandbox execution boundaries.