Tech Tip #4: Give your AI coding agent energy rules

Your AI agent optimises for passing tests, not for energy.

Video created by explainapaper.com

The problem

Coding agents change code until tests pass. Left alone they chase speed or style and can break behaviour while 'optimising'. GreenCode's Constitution gives an agent five inviolable rules, correctness first, and 37 ranked anti-patterns to hunt.

The fix you can use today

  • Add an energy skill or rules file to your agent's instructions.
  • Make correctness, security and public interfaces non-negotiable in those rules.
  • Ask the agent to justify each change and to measure before and after.

GreenCode researchers wrote energy rules for AI coding agents, and the agents saved 25.1% of the energy.

Tools that help

  • GreenCode Constitution skill (GreenCode researchers): open-source energy principles and a catalogue of 37 energy anti-patterns that an AI coding agent can follow to find and fix waste like this
  • GreenCode Constitution profiler (profile.sh) (GreenCode researchers): a script from the Constitution tooling that measures the energy of a command from processor counters, GPU sensors and an optional smart plug, and writes the result as JSON
  • EnergyBench (GreenCode researchers): an MIT-licensed benchmark that scores LLM-generated code for correctness and for the energy it actually uses

How GreenCode helps

GreenCode helps tackle this by publishing the Constitution for anyone to use. An AI agent profiles the code, fixes ranked energy anti-patterns, measures again and keeps only the changes that save energy, leaving changes developers can review. More on this.

Tags

#llm#ai-assistants#refactoring

Sources

Transcript

Your AI agent optimises for passing tests, not for energy. Coding agents change code until the tests pass. Left alone, they chase speed or style. And while optimising, they can quietly break what the code does. Here is the fix you can use today. Give your agent written energy rules, as a skill or a rules file. Make correctness, security and public interfaces rules it can never break. Ask it to explain each change. And ask it to measure energy before and after. GreenCode researchers wrote energy rules for AI coding agents. The agents saved twenty-five point one percent of the energy. That was across forty-five problems, in six programming languages. The rules put correctness first, then list thirty-seven kinds of waste to hunt. You can start with the GreenCode Constitution skill, which gives your agent these rules. Then check the results using tools like its profiler and EnergyBench. GreenCode helps tackle this by publishing the Constitution for anyone to use. The agent keeps only what saves energy, in changes developers can review. That was GreenCode Tech Tip number four. Follow for the next tip, and find more on greencode.ai/tech-tips.

All GreenCode Tech Tips · All GreenCode videos

  • Tip #4
  • For Developers
  • Length 1:16
  • Category AI and machine learning
GreenCode

Want this checked on your own system? Talk to the GreenCode team.

Get in touch