Skip to content

Skip bare "# AGENTS.md instructions" codex heading in session titles (#339) - #355

Merged
Yuandi (DDKinger) merged 1 commit into
mainfrom
dev/yuazha/codex-bare-agents-md-title
Jun 24, 2026
Merged

Yuandi (DDKinger) merged 1 commit into
mainfrom
dev/yuazha/codex-bare-agents-md-title

Conversation

@DDKinger

Copy link
Copy Markdown
Contributor

Summary

Completes the fix for #339. Codex session rows could still be titled with the
literal # AGENTS.md instructions heading instead of the user's prompt.

PR #288 added codex_user_text_is_synthetic to skip codex's injected AGENTS.md
block, but it only matched the project form `# AGENTS.md instructions for

` (codex `UserInstructions::body` with `directory = Some`). A **global** `~/.codex/AGENTS.md` (`directory = None`) makes codex emit the **bare** `# AGENTS.md instructions` heading, which the `for `-only check missed — so it still won the title and defeated the phantom-session check. This is why the issue reproduced only with a global AGENTS.md present; a project-AGENTS.md repro looked already-fixed.

What changed

  • tools/wta/src/history_loader.rs — codex_user_text_is_synthetic now
    matches the # AGENTS.md instructions marker as a whole heading line:
    followed by end-of-text, a newline (\n/\r), or for. Both the project
    and bare/global forms are skipped, while a real prompt that merely opens with
    the phrase mid-line (e.g. # AGENTS.md instructions are unclear…) is left
    intact. Used by both the title scan (codex_title_from_file) and the phantom
    check (codex_session_has_real_content).
  • Regression tests — a direct predicate test (both forms + false-positive
    guard) and two end-to-end load_codex tests (bare heading must not win the
    title; a bare-only session is phantom).
  • doc/specs/hybrid-agent-session-tracking.md — documents both marker forms.

Test plan

  • cargo test --manifest-path tools/wta/Cargo.toml — 992 passed, 0 failed
    (3 new + the 2 existing AGENTS.md tests).
  • cargo build --manifest-path tools/wta/Cargo.toml — clean (warnings only).

Manual repro / verify

ni $env:USERPROFILE\.codex\AGENTS.md -Force -Value "be concise"
# open a codex shell pane, send a prompt, then /sessions
# before: title "# AGENTS.md instructions"   after: the real prompt

Fixes #339.

codex_user_text_is_synthetic only matched the project form
"# AGENTS.md instructions for <dir>" (codex UserInstructions::body with
directory=Some). A global ~/.codex/AGENTS.md (directory=None) makes codex
emit the bare "# AGENTS.md instructions" heading, which the "for <dir>"-only
check missed -- so it still won the codex session title and defeated the
phantom-session check. This is the remaining half of #339 (a project-AGENTS.md
repro looked already-fixed by PR #288).

Match the marker as a whole heading line (followed by end-of-text, a newline,
or " for <dir>") so both the project and bare/global forms are skipped, while a
real prompt that merely opens with the phrase mid-line is left intact. Adds a
predicate test (both forms + false-positive guard) and two load_codex
end-to-end tests, and updates the hybrid-agent-session-tracking spec.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 24, 2026 09:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the fix for #339 by ensuring Codex session title extraction ignores Codex-injected AGENTS.md instruction headings in both the project-scoped (# AGENTS.md instructions for <dir>) and global/bare (# AGENTS.md instructions) forms, so sessions are titled from the user’s real prompt (and bare-only sessions are treated as phantom/empty).

Changes:

  • Extend codex_user_text_is_synthetic to recognize the bare # AGENTS.md instructions heading when it appears as a whole heading line (end-of-text / newline / for).
  • Add regression coverage: predicate-level tests plus end-to-end load_codex tests for (a) title selection and (b) phantom-session detection.
  • Update design documentation to describe both injected marker forms and the “whole heading line” matching rule.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tools/wta/src/history_loader.rs Expand synthetic-record detection for Codex AGENTS.md injections and add regression tests to prevent title/phantom regressions.
doc/specs/hybrid-agent-session-tracking.md Document both Codex AGENTS.md marker forms and how the shared synthetic-skip logic handles them.

@DDKinger
Yuandi (DDKinger) merged commit 60371f5 into main Jun 24, 2026
8 of 10 checks passed
Kai Tao (vanzue) added a commit that referenced this pull request Jul 3, 2026
Second review pass over the release checklist against the v0.1.2 release notes:

- Added a [new] coverage marker to the legend and tagged all 12 genuinely-new v0.1.2 test cases with it (the two reworded existing cases — F5 refresh, ACP-sourced historical — are corrections, not new cases, so they stay untagged).
- Added 5 more previously-missing cases surfaced by a closer read:
  - FRE execution-policy detection is correct / no false-block on probe timeout (#336/#338/#309)
  - wta-master death is a consistent degraded state requiring /restart, no split-brain (#329)
  - Session titles are clean (no bare '# AGENTS.md instructions' heading) (#355)
  - Focus brings the target window to the foreground (#353)
  - Agent-created terminals inherit the active pane profile (#366, closes #351)

Co-authored-by: Copilot <[email protected]>
Kai Tao (vanzue) added a commit that referenced this pull request Jul 3, 2026
Kai Tao (vanzue) added a commit that referenced this pull request Jul 3, 2026
* docs(release-check-list): sync with v0.1.2 features

Reviewed the release checklist against the v0.1.2 release notes and fixed two outdated statements plus added seven missing test cases for new features.

Outdated statements corrected:
- Session view refresh: now F5 on-demand re-scan (incl. WSL distros started after launch), not gated on hooks (#344).
- Historical state: history is now sourced from ACP session/list, not on-disk file parsing (#365).

Missing test cases added:
- Alt+V clipboard image paste into agent chat (#354)
- GitHub Enterprise Copilot sign-in (#362)
- Bash/WSL shell integration incl. set -u safety (#340)
- Shells self-report identity via OSC 9001;ShellType + nested-shell autofix targeting (#345)
- Environment-aware answers/fixes: investigate PATH before answering/autofixing (#306)
- WSL distro sessions visible and resumable in the correct distro (#323)
- Agent panes not persisted into saved window layout (#360/#275)

Co-authored-by: Copilot <[email protected]>

* docs(release-check-list): tag new v0.1.2 cases with [new] + add 5 more

Second review pass over the release checklist against the v0.1.2 release notes:

- Added a [new] coverage marker to the legend and tagged all 12 genuinely-new v0.1.2 test cases with it (the two reworded existing cases — F5 refresh, ACP-sourced historical — are corrections, not new cases, so they stay untagged).
- Added 5 more previously-missing cases surfaced by a closer read:
  - FRE execution-policy detection is correct / no false-block on probe timeout (#336/#338/#309)
  - wta-master death is a consistent degraded state requiring /restart, no split-brain (#329)
  - Session titles are clean (no bare '# AGENTS.md instructions' heading) (#355)
  - Focus brings the target window to the foreground (#353)
  - Agent-created terminals inherit the active pane profile (#366, closes #351)

Co-authored-by: Copilot <[email protected]>

* test(e2e): add master-death degraded-state integration test (#329); drop rolled-back WSL session checklist item

Adds Feature.AgentMasterDeath.Tests.ps1: kills this app's wta-master out from under a live helper and asserts the full #329 contract end-to-end — the pane leaves Connected, the / popup is filtered to only /restart, NO master is silently respawned while degraded (anti-split-brain), and /restart brings up exactly one fresh master and reconnects. Verified passing live against the deployed dev package.

Also removes the '[new] WSL distro sessions are visible and resumable' checklist item (#323) since WSL in-distro session support is being rolled back for v0.1.2, and drops the WSL example from the F5 refresh item to match.

Co-authored-by: Copilot <[email protected]>

* Address Copilot review: tighten master-count assertion and clarify Alt+V behavior

- Feature.AgentMasterDeath.Tests.ps1: assert exactly one wta-master while connected (-Be 1, was -BeGreaterThan 0) so the connected-state gate itself catches a split-brain regression. Re-verified passing live.

- release-check-list.md: correct the Alt+V item — Alt+V queues the image until the next prompt, and an unsupported agent / empty clipboard surfaces a clear system message rather than being a silent no-op.

The [WSL-<distro>] raw-angle-bracket comment is already resolved: that checklist item was removed with the WSL session rollback.

Co-authored-by: Copilot <[email protected]>

* Address Copilot review round 2: block /stop in degraded popup test, release-agnostic [new] marker, spelling fix

- Feature.AgentMasterDeath.Tests.ps1: add /stop to the blocked-slash-command list so a regression that offers /stop while transport-lost is caught (it's a real CommandKind::Stop). Re-verified passing live.

- release-check-list.md: reword the [new] marker in release-agnostic terms and say when to clear it (was hard-coded to v0.1.2); fix forbidden spelling non-existent -> nonexistent (check-spelling CI).

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
@DDKinger
Yuandi (DDKinger) deleted the dev/yuazha/codex-bare-agents-md-title branch July 17, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex agent sessions show AGENTS.md instructions instead of actual session titles

3 participants