Autonomous coding brokers: A Codex instance

Autonomous coding brokers: A Codex instance


Prior to now few weeks, a number of “autonomous background coding brokers” have been launched.

  • Supervised coding brokers: Interactive chat brokers which are pushed and steered by a developer. Create code domestically, within the IDE. Device examples: GitHub Copilot, Windsurf, Cursor, Cline, Roo Code, Claude Code, Aider, Goose, …
  • Autonomous background coding brokers: Headless brokers that you simply ship off to work autonomously via an entire job. Code will get created in an atmosphere spun up completely for that agent, and normally leads to a pull request. A few of them are also runnable domestically although. Device examples: OpenAI Codex, Google Jules, Cursor background brokers, Devin, …

I gave a job to OpenAI Codex and another brokers to see what I can be taught. The next is a report of 1 explicit Codex run, that will help you look behind the scenes and draw your individual conclusions, adopted by a few of my very own observations.

The duty

Now we have an inside utility referred to as Haiven that we use as a demo frontend for our software program supply immediate library, and to run some experiments with completely different AI help experiences on software program groups. The code for that utility is public.

The duty I gave to Codex was relating to the next UI challenge:

Precise:

Autonomous coding brokers: A Codex instance

What I wished from the agent:

Screenshot of what we want: The labels should be more human readable, "Delivery Management", "Client Research"

Immediate:
Once we create the filter labels on the dashboard, we create human readable labels primarily based on the classes now we have. "client-research" is become "Consumer-Analysis", "deliveryManagement" into "DeliveryManagement". Enhance the sophistication of the "category-to-human-readable" logic in order that the labels are showing to the consumer as "Consumer Analysis" and "Supply Administration"

This job is

  • Comparatively small
  • A typical “cosmetics” job that’s not tremendous pressing and would possibly get deprioritised repeatedly

Agent logs

I’m sharing the detailed logs right here as a way to get an impression of what’s going on underneath the hood.

Right here’s what the logs view seems like in Codex:

A screenshot of Codex's "Logs" view, showing examples of step summaries and command executions

Accumulating info first

The primary 17 log entries had been all about studying AGENTS.md and README.md:

  • “I must test the AGENTS.md within the repository root for directions.”
  • seems for AGENTS.md, however I had really referred to as it AGENT.md, which led to some forwards and backwards till it figured that out
  • reads README.md
  • Seems at .pre-commit, finds a check setup

The next tables checklist the remainder of the log messages verbatim. After every of these messages, the agent executed a command, for a few of them I added that precise command for context. I’m positive that the log messages are simply summaries of the tokens that had been really happening behind the scenes, as a result of the messages are approach too brief to symbolize the complete “pondering” the mannequin should have been going via.

Looking for the related code with plenty of grep

Message Command (samples) Notes
I must seek for “category-to-human-readable” to find the place to make adjustments for the frontend labels. grep -R "human readable" -n  
I’ll search for any mentions of “class” within the challenge.    
Grep output is huge due to node_modules; I’ll restrict it to src as an alternative.    
I’ll seek for “to human” within the src listing to search out related references.    
I’ll open and test index.js to see what’s inside.    
I’m checking if the category-to-human-readable transformation is dealt with in _navigation_items or elsewhere.    
I’m going to search for “human readable” to get extra information on the subject. grep -R "human-readable" -n ui/src | head  
I’m wondering if there’s a operate for changing classes into one thing extra readable.    
Filtering the search to simply the “src” folder to keep away from node_modules noise.   second time it’s operating into this, didn’t ‘keep in mind’
I’ll search for a operate like “toHumanReadable”. Let’s see what I discover.    
I’m checking the entire repo in case the logic is within the backend or a library. grep -R "Human" -n | head  
I’ll restrict the scope to app/ and ui/src to keep away from the big node_modules folder.   third time it’s operating into this, didn’t ‘keep in mind’
I believe the logic may be lacking, so I’ll test _navigation_items and different modules for classes. grep -R "human" app -n | head  
I believe it’s time to look a bit deeper. Let’s dive in and discover. grep -R "human" app | wc -l To “look deeper”, it searches for “human” once more, however pipes it into wc as an alternative of head?

Lastly, it’s getting nearer! The labels had been beforehand crudely capitalized by way of CSS, it finds that

Message Command (samples) Notes
I’m checking for references to “capitalize” or class transformation within the frontend. Output:
root@0c5de6379b32:/workspace/haiven# grep -R "capitalize" -n ui/src | head
ui/src/pages/index.js:250: className="capital
ize"
ui/src/kinds/globals.css:1915:.capitalize {
ui/src/kinds/globals.css:1916: text-transform: capitalize;
ui/src/kinds/globals.css:1931: text-transform: capitalize;
 
I’ll test across the Tag part in index.js.    
Tag show capitalizes phrases incorrectly resulting from hyphen or camelCase; I’ll take a look at filter classes.    

Now it’s beginning to test for extra related code within the app folder, the place the backend is. It doesn’t discover something, which is appropriate, there’s nothing related there

Message Command (samples) Notes
I’ll test the repo for a way classes are formatted, specializing in hyphens and camelCase. grep -R "classes" -n app | head  
Time to strive a brand new search! grep -R "shopper" -n app | head  
I’ll take a more in-depth take a look at the prompts within the check information. grep -R "classes:" -n app/checks | head Why?
It seems just like the check information has restricted classes. I’ll test the docs for any variations. grep -R "client-research" -n  
I’ll begin by opening the information to take a more in-depth look. sed -n '1,100p' ui/src/app/_navigation_items.js  

Now it’s going again to looking within the ui folder – it discovered the CSS beforehand, and is now searching for present code that it might probably reuse to resolve the duty. That’s nice, as a result of we certainly have already got an analogous operate, and it finds it:

Message Command (samples) Notes
I would like a operate to transform tags like “client-research” to “Consumer Analysis” for filters. grep -R "to.*Readable" -n ui/src | head  
I’m opening the toReadableText operate inside _dynamic_data_renderer.js to discover it.    
I’m shifting via the web page to get the small print I would like.    

It now finds a niche within the present operate’s implementation:

Message Command (samples) Notes
I see that hyphens aren’t dealt with by the operate. I would like to regulate it for hyphens.    
I’ll modify toReadableText to deal with hyphens, guaranteeing correct capitalization and spacing. Let’s test checks!   It really didn’t test any checks
I’ll test _dynamic_data_renderer.js to look at toReadableText and modify it for hyphen-case.    
I’ll test checks/_sidebar.check.js to evaluation the associated classes there.    
I’ll test different information to see if toReadableText seems wherever.    
I’ll test if _sidebar or others include a toReadableText operate.    

Replace the check for the operate that it desires to alter:

Message Command (samples) Notes
I’ll modify the operate to deal with hyphen-case, then replace checks to mirror that.    
I’ll test the check file after line 36 to make sure hyphen-case is roofed.    
I’ll scroll via traces 60 to 120 to look at the remainder of the file.    
I’m scrolling the remainder to seize all of the related info.    
I’ll add checks for hyphen-case and replace toReadableText, together with modifying index.js for classes.    
I’ll modify _dynamic_data_renderer.js and index.js to make use of toReadableText and replace checks. git standing --short  

You may configure some atmosphere startup instructions in Codex, I had configured that to be yarn set up, which led to the next:

Message Command (samples) Notes
There are untracked .yarn/ and .yarnrc information. I’ll test and clear them up.    
I’ll test the foundation of ‘ui’ and take away any pointless Yarn 4 entries.    
I’ll take a look at the commit historical past to see if these .yarn information had been added later. git log --oneline -n 1  
I’ll evaluation the repository’s .gitignore to verify if Node modules are excluded. grep yarn .gitignore  
I see no entry for .yarn or .yarnrc. I’ll test and take away them if wanted. cat ui/.gitignore  
I’ll test if I can take away .yarn or .yarnrc information since they shouldn’t be dedicated.    
It seems like yarn.lock adjustments had been made. Time to reset to HEAD.    

Precise code adjustments:

Message Command (samples) Notes
Time to switch the code. I’ll start the mandatory updates now. sed -n '1,30p' ...  
I’m going so as to add a hyphen to the mandatory a part of the code.    
I’m going to make adjustments to the index.js file now.    
I’ll import toReadableText and begin utilizing it within the code.    
I’ll replace index.js to import toReadableText and modify the _dynamic_data_renderer checks.    
I would like to switch {tag} with {toReadableText(tag)} for higher rendering.    
I’ll check out the variations to higher perceive the adjustments. git diff  
I’ll evaluation the adjustments in index.js to see what’s been modified.    
I’ll add a brand new check for hyphenated instances in _dynamic_data_renderer.check.js.    
I’ll contemplate inserting a check after line 35.    

Working our code linter subsequent, good:

Message Command (samples) Notes
I’ll format the code utilizing Prettier as instructed. cd ui && npx prettier -w ... Prettier is talked about within the AGENTS.md. It appears to run prettier efficiently, although not one of the information had been modified
I’ll evaluation the logs to collect extra info.    

Attempting to run the checks – unsuccessfully:

Message Command (samples) Notes
I’ll run the yarn checks to test if all the pieces’s working effective.    
Assessments would possibly’ve been cached or want community—output’s empty, so I’ll test the log.    
The lockfile isn’t up to date. I’ll strive operating ‘yarn set up’ because the atmosphere permits it.    
The atmosphere is offline, so yarn set up can’t be run, however I see a node_modules folder.    
I see node_modules are already put in. I’ll test the log for why checks failed.    
The error occurs as a result of Yarn 4 depends on .yarn and .yarnrc, which we eliminated.   ?
It seems like .yarnrc.yml isn’t tracked. I’ll additionally test .yarn for monitoring.    
I’m double-checking the bundle.json to see if “haiven-ui” is the proper title.   ?
I’ll test the Node model to verify if it’s 18 or 20 by operating node -v.   bizarre, the node model laid out in bundle.json is 22.6
I believe switching to npx vitest run might repair the error. Let’s strive that.    
The output is lengthy—now I’ll seize the final abstract traces. Error: Not applied: window.getComputedStyle(elt, pseudoElt)  
The output is just too lengthy, so I’ll extract the important thing factors for a abstract.    

Happening a tangent about organising the venv, which is completely pointless as a result of it solely plans adjustments for frontend code:

Message Command (samples) Notes
The checks failed resulting from case variations, however now I’ll activate the digital atmosphere.   AGENTS.md comprises directions to activate venv for the Python backend, however we’re within the frontend right here, so…
Hmm, the .venv isn’t right here. I ought to test if it wants creation or already exists.    
It seems just like the .venv listing is lacking. Let’s evaluation AGENT’s directions fastidiously.    
The atmosphere appears offline, however there may be a script to arrange dependencies domestically.    
I can’t run “poetry set up” offline, however I’ll test the .cursor folder for dependencies.    
I can’t run backend checks with the present setup, however I’ll strive pytest anyway.    

Gave up on the checks, now wrapping up the adjustments:

Message Command (samples) Notes
Assessments failed resulting from lacking dependencies. Now, I’ll test standing and proceed with committing.    
I believe the .yarnrc.yml was left over from a earlier yarn set up. Eradicating it.    
I’ll seize the related file traces for the citations now.    
I’ll get the encircling line vary for the adjustments in index.js. nl -ba ui/src/pages/index.js | sed -n '12,28p'  
I’ll seize the related traces round these adjustments now.    
It’s time to finalize the PR message and confirm the commit.    
UI checks failed resulting from atmosphere points. I’ll reference the final failure traces. Performed!    

Screenshot of the final results view in OpenAI Codex

Right here is the complete pull request created by Codex.

Observations

I discovered it attention-grabbing to see that Codex, and many of the different coding assistants I’m utilizing, are resorting an increasing number of to easy textual content search to search out related code. Within the log above you see how Codex goes via a bunch of search phrases with grep, to search out related items of code (“human”, “human readable”, “humanReadable”, …). The rationale why I discover it attention-grabbing is as a result of there have been a whole lot of seemingly extra subtle code search mechanisms applied, like semantic search over codebase indices with vectors / embeddings (Cursor, GH Copilot, Windsurf), or utilizing the summary syntax tree as a place to begin (Aider, Cline). The latter remains to be fairly easy, however doing textual content search with grep is the best doable.

It looks as if the device creators have discovered that this straightforward search remains to be the best in any case – ? Or they’re making some type of trade-off right here, between simplicity and effectiveness?

The distant dev atmosphere is vital for these brokers to work “within the background”

Here’s a screenshot of Codex’s atmosphere configuration display (as of finish of Could 2024). As of now, you possibly can configure a container picture, atmosphere variables, secrets and techniques, and a startup script. They level out that after the execution of that startup script, the atmosphere is not going to have entry to the web anymore, which might sandbox the atmosphere and mitigate a few of the safety dangers.

Screenshot of Codex's environment configuration screen (as of end of May 2024); Shows configurable container image, environment variables, secrets, and a setup script.

For these “autonomous background brokers”, the maturity of the distant dev atmosphere that’s arrange for the agent is essential, and it’s a tough problem. On this case e.g., Codex didn’t handle to run the checks.

And it turned out that when the pull request was created, there have been certainly two checks failing due to regression, which is a disgrace, as a result of if it had recognized, it might have simply been capable of repair the checks, it was a trivial repair:

Screenshot of the Codex error messages indicating that it couldn't run the tests.

This explicit challenge, Haiven, really has a scripted developer security internet, within the type of a fairly elaborate .pre-commit configuration. () It will be excellent if the agent might execute the complete pre-commit earlier than even making a pull request. Nevertheless, to run all of the steps, it might must run

  • Node and yarn (to run UI checks and the frontend linter)
  • Python and poetry (to run backend checks)
  • Semgrep (for security-related static code evaluation)
  • Ruff (Python linter)
  • Gitleaks (secret scanner)

…and all of these need to be accessible in the best variations as properly, in fact.

Determining a clean expertise to spin up simply the best atmosphere for an agent is vital for these agent merchandise, if you wish to actually run them “within the background” as an alternative of a developer machine. It isn’t a brand new drawback, and to an extent a solved drawback, in any case we do that in CI pipelines on a regular basis. But it surely’s additionally not trivial, and for the time being my impression is that atmosphere maturity remains to be a problem in most of those merchandise, and the consumer expertise to configure and check the atmosphere setups is as irritating, if no more, as it may be for CI pipelines.

Answer high quality

I ran the identical immediate 3 occasions in OpenAI Codex, 1 time in Google’s Jules, 2 occasions domestically in Claude Code (which isn’t totally autonomous although, I wanted to manually say ‘sure’ to all the pieces). Although this was a comparatively easy job and answer, turns on the market had been high quality variations between the outcomes.

Excellent news first, the brokers got here up with a working answer each time (leaving breaking regression checks apart, and to be sincere I didn’t really run each single one of many options to verify). I believe this job is an efficient instance of the categories and sizes of duties that GenAI brokers are already properly positioned to work on by themselves. However there have been two facets that differed by way of high quality of the answer:

  • Discovery of present code that may very well be reused: Within the log right here you’ll discover that Codex discovered an present part, the “dynamic information renderer”, that already had performance for turning technical keys into human readable variations. Within the 6 runs I did, solely 2 occasions did the respective agent discover this piece of code. Within the different 4, the brokers created a brand new file with a brand new operate, which led to duplicated code.
  • Discovery of a further place that ought to use this logic: The workforce is presently engaged on a brand new characteristic that additionally shows class names to the consumer, in a dropdown. In one of many 6 runs, the agent really found that and recommended to additionally change that place to make use of the brand new performance.
Discovered the reusable code Went the additional mile and located the extra place the place it must be used
Sure Sure
Sure No
No Sure
No No
No No
No No

I put these outcomes right into a desk for instance that in every job given to an agent, now we have a number of dimensions of high quality, of issues that we need to “go proper”. Every agent run can “go incorrect” in a single or a number of of those dimensions, and the extra dimensions there are, the much less possible it’s that an agent will get all the pieces executed the best way we would like it.

Sunk value fallacy

I’ve been questioning – let’s say a workforce makes use of background brokers for any such job, the forms of duties which are type of small, and neither necessary nor pressing. Haiven is an internal-facing utility, and has solely two builders assigned for the time being, so any such beauty repair is definitely thought-about low precedence because it takes developer capability away from extra necessary issues. When an agent solely type of succeeds, however not totally – during which conditions would a workforce discard the pull request, and during which conditions would they make investments the time to get it the final 20% there, although spending capability on this had been deprioritised? It makes me surprise in regards to the tail finish of unprioritised effort we would find yourself with.

Leave a Reply

Your email address will not be published. Required fields are marked *