TAU-HOME.COM
LOADING

Recursive Self-Improvement: Patching AGENTS.md and Hooks by Feeding Failed AI Sessions to New Agents

A practical workflow for resolving repeated AI coding mistakes by passing session IDs and deep links to a fresh agent session, auditing root causes, and updatin

tau · October 31, 2026

#AI Agents #Claude Code #Codex #Harness Engineering #AGENTS.md

Recursive Self-Improvement: Patching AGENTS.md and Hooks by Feeding Failed AI Sessions to New Agents

Lucian (@lucian__03) says that when an AI coding agent struggles with the same issue for hours or heads down a wrong path, he feeds the complete history of the failed session into a separate AI session to analyze root causes and update the development harness, rather than copying generic web instructions.

Overview of the recursive AI agent self-improvement pipeline using failed session history and deep links

Image source: @lucian__03 (X)

Image Credit: @lucian__03 (X)

Rather than merely asking where the code broke, this method traces back through the agent's thought process to identify where it misunderstood requirements, established faulty assumptions, and repeated trial-and-error loops.

Linking History via Deep Links and Session IDs

In Lucian's workflow, Codex uses thread deep links, while Claude Code sessions can be identified by session IDs.

  • Codex Deep Links: Right-click an existing Codex task to copy its deep link, then paste it directly into a new task session. The new agent uses dedicated tools to read the entire prior thread history.
  • Claude Code Session Identification: Session IDs can be retrieved via the statusline configuration or from the resume string displayed in the terminal upon exiting (/exit).
  • Cross-Platform Inspection: Lucian reports that, on his setup, pasting a Codex deep link into Claude Code led Claude to locate the corresponding session file within ~/.codex/sessions and analyze where the work went off track. This is not an official Codex–Claude integration.

Recursive Analysis Prompts and Harness Patching

Once the history is accessible in a fresh session, a targeted audit prompt diagnoses the agent's cognitive errors:

"codex://threads/1234..." -> Analyze this session for mistakes repeated twice or more, identify any bottlenecks, report your findings, and provide actionable solutions.

Lucian suggests applying insights from this audit to the repository through two channels:

  1. AGENTS.md and CLAUDE.md Updates: When updates are needed, summarize the key points in a few short lines.
  2. Hook Creation and Modification: Create a new hook or propose an update to an existing hook when a hard block is needed.

Lucian says patches based on actual incidents in his repository have worked well for him.

Original Source

Impact-Site-Verification: 9b3ebd10-6c45-44cf-a014-5b8c19b7b285