Agentic Code Fixing — Deep Dive

Understanding how Nascentist autonomously fixes code through iterative execution and analysis.

What is "agentic"?

Unlike traditional completion APIs that simply predict the next tokens, agentic endpoints can:

  • Execute code in a controlled sandbox environment
  • Read real output including errors and runtime behavior
  • Iterate on solutions by modifying code based on feedback
  • Verify fixes by running tests or re-executing

The Execution Sandbox

When you use the /agent/fix endpoint, your code runs in an isolated sandbox:

  • Isolated environment — No internet access, limited filesystem
  • 30-second timeout — Long-running code is terminated
  • Fresh state — Each execution starts with a clean environment
  • Secure — No data persists between runs

Supported Languages

LanguageRuntimeStatus
PythonPython 3.11✅ Available
JavaScriptNode.js 20✅ Available
TypeScriptNode.js 20✅ Available
GoGo 1.21✅ Available
RustRust 1.75✅ Available

Best Practices

1. Provide Full Files

For best results, submit complete files rather than snippets. This gives the model full context:

// Good: Full function with context
def calculate_statistics(numbers):
    mean = sum(numbers) / len(numbers)
    variance = sum((x - mean) ** 2 for x in numbers) / len(numbers)
    return mean, variance

result = calculate_statistics([1, 2, 3, 4, 5])
print(result)

2. Use Test Cases

Provide test cases to help validate fixes:

{
  "code": "def add(a, b):\n    return a + b",
  "test_cases": [
    {"input": "add(1, 2)", "expected": "3"},
    {"input": "add(-1, 1)", "expected": "0"},
    {"input": "add(0, 0)", "expected": "0"}
  ]
}

3. Handle Partial Fixes

Sometimes the model may not fully fix the code. The response includes a status field:

  • fixed — Code works and passes all tests
  • partial — Improved but some issues remain
  • failed — Could not fix within iteration limit

Cost Optimization

Each iteration uses additional tokens. To minimize costs:

  • • Start with max_iterations: 3 for simple fixes
  • • Increase only if needed for complex issues
  • • Use test_cases to validate fixes faster
  • • Provide the error message if you know it

Worked Example

Let's fix a Python script with three bugs:

# Original broken code
def find_primes(n):
    primes = []
    for i in range(2, n+1):
        is_prime = True
        for j in range(2, i):
            if i % j = 0:
                is_prime = False
                break
        if is_prime:
            primes.append(i)
    return primes

print(find_primes(10))

After 3 iterations, the model:

  1. Identified the syntax error (should be == not =)
  2. Fixed the comparison operator
  3. Verified the fix works correctly