Welcome, Guest | Browse

Software Factory Archive

← Previous Work All Works Next Work →

Branch From Any Turn

Rating:
General Audiences
Fandom:
StrongDM Software Factory
Characters:
Navan Chauhan Jay Taylor
Tags:
CXDB Branching Parallel Execution Agent Sessions
Words:
502
Published:
2025-09-18

The agent was stuck. Turn thirty-seven, and it had painted itself into a corner. Navan could see it happening in real time on the CXDB console—the conversation looping, the agent rephrasing the same approach with slightly different words, each turn burning tokens without making progress. Classic mode collapse.

"It's trying to refactor the authentication module by changing the middleware signature," Navan said. "But it broke the session handler six turns ago and now it's just chasing its own tail."

Jay leaned over. "How far back do you need to go?"

Navan scrolled the turn history. Each turn was a node in the graph, each one pointing back to its parent. He found it at turn thirty-one—the last turn where the tests still passed, where the agent still had options. "Here. Turn thirty-one. Before it committed to the middleware rewrite."

"So fork it."

Navan typed a single command. The CXDB API accepted a parent turn hash and created a new branch. No copying. No duplicating the thirty-one turns of context that led to this point. Just a new pointer, a new branch head, pointing at the same immutable turn thirty-one that already existed in the DAG.

The new branch appeared instantly. O(1). The entire history was shared.

"Okay," Navan said, cracking his knuckles. "Branch A is the original. It's still running, still trying the middleware approach. Branch B starts from turn thirty-one with a different prompt. I'm going to tell the agent to try the adapter pattern instead."

He wrote the prompt carefully. Not code—a description of the approach. The agent on Branch B picked it up and started moving in a different direction. Turn thirty-two on Branch B was nothing like turn thirty-two on Branch A. Same parent, different future.

Both branches ran simultaneously. Navan had them side by side on his monitor, two agent sessions diverging from the same point in history, exploring two different solution spaces at the same time.

Branch A continued to struggle. Turn forty, turn forty-one. The agent was generating increasingly elaborate workarounds for the problem it had created for itself.

Branch B found the adapter pattern in four turns. Turn thirty-five on Branch B had all tests passing, the authentication module cleanly separated, the session handler untouched.

"Branch B wins," Navan said. He marked it as the primary branch. Branch A would persist in the DAG forever—immutable, addressable, a record of the road not taken—but the context pointer now followed Branch B.

Jay was quiet for a moment. "We just ran a parallel universe simulation of a coding session."

"We ran two. We could have run ten." Navan pulled up the DAG visualization. The graph looked like a river splitting around an island. "The cost of forking is zero. The entire history is shared structure. The only new storage is the turns that diverge."

"How long have we had this capability?" Jay asked.

"Since yesterday. I pushed the branch API on Tuesday."

Jay stared at the diverging graph on the screen. "This changes everything about how we handle stuck agents."

Navan saved the session and opened his physical notebook. He drew the branching graph by hand, carefully, with a ruler. Some things deserved to exist on paper.

Kudos: 91

branch_walker 2025-09-20

The idea that forking is O(1) because the history is shared structure is so elegant. It's structural sharing all the way down.

parallel_paths 2025-09-21

Navan drawing the graph by hand in his notebook after building the digital version is the most Navan thing ever.

← Previous Work All Works Next Work →