AI & Automation

How AI coding agents work: plan, act, observe

What a coding agent actually does, why running the tests matters more than the model, and the guard rails that keep it safe to use.

Tech Cognixium team 4 min read

An AI coding agent is more than a chatbot that writes code. It writes code, runs it, reads what happened and tries again. That loop is what makes it useful, and it is also the part that needs the most care.

The loop: plan, act, observe

  • Plan: read the task and its tests, and list the steps.
  • Act: write the code, or change only the lines that need fixing.
  • Observe: run the tests and read the results, including any error messages.
  • Repeat until every test passes, or until a limit is reached and a person takes over.

The observe step is the heart of it. A model on its own can only guess whether its code is right. An agent finds out, because the tests give it something concrete to work with: which case failed, what was expected and what came back instead.

Why the tests matter more than the model

An agent is only as good as the checks it runs against. With clear tests, a failing case points straight at the fix. With vague or missing tests, the agent can "pass" by solving the wrong problem, or go round in circles without making progress.

Before you ask an agent to build something, write down five or ten examples of the right answer, including the awkward ones. Those examples become the tests, and they are worth having even if no agent is ever involved.

The guard rails a real agent needs

  • A sandbox: code written by a model runs somewhere isolated, with no access to live data or passwords.
  • A time limit on every run, so code that never finishes cannot hang the agent.
  • A limit on attempts, after which the work goes to a person with a summary of what was tried.
  • Narrow permissions: the agent can change the files and run the commands it needs, and nothing else.
  • A trace of every action, so a person can see what the agent did and in what order.
  • Human review before anything is merged or goes live.

Where agents help, and where they struggle

Agents do well on small, well-defined changes that have good tests: fixing a reported bug, adding a validation rule, writing a data conversion, or updating code after a library changes. They struggle when the goal is unclear, when the tests are thin, or when a change touches many parts of a large system that the agent cannot see at once.

They do not replace engineering judgement. Someone still has to decide what to build, define what "correct" means and review the result. What an agent can take on is the repetitive part of the loop, so that people spend more of their time on those decisions.

How to start

Pick one repetitive kind of change in your code, make sure it has good tests, and run an agent against it in a sandbox, with a person reviewing every result. Keep track of how often its changes are accepted without edits. That tells you whether to use it more widely, change how you use it, or stop.

See the loop for yourself

  • AI Coding Agent: watch an agent plan, write code, run real tests in your browser and fix its own mistakes
  • Demo manual: step-by-step instructions for every demo

In the demo the agent's attempts are written in advance, but the tests really run, so you can see exactly how a failing test leads to the next fix. If you are thinking about agents for your own team, we would be glad to talk it through.

Related service: AI & Intelligent Automation

AI assistants, document processing and workflow automation integrated with the systems you already use.

Learn more

Have an idea? Let's build it properly.

Tell us what you want to build or automate. We'll reply with practical next steps.