Urgent.News

What's breaking now, across thousands of outlets.

Tech

Give Your Coding Agent Scripts, Not Prose: Build a Tool-Contract Doctor First

A coding agent with a folder of scripts and a contract test will outrun one with a gorgeous instruction file. Not because scripts are clever — because scripts fail loudly, and prose doesn't. I keep reading AGENTS.md files that read like onboarding docs for a new hire. Pleasant, sure. They also drift the moment the repo changes, and nothing tells you when they've gone stale. "Run the tests" is an…

A coding agent with a folder of scripts and a contract test will outperform one with a beautifully written instruction file. The reason for this is that scripts fail loudly, whereas prose does not. Unfortunately, many AGENTS.md files appear to be onboarding documents for a new hire. While these may be pleasant to read, they are also prone to becoming outdated as the repository changes. Running the tests is the only way to ensure that the instructions are up-to-date.

The process from an empty repository to a green tool doctor that gates what the agent can call involves several stages. First, it is essential to determine whether the task is a decision or a procedure. Decisions should be written in prose, while procedures should be written in scripts. The agent needs to perform a repeatable step that is stable and report whether it was successful. The exit code should be verified in the Continuous Integration (CI) system, rather than relying on a testable test.

The contract between the agent and the tool should be clearly defined. The contract should include three failure classes and one JSON shape, along with one timeout. By defining the contract in this way, the agent can receive a stable surface instead of a hopeful description. The contract should consist of three exit codes: success, failure due to a missing required flag, and failure due to a missing path.

The happy path should emit parseable JSON with named keys, and the contract should include three failure classes and three exit codes. Vague failures are the reason agents retry indefinitely.

After writing the contract, the next step is to write the doctor that reads the contract. The doctor should validate the tool interfaces before handing them to the agent. The doctor should import the necessary libraries, set a timeout for the subprocess.run command, and run the appropriate command based on the case. If the command is not found, the doctor should return a problem indicating that the command was not found.

If the subprocess times out, the doctor should return a problem indicating that the command timed out. The doctor should then check the return code of the subprocess and compare it to the expected exit code in the contract. If the exit codes do not match, the doctor should append a problem indicating the mismatch. If the JSON output is expected, the doctor should attempt to load the JSON from the subprocess's stdout.

If the JSON cannot be loaded, the doctor should append a problem indicating that the stdout is not JSON.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Node.js Secure Direct Browser Uploads for Generic Gaming Files (Object Storage at Scale)

Large product-image batches change this decision: the browser should send bytes to storage, while the Node.js application issues narrow, tenant-scoped permission and stays out of the data path.

  • Node.js acts as intermediary for secure direct browser uploads of gaming files.
  • Browser transfers bytes directly to object storage, minimizing Node.js server involvement.

Human as a Tool: The Agent Pattern Where You Work for the Machine

There's an agent design pattern with an uncomfortable premise: the agent is the orchestrator, and you are one of its tools.

  • Human-as-a-tool pattern treats humans as integral components of machine operation.
  • Implementation involves simple tool definition with human operator response to specific questions.

More from Sunday 8 November →