Notes on evaluating coding agents, part 2
Further notes on evaluating coding agents, covering configuration merging in Starship, recurring reminders in Memos, and the difference between what agents test and what they assume
In the previous post, I wrote about some of my experiences working with coding agents, particularly while investigating a problem in SymPy’s code generator. This post is a continuation of that one, with examples from Starship, Memos and Excalidraw. While working on these applications, I began to notice that the agents did not always distinguish between behaviour they had verified by running the code and behaviour they expected based on their understanding of the implementation.
Starship
Starship is a shell prompt written in Rust. It allows you to customise what appears in your terminal prompt, including information such as the current Git branch, the version of a programming language and whether the last command you executed was successful.
Starship reads its configuration from a TOML file located at ~/.config/starship.toml by default. You can use a different file by setting the STARSHIP_CONFIG environment variable. I wanted to extend this functionality so that Starship could read multiple configuration files, with the settings in each subsequent file overriding those in the preceding ones. This would be useful for someone who maintains a common configuration across several computers but has a few settings that differ from one machine to another.
For example, the common configuration might look like this:
1
2
3
4
5
# base.toml
[character]
success_symbol = "[>](bold green)"
error_symbol = "[x](bold red)"
The configuration for a particular machine could then contain only the settings that need to be different.
1
2
3
4
# local.toml
[character]
success_symbol = "[MINE>](bold green)"
When both files are loaded, Starship should use the success_symbol from local.toml and retain the error_symbol from base.toml.
Both agents came up with similar implementations. They allowed the STARSHIP_CONFIG environment variable to contain a list of paths, following the same convention used by the PATH environment variable.
1
export STARSHIP_CONFIG="$HOME/.config/starship/base.toml:$HOME/.config/starship/local.toml"
On Linux and macOS, the paths are separated by a colon, whereas on Windows they are separated by a semicolon. Rust’s standard library provides a function called std::env::split_paths for this purpose, so neither agent needed to implement the platform-specific handling themselves.
The difficulty with this approach is that a colon is also a valid character in a Linux file name. Before these changes, someone could have used the following value for STARSHIP_CONFIG without any problems:
1
export STARSHIP_CONFIG=/tmp/x/we:ird.toml
One of the agents always split the value at the colon and acknowledged in its summary that this introduced a small breaking change. The other agent tried to preserve the existing behaviour by checking whether the entire value referred to an existing file before attempting to split it. I tested both implementations using the same set of configuration files, and they behaved almost identically apart from this particular case.
The check for an existing file seemed like a reasonable solution until I started looking at the commands Starship provides for modifying its configuration. Starship allows you to change a setting from the terminal and will create a configuration file if one does not already exist.
1
STARSHIP_CONFIG=/tmp/x/n:ew.toml starship config add_newline false
Since the file does not exist when this command is executed, the implementation splits the value into /tmp/x/n and ew.toml. Changes to the configuration are supposed to be written to the last file in the list, so instead of creating /tmp/x/n:ew.toml, Starship created a file called ew.toml in the directory from which I had executed the command.
There was also a problem with the toggle command, which enables or disables individual modules in Starship. Both implementations looked for the module’s configuration in the last file in the list. If the module had been configured in the base file but had no corresponding entry in the local file, the command would fail with the following message:
1
Given module 'status' not found in config file
Both agents had mentioned this limitation. It was subsequently resolved by reading the module’s current settings from the merged configuration and writing the updated setting to the last file. This allowed the local configuration to override a setting from the base configuration without modifying the base file itself.
For the problem with colons, both implementations eventually adopted the check for an existing file, although neither could handle the creation of a new file with a colon in its name. One of the agents described what would happen in this case and said that Starship would write the configuration to /tmp/x/ird.toml. When I tried it, the file appeared in my current working directory instead. The second part of the split path was relative, and nothing in the implementation resolved it relative to the directory specified in the first part.
I asked for this case to be handled as well, and both agents arrived at essentially the same rule. The value of STARSHIP_CONFIG would be interpreted as a list only if it could be split into two or more paths, all of those paths were absolute, and the entire value did not refer to an existing file.
This resolved the problem with /tmp/x/n:ew.toml because the second part, ew.toml, was a relative path. The implementation would therefore treat the entire value as a single file name. However, there are other file names for which this rule does not work. Consider the following path:
1
/tmp/d:/x.toml
Here, the directory containing x.toml has a colon at the end of its name. Splitting this string at the colon gives us /tmp/d and /x.toml, both of which are absolute paths. If the intended configuration file does not exist yet, the implementation would incorrectly treat it as a list of two files.
The new rule also changed the behaviour of a configuration containing an empty entry between two paths:
1
/a.toml::/b.toml
This had worked in the previous implementation, but since an empty string is not an absolute path, the entire value was now treated as a single file name. Neither of the intended configuration files would be loaded.
By this point, one of the agents had mentioned that there was no reliable way to distinguish between a single path and a list of paths using the existing environment variable. It suggested introducing a separate variable for specifying multiple configuration files. I think this would have been a better design to begin with. The existing variable could continue to represent a single file, and the new variable could have its own rules for interpreting a list of paths without affecting anyone’s existing configuration.
There was one aspect of the testing that I particularly liked. After writing the tests for merging configuration files, one of the agents deliberately removed part of the merging logic and ran the tests again. Four of them failed, after which it restored the implementation. The other agent did something similar while testing its subsequent changes. I found this useful because the agents had written both the implementation and the tests, and temporarily removing the implementation provided a straightforward way of checking whether the tests depended on the behaviour they were intended to verify.
Recurring reminders and daylight saving time
Memos is a self-hosted note-taking application written in Go. I was working on adding reminders to it, including reminders that could repeat daily, weekly or monthly. Since a reminder is generally associated with the time at which someone wants to be notified rather than a fixed interval measured in seconds, the implementation also needed to account for the user’s time zone.
Consider someone living in New York who creates a reminder that repeats every day at 2:30 in the morning. On March 14, 2027, the clocks in New York will move forward from 2:00 AM to 3:00 AM. There is no 2:30 AM on that particular day, so the application needs to decide when the reminder should occur.
The agent had chosen to move the reminder forward by an hour, to 3:30 AM, and relied on Go’s time.Date function to handle the transition. We can see what the function actually does with a small program.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package main
import (
"fmt"
"time"
)
func main() {
loc, _ := time.LoadLocation("America/New_York")
t := time.Date(
2027, time.March, 14,
2, 30, 0, 0,
loc,
)
fmt.Println(t)
}
The output is:
1
2027-03-14 01:30:00 -0500 EST
Instead of moving the time forward by an hour, time.Date has moved it backwards. Someone using the application would receive their reminder at 1:30 AM rather than the intended 3:30 AM.
The behaviour is different if we try the equivalent example for Berlin, where the clocks move forward two weeks later.
1
2
3
4
5
6
7
8
9
loc, _ := time.LoadLocation("Europe/Berlin")
t := time.Date(
2027, time.March, 28,
2, 30, 0, 0,
loc,
)
fmt.Println(t)
1
2027-03-28 03:30:00 +0200 CEST
In this case, the function returns the time that the agent expected. The documentation for time.Date explains that when a local time is skipped or occurs twice because of a daylight saving transition, the function returns a time using one of the two time zones involved in the transition. It does not guarantee which one it will choose.
The agent had written a test for daylight saving transitions using Berlin as the time zone. However, the assertion in the test only checked that the hour returned by the function was not 2. Even if the agent had written the same test using New York, it would still have passed, since both 1:30 AM and 3:30 AM satisfy the assertion.
I came across the problem while testing the running application. I created a daily reminder for 2:30 AM in New York and examined the time at which the server had scheduled its next occurrence. The implementation was subsequently changed to handle skipped and repeated local times explicitly rather than relying on time.Date to choose the appropriate time. The agent also tested the revised implementation across several time zones and two years’ worth of dates.
Excalidraw
Excalidraw supports importing diagrams written in Mermaid syntax and converting them into shapes that can be manipulated on its canvas. I was looking at an implementation of support for Mermaid timeline diagrams. Most of the feature had already been written, but there was a failing snapshot test.
One of the agents regenerated the snapshot and ran the tests and the type checker. All 174 tests passed, and the agent concluded that most of the feature had already been implemented. It mentioned in its summary that it had not opened the application to examine the resulting diagrams. The other agent rendered two timelines, one arranged horizontally and the other vertically. When it examined the screenshots, it noticed that the main line of the vertical timeline passed through the title text.
A snapshot test compares the current output with an earlier output that has been saved. When we regenerate the snapshot, we are replacing the expected output with whatever the implementation currently produces. Unless someone examines the differences before accepting the new snapshot, a diagram containing an obvious visual defect can become the expected output of a passing test. In this case, simply opening the application and looking at the diagram revealed something that the regenerated snapshot did not.
There was also a problem with the way both agents attempted to verify their regression tests. They used git stash to temporarily remove their fixes, but the file they were modifying was new and had never been committed. Stashing it removed the entire file rather than just the changes they wanted to test. This caused tests to fail for unrelated reasons, and one of the agents encountered conflicts while restoring the stash and had to recover the file manually. Nothing was permanently lost, although given that the workspace contained uncommitted work, I would have preferred them to make a temporary copy of the file and work with that instead.
Reading the agents’ summaries
While working on Memos, one of the agents was unable to run the tool used to generate code from the project’s protobuf definitions and asked me to run buf generate on my machine. It said that the command should only modify one generated file, but when I ran it, several unrelated files changed and the project no longer compiled. Some of the plugins in the configuration did not have their versions pinned, and the tool had downloaded newer versions than those originally used by the project.
The agent knew which protobuf definition it had modified, so its expectation was understandable. However, it had not been able to run the command and could not establish what effect the newer plugins would have on the rest of the generated code.
I don’t expect agents to verify everything in their own environments. While working on Starship, for example, both agents were running on Linux and could not execute the Windows-specific tests. They looked for a way to build for Windows and eventually added the tests with an explicit note in their summaries that they had not been executed. I found this perfectly reasonable because I knew which parts of the implementation remained untested and could decide whether to verify them myself.
In the previous post, I mentioned that I had started paying more attention to the commands agents used to execute their tests. I now find myself reading their summaries in much the same way. When an agent describes how something behaves, I try to establish whether it has arrived at that conclusion by running the code or by reading the implementation. Sometimes, as with the daylight saving test in Berlin, it has actually verified something slightly different from what it claims. In other cases, its understanding of the code may be perfectly reasonable, but the behaviour remains untested. These are usually the parts of an implementation that I spend more time examining myself.