Original source pages and recordings require authorized access. The full article text here is public.
The practice is turning agent failures into better tooling: capture the exact terminal state, feed it back into the agent or plugin workspace, patch for that fail case, then verify with hard evidence instead of trusting a happy-sounding completion message. John also zooms out into a boundary model: keep worker agents narrow, isolated, and tool-limited; let a context-rich orchestrator coordinate them; and aggressively reduce context for single-purpose daemon-style tasks.
Working outcomes
- Extract terminal pane text in CMUX as machine-readable context
- Build self-improvement error loops behind log-based deterministic gates
- Define natural-language contract boundaries and prune context
Concepts and consequences
Terminal text extraction as context
John shows a CMUX shortcut, Cmd-Opt-Shift-J in his setup, that takes the current terminal session and opens it as plain selectable text in an editor-like pane. Instead of fighting terminal scrollback, colors, and selection behavior, he copies the exact failure state and uses it as agent context.
Why it matters: The fastest debugging loop starts with the real failure, not a vague summary of what you think happened.
Self-improvement error loops
When a plugin or hook fails, John copies the failed session text and asks the agent to explain why the plugin failed in that scenario and how to account for it next time. The point is not just to fix one run, but to use the exact fail case to harden the tool or workflow.
Why it matters: Tooling compounds when each failure leaves behind a stronger hook, workflow, or guardrail.
Log-based deterministic gates
John's default answer to verification is to write logs or other artifacts to files. Depending on the project, those artifacts might show that a file was created, an API call happened, an object had the expected shape, timestamps were recorded, or multiple sessions produced comparable outputs. A main agent can wait for worker sessions to finish, inspect the logs and text output, and compare them against the criteria.
Why it matters: Agents are useful reviewers, but artifacts are the evidence. Logs make fix-verify loops inspectable instead of trust-based.
Natural-language contract boundaries
John frames modules, tools, and CLIs as boundaries that agents can own. A master orchestrator can hold broader project context and spin up focused agents, while each worker gets a narrow task, limited tools, and a clear English instruction payload. He compares this to API contracts, except the handoff can be natural language sent to an agent.
Why it matters: Narrow agents are faster, easier to inspect, cheaper to run, and less likely to get distracted by unrelated context.
Context pruning for low-latency daemons
The codex-daemons demo shows an advanced experiment in stripping agent startup context. John redirects the Codex home directory, symlinks the needed auth file, disables memories, MCP servers, web search, and Agents.md/project rules, and runs hyper-specific daemon commands on Codex Spark Low by default. He also shows SDK thread warm-up so the first prompt can skip several seconds of startup work.
Why it matters: For repetitive, well-scoped CLI-style tasks, less context can mean faster responses, lower quota pressure, and fewer distractions.
Reference tools and resources
codex-daemons
John's open-source project for low-context, single-purpose Codex daemon commands.
Use when: Reach for it when you want to study the virtual CODEX_HOME pattern, auth.json symlink approach, disabled context sources, Codex Spark Low usage, and warmed SDK thread pattern.
CMUX
The terminal and agent workspace John uses to run panes, capture terminal sessions as text, and coordinate agent workflows.
Use when: Reach for it when you want pane-based agent workspaces, terminal text capture, or agent-driven terminal/browser automation.
GitHub CLI
The GitHub command-line tool used as the target of John's Pro GH daemon example.
Use when: Reach for it when a narrow daemon or agent should perform GitHub-specific tasks such as summarizing recent commits.
Better Plugins / Ralph hook example
The workshop plugin-hook workspace John used to show a Python Ralph hook, local validation, and agent-driven scenario testing.
Use when: Reach for it when you want examples of building hooks, installing them into an agent environment, and verifying them against a few scenarios.
search: John Lindquist Better Plugins Ralph hook
Recommendations and best practices
- When an agent, hook, or plugin fails, capture the exact terminal output first; do not summarize from memory unless you have no other option.
- Use a repair prompt shape like: state the goal, paste the failure text after a colon, then ask the agent to explain why it failed and account for that case next time.
- Make verification concrete by writing logs or files that record what actually happened: API calls, object shapes, timestamps, terminal outputs, or whatever criteria your project requires.
- For multi-session verification, let the main agent wait for worker sessions to finish, inspect their logs and text outputs, and compare them against the criteria.
- Avoid giant all-knowing worker sessions for execution work. Keep the orchestrator context-rich, but make worker agents narrow, tool-limited, and easy to audit.
- Before fanning work out across agents, scope which tasks can be isolated, which tools each worker should use, and which boundaries define ownership.
- Treat CODEX_HOME redirection, auth.json symlinks, disabled memories/MCP/web search/Agents.md, model overrides, and warmed SDK threads as advanced experimental patterns; test what works in your own setup.
Practice and acceptance criteria
Practice capturing real failures, turning them into repair prompts, verifying work with artifacts, and designing narrow worker agents with clear boundaries.
Checklist
- Pick one local script, hook, or CLI workflow that occasionally fails and identify a real or intentionally created fail case.
- Run the scenario in CMUX or your terminal, then capture the exact terminal output as clean text using Cmd-Opt-Shift-J or an equivalent scrollback export.
- Write a repair prompt with three parts: the goal, the raw failure text after a colon, and an instruction to explain the failure and account for it next time.
- Add logging to the workflow that records what it actually did, such as relevant API calls, object shapes, timestamps when useful, outputs, or errors.
- Run a few scenarios or sessions that match the criteria you care about verifying.
- Use a supervisor prompt or verifier script to read the logs and text outputs, then compare them against your criteria instead of accepting the worker agent's completion message.
- Draft a natural-language contract for the worker agent: what it owns, which tools it may use, what inputs it receives, what outputs it must produce, and what context it does not need.
Failure Capture Drill
Difficulty: Easy
Break a small local script on purpose, capture the exact terminal failure as clean text, and use it to ask Codex to explain the cause and patch the code. Do not summarize the error manually.
Done when: The repaired script handles the original failure case, and your prompt includes the raw captured output rather than a vague description.
Log Comparison Gate
Difficulty: Medium
Add file logging to one hook or CLI workflow, then run three sessions or scenarios and save one log artifact per run. Include the facts your project needs to verify the run, such as an API call, object shape, result, error, timestamp, or terminal output.
Done when: A verifier or supervisor agent can read the log files and clearly compare each run against the expected criteria without relying on the worker agent's chat response.
Boundary Contract Map
Difficulty: Medium
Choose a feature in one of your projects and split the work into an orchestrator plus two or three narrow worker agents. For each worker, write its natural-language contract, allowed tools, out-of-scope areas, required inputs, and required outputs.
Done when: Another developer could read the map and know which agent owns each part of the work, where handoffs happen, and what context should be pruned from each worker.
Low-Context Daemon Prototype
Difficulty: Hard
Study or prototype a small wrapper around a CLI-style target such as GitHub CLI or CMUX. Isolate the agent context as much as your tooling allows: redirect the home/config context, symlink only the required auth/config if needed, disable extra context sources where possible, and compare behavior against your normal setup.
Done when: You can show a before-and-after comparison of startup context, speed, or focus, and you have documented which parts of the setup are experimental or hacky.
Questions to test understanding
A hook fails in a CMUX terminal pane and prints a long stack trace. What should you do first if you want the fastest useful self-improvement loop?
- A. Capture the exact terminal text and feed it back to the agent as context.
- B. Ask the agent to guess what probably happened from a short summary.
- C. Restart the session and hope the failure disappears.
- D. Install more tools into the agent environment before debugging.
Answer: A. The lesson emphasizes starting from the real failure state, not memory or vibes. Clean terminal extraction gives the agent precise evidence to explain and patch against.
What makes a log-based deterministic gate stronger than an agent's completion claim?
- A. The log file sounds more official than chat text.
- B. Logs can record inspectable facts that another process or supervisor can compare.
- C. Logs prevent all future bugs automatically.
- D. The worker agent cannot read log files, so it has less context to misuse.
Answer: B. John's default is to create artifacts agents can inspect: logs, files, timestamps, object shapes, API-call evidence, and session outputs. A supervisor can compare those artifacts instead of trusting a natural-language claim.
In this lesson's boundary model, what should the master orchestrator usually do?
- A. Run every task directly with every available tool.
- B. Hold broad project context, split work, and assign narrow tasks to isolated agents.
- C. Disable all logging so agents rely on reasoning alone.
- D. Give every worker the full repository, memories, browser access, and MCP servers.
Answer: B. The orchestrator keeps the big picture and coordinates work. Worker agents should be small, tool-limited, and scoped to clear natural-language contracts.
Why would a Codex daemon use a redirected home directory and disable memories, MCP servers, web search, and project rules?
- A. To make the agent more creative by hiding all instructions.
- B. To reduce startup context and keep a single-purpose daemon fast and focused.
- C. To bypass the need for authentication completely.
- D. To make logs unnecessary because the model has fewer distractions.
Answer: B. Context pruning removes baggage for repetitive, well-scoped tasks. John framed the codex-daemons setup as an advanced experiment involving a fake Codex home directory, an auth.json symlink, disabled context sources, and a low-reasoning default model.
Which prompt shape best matches the lesson's repair loop?
- A. Fix this, it failed somehow.
- B. Here is the goal, here is the exact failure text, explain why it failed and account for this case next time.
- C. Ignore the stack trace and rewrite the whole project from scratch.
- D. Tell me the issue is resolved after editing the first related file you find.
Answer: B. The useful loop combines goal, exact failure evidence, diagnosis, and durable workflow hardening. The point is not only to fix one bug, but to prevent the same class of failure from returning.
Reflection prompts
- Where in your current workflow are you still trusting an agent's claim instead of checking an artifact?
- Which agent tasks in your projects would get faster or safer if they had less context, not more?
- What log output would let an orchestrator compare multiple runs against your actual success criteria?
Further applications
- Build a tiny local failed-session library: save terminal captures into dated files, then use them as regression prompts when improving hooks.
- Prototype a deterministic gate for one workflow: run a few sessions or scenarios, write a log artifact for each run, and compare expected criteria versus actual outputs.
- Create a natural-language contract map for your project: list each module, the agent that owns it, the tools it may use, and the inputs and outputs it should exchange.
- Experiment with a single-purpose daemon around a demonstrated CLI-style target such as GitHub CLI or CMUX, and measure whether reduced context improves speed, focus, or reliability.
- Add logs, tracing, or telemetry around boundary crossings so an agent can inspect when work reached outside its intended scope.
Applied exercises
Exercise 1: Build a Manual Error-Recovery Loop
Objective: Practice stripping terminal artifacts and running a recovery loop using John's approach.
Steps: Intentionally break a local script or hook so it throws an active stack trace or error block in your terminal workspace.Use your environment's clean text export option (or the CMUX Cmd-Opt-Shift-J shortcut) to capture the raw error text without terminal escape characters.Draft an explicit repair prompt using John's structure: outline the overarching goal, paste the error after a colon separator, and instruct an agent to modify the code file to handle the edge case.
Exercise 2: Prototype an Isolated Virtual Environment Hack
Objective: Build a basic shell wrapper script that mimics the token-saving isolation strategy of codex-daemons.
Steps: Write a shell script wrapper for your local development tool of choice.Inside the script, temporarily override the tool's core path variable or home folder directory target (ENV_HOME) to a completely empty temporary directory (/tmp/isolated_sandbox).Explicitly symlink only your core API key configuration file into that temporary sandboxed folder.Run a test command through the wrapper. Verify that the agent no longer scans your main project's workspace rule files or local database histories, matching the clean-slate daemon setup.
Questions and answers
How do you make the verify half of a fix-verify loop something you enforce, not something the agent just claims it did? When an agent fixes a bug, what's the deterministic gate that proves it's fixed + didn't regress?
John recommends relying on structured logs written directly to disk. These files act as multi-agent-readable verification artifacts that track data shapes and API timing signatures. A supervisor agent can run parallel worker blocks, wait for completion, and compare files to programmatically confirm structural success without trusting the worker agent's natural language updates.
you use the word boundaries a few times, seems like you have a visual conceptual meta-framework to think about how to control and steer and keep tools and agents and plugins scoped properly, can you speak to this, your way of thinking?
John advises against loading too many marketplace tools into a single agent context. His approach uses a highly context-aware master orchestrator that manages project goals alongside hyper-isolated sub-agents running small token footprints. This forms natural language contract boundaries across layers, mimicking decoupled microservice modules.
Operational playbooks
Recording references
Visual reference index
- 03:34:58: CMUX shortcut changes active window layout into a clean plain text editor block.
- 03:36:12: Workspace view with terminal/log text and the live typing-game dashboard visible, useful for the self-improvement loop context.
- 03:38:22: IDE displays a custom python-based implementation file of a Ralph hook.
- 03:39:45: Dark terminal/editor view during the prompt-structure discussion; keep exact prompt-pattern claims tied to transcript evidence.
- 03:48:02: Terminal/browser workspace during the transition into codex-daemons; repository URL remains confirmed by chat.
- 03:49:48: Terminal logs screen view of the Pro GH utility streaming a low-latency commit overview.
- 03:52:12: Code display tracking the virtualized home directory environment overrides inside the daemon root folder.
- 03:53:15: Configuration block code showing flags explicitly setting memories, mcp, and web search options to false.
- 03:54:18: Orchestration logic view tracking background handshake mechanisms used to warm up active SDK execution threads.
- 03:55:38: Terminal workspace after the CMUX pane command, showing split-pane execution context.