09. Advanced Concepts
Advanced Coding Agents
Advanced coding agents treat a repository as their environment: they explore code, apply patches, run tests and linters, diagnose failures, and iterate under step budgets until a reviewable change (often a PR) is ready. They combine planning, tool use, reflection, and sandboxed shell — with test gates and HITL for push, merge, and deploy.
What you will learn
- Describe coding agents vs chat codegen and computer-use
- Design an explore-edit-test-fix loop with stop rules
- Choose repo tools: files, shell, git, diagnostics
- Apply sandbox, allowlists, test gates, and HITL
- Answer interview questions with short, solid answers
Definition
An advanced coding agent is a multi-step system that ships software changes by using repo tools: reading and searching files, editing with patches, running builds/tests, inspecting diagnostics, and preparing commits or PRs. Autonomy is bounded by workspace sandboxes, command allowlists, step budgets, and human gates for irreversible git or deploy actions.
Unlike one-shot chat codegen, these agents verify with the real toolchain. Unlike computer-use, their primary interface is files and terminals — not pixel clicking — though they may open a browser for UI checks.
Introduction
This lesson (#7 in Advanced Concepts) follows Computer-Use and Browser Automation Agents. GUI agents drive UIs; coding agents drive IDEs, shells, and VCS for engineering work.
Next: AI Workflow Automation — chaining agents and tools across business processes.
Why coding agents
- Bugs and features span many files and need iteration
- Tests and typecheckers catch model mistakes early
- Repo context is too large for a single prompt dump
- Teams want PR-ready diffs, not paste-bin snippets
- Still need review for design, security, and product fit
End-to-end pipeline
- Task - issue, bug report, or feature brief
- Explore - map repo, locate symbols, read neighbors
- Plan - small steps and acceptance checks
- Edit - surgical patches, not whole-file rewrites when possible
- Test - unit/lint/build; diagnose failures
- Review + deliver - diff summary, then PR under HITL
Edit-test-fix loop
Reflection for coding agents is mostly executable feedback.
- Edit - apply a minimal patch for the current step
- Run - tests, typecheck, linters, or targeted scripts
- Diagnose - parse logs, stack traces, LSP diagnostics
- Fix - adjust code or tests; avoid unrelated churn
- Budget - max tool calls, wall-clock, and retry count
- Escalate - ask HITL when blocked or acceptance is ambiguous
Tool surface
- read_file / search / list_dir for exploration
- apply_patch or write with path allowlists
- shell for build/test (command allowlist)
- git status/diff/commit (push gated)
- diagnostics from compiler or language server
- optional browser for UI smoke checks
Safety and controls
Shell access without bounds can wipe repos or leak secrets.
- Workspace sandbox — confine edits and cwd
- Allowlist commands and blocked paths (.env, keys, prod configs)
- Require tests/lint before offering a PR
- HITL for push, merge, deploy, and dependency upgrades
- No network by default, or allowlist package registries only
- Trace every edit and shell call for audit/replay
Failure modes
- Hallucinated APIs and imports that never existed
- Infinite fix loops on flaky or misread failures
- Drive-by refactors that enlarge the blast radius
- Deleting or overwriting critical files
- Skipping tests and claiming done
- Committing secrets or .env contents
Evaluation
- Task success: acceptance tests pass on a held-out suite
- Diff quality: size, focus, and reviewability
- Efficiency: steps/tokens to green
- Regression rate on neighboring tests
- Benchmarks like SWE-style issue resolution (with caveats)
Map to earlier modules
- Planning = multi-file change plans under budgets
- Tools = file/shell/git as first-class actions
- Reflection = tests and diagnostics as critics
- Computer-use = optional UI verification
- Next: workflow automation across non-code systems
Program / implementation notes
Implement tools: read, search, apply_patch, run_tests, git_diff. Loop with max steps; stop when acceptance tests pass. Persist traces. Gate git push behind HITL.
- Prefer targeted tests over full-suite every hop when possible
- Next: AI Workflow Automation
Advantages and limitations
- Advantage: closes the loop with real builds and tests
- Advantage: produces reviewable diffs for teams
- Advantage: scales triage of many small issues
- Limitation: weak on deep architecture without human design
- Limitation: flaky tests and poor repos confuse agents
- Limitation: security and ops actions still need HITL
Key points
- Coding agents: task → explore → edit → test → review → PR.
- Use an edit-test-fix loop with executable critics.
- Sandbox paths, allowlist shell, and gate push/deploy.
- Prefer surgical patches and focused tests.
- Eval with acceptance suites and diff quality, not demo chat.
- Escalate ambiguous product decisions to humans.
FAQs
Coding agent vs autocomplete / chat codegen?
Autocomplete and chat suggest code in context. Coding agents run multi-step tool loops: explore the repo, edit, execute tests, and iterate toward a deliverable change.
Do coding agents need computer-use?
Not always. Most work is files and shell. Add browser/computer-use when UI verification or web consoles are part of acceptance.
How do you stop runaway shell loops?
Cap tool calls and wall-clock, allowlist commands, detect repeated identical failures, and abort or HITL when no progress.
When require human review?
Before push/merge/deploy, for security-sensitive changes, dependency upgrades, migrations, and any ambiguous product behavior.
Interview questions
- What is an advanced coding agent?
Answer A budgeted multi-step agent that explores a repo, edits code, runs tests/diagnostics, and iterates toward a reviewable change such as a PR.
- What is the core loop?
Answer Edit, run tests/build, diagnose failures, fix or stop — under step budgets, with acceptance checks as the success signal.
- Which tools matter most?
Answer File read/search/patch, allowlisted shell for tests, diagnostics, and git diff/status — with push and deploy gated.
- How do you keep coding agents safe?
Answer Sandbox the workspace, allowlist commands and paths, block secrets, require test gates, and HITL for push, merge, and deploy.
- How do you evaluate coding agents?
Answer Measure acceptance-test success, regression rate, steps/tokens to green, and diff reviewability on realistic issue suites.
- Coding agent vs computer-use agent?
Answer Coding agents primarily use files and terminals; computer-use agents click GUIs. Coding agents may call browser tools only for UI checks.
Related topics
Practice task
Complete each numbered practice step in a notebook or doc before opening the next lesson.
- Write an acceptance checklist for a “fix failing unit test” coding-agent task.
- List allowlisted shell commands and blocked paths for a Node or Python repo.
- Design stop rules: max steps, identical-failure limit, when to HITL.
- Sketch a PR deliverable template (summary, test plan, risk notes).
- Answer interview questions 1, 2, and 4 in two sentences each.