Back to news
ReleaseGemini10 min read

A coding agent that fixes a failing test suite with Gemini 4 Carbon.

Run a local agent on your project with Gemini 4 Carbon: it reads the failure, edits the code, reruns the tests and stops at a credit budget — and you can steer it while it works.

geminicarboncodingagentssdktutorial

Fixing a red test suite is a loop: read the failure, find the cause, change the code, run the tests again. A local IaGenify agent can run that loop on your machine while you watch, with Gemini 4 Carbon as the model. You decide what it may run and what it may spend.

Put the project in the agent's workspace

On a computer, the local agent works in the SDK's own folder in your home directory. Clone the project there, so its files are the ones the agent reads and edits.

git clone https://github.com/your-org/shop-api ~/.iagenify/files/shop-api

Create the agent

Auto mode lets the agent edit files in its workspace without asking; commands are still asked, and the permission callback answers them. Here it allows the test and lint scripts and refuses everything else. The budget stops the run before it spends more than 60 credits, and memory keeps checkpoints so a wrong direction can be rewound.

import { IaGenify } from "iagenify";

const api = new IaGenify({ apiKey: process.env.IAGENIFY_API_KEY });
const pc = await api.storage.get();

const agent = api.agents.create({
  runtime: "local",
  machine: pc,
  model: "gemini-4-carbon",
  mode: "auto",
  budget: 60,
  memory: true,
  onPermission: async ({ category, args }) =>
    category === "exec" && /npm (test|run lint)\b/.test(args.command ?? "") ? "once" : "deny",
});

Run the loop, and steer it

const running = agent.run({
  message: "In shop-api, run npm test, find why the failing tests fail, fix the code (not the tests), and run npm test again until it passes.",
  onEvent(event) {
    if (event.type === "tool_start") console.log("→", event.tool, event.args?.path ?? event.args?.command ?? "");
  },
});

// A constraint you thought of later, read before the agent's next step:
setTimeout(() => agent.queue("Keep the public functions of src/cart.js unchanged."), 20_000);

const result = await running;
console.log(result.stopReason, result.usage.credits);

When the run ends, stopReason says whether the agent finished (end_turn) or stopped at its budget, and usage.credits says what it spent.

Review before you commit

The agent changes files; it does not commit them. Read the diff, run the tests yourself and keep the decision to merge. If a direction turns out wrong, rewind() returns the workspace to where it was before the message.

References

Frequently asked questions

Can the agent push to my repository?

Not in this setup: the permission callback allows only the test and lint scripts, so a git push is refused.

What does Carbon cost?

Through November 30, 2026, 500 credits per million input tokens and 2,500 per million output tokens; from December 1, 1,000 and 5,000. The run's budget caps the total.

Back to news