DEV Community

Leonardo Weber
Leonardo Weber

Posted on

Building and Optimizing a Competitive AI Coding Agent

I developed an autonomous coding agent designed to solve challenging programming tasks in a competitive environment. Rather than relying on an LLM to generate code in a single pass, I built a complete workflow combining repository analysis, planning, implementation, execution, testing, and iterative refinement.

The agent’s workflow:

Task → Analyze → Plan → Implement → Execute → Test → Diagnose → Refine → Retest → Submit

The feedback loop is where the real improvement happens. When a test fails, the agent analyzes the error, identifies the likely cause, updates the code, and reruns the relevant tests. This helps catch logic errors and edge cases before submission instead of accepting the first plausible-looking solution.

Performance comparison

I evaluate the agent with and without iterative feedback using the same benchmark tasks and execution limits:

Task success rate: [baseline]% → [optimized]%

Tests passed per task: [baseline] → [optimized]

Average completion time: [baseline] → [optimized]

Compute cost per successful task: [baseline] → [optimized]

These measurements help show whether each optimization improves correctness and reliability without introducing excessive latency or compute overhead.

Beyond the feedback loop, I optimize model selection, prompt design, repository context, tool usage, inference settings, and failure recovery. The goal is to build an agent that doesn't just generate code, but uses execution results as evidence to improve its solutions systematically.

Top comments (1)

Collapse
 
aisovereign profile image
Ananya Soni •

The feedback loop focus is spot on. Single-pass LLM generation is basically a trap, and active test-diagnose-refine passes are the only way to catch silent logic edge cases before shipping.

Building multimodal AGI architectures and autonomous agents from scratch at AGI Systems Directorate (where I'm Founder & CEO, working on our agent Project Lumina), the biggest headache with iterative loops like this is always context state corruption and compute latency stacking up during re-tests.

Quick question on your setup: are you running deterministic local execution sandboxes for the diagnostic phase, or letting the agent dynamically alter its tool suite based on error outputs? Would love to know what stack you're running this on.

Also AI agents hallucination is also one of the problems