lazycodex icon indicating copy to clipboard operation
lazycodex copied to clipboard

[Bug][LazyCodex] $omo:ulw-plan also triggers full Ultrawork mode, compounding planning and subagent stalls

Open ameforce opened this issue 4 months ago • 2 comments

Summary

Invoking the planning-only Codex skill $omo:ulw-plan also activates the generic Ultrawork UserPromptSubmit hook. The hook searches the entire current prompt with /(?:ultrawork|ulw)/i, so the ulw inside the skill name causes a second, full <ultrawork-mode> directive to be injected.

The result is two overlapping contracts in one turn:

  • ulw-plan: planning consultant, stop at a decision-complete plan, never implement.
  • ultrawork: open a goal/notepad, create exhaustive update_plan state, fan out subagents, wait on dependent child barriers, verify, and continue until completion.

In the observed run, a bounded RCA-and-plan request remained active for about six hours with very little user-visible progress. Long Codex tool calls were a contributing trigger, but the deterministic LazyCodex routing collision caused a planning-only request to inherit the heavier execution workflow and its unbounded wait rules.

Environment

  • OS: Windows 11 Pro 10.0.26200 (build 26200)
  • Codex Desktop: 26.707.3748.0
  • Codex CLI: 0.142.4
  • Active plugin: omo@sisyphuslabs 4.16.2
  • Also verified against current LazyCodex main at bb8764ca1754148ca56478d433c42b91c550e0f4 (marketplace 4.16.3 sync)
  • Node.js used for the packaged-hook probe: 24.11.1

Repository Decision

This report belongs in code-yeongyu/lazycodex because the confirmed defect is in the Codex-specific Ultrawork UserPromptSubmit hook shipped by LazyCodex. Upstream Codex issues may explain individual long tool calls or child-result loss, but upstream Codex does not decide that $omo:ulw-plan should receive <ultrawork-mode>.

Related but not duplicate:

Reproduction

From plugins/omo/components/ultrawork in either the installed 4.16.2 payload or current 4.16.3 source:

printf '%s\n' '{"hook_event_name":"UserPromptSubmit","prompt":"$omo:ulw-plan RCA and improvement plan only"}' \
  | node dist/cli.js hook user-prompt-submit \
  | rg -o '<ultrawork-mode>'

Actual output:

<ultrawork-mode>

Control prompt without ulw returns zero bytes:

printf '%s\n' '{"hook_event_name":"UserPromptSubmit","prompt":"RCA and improvement plan only"}' \
  | node dist/cli.js hook user-prompt-submit \
  | wc -c
0

The same detector also injects Ultrawork for non-activation substrings such as refactor ulw_helper.ts. Current tests explicitly pin 하이ulw and ulw_helper.ts as positive triggers.

Expected

  • An explicit $omo:ulw-plan invocation should load the selected planning skill without also injecting the generic full Ultrawork execution contract.
  • Explicit skill routing should take precedence over substring keyword routing.
  • Identifiers such as ulw_helper.ts should not activate Ultrawork.
  • A user should be able to request planning only and reliably reach the approval/plan handoff stop condition.

Actual

  • $omo:ulw-plan deterministically receives <ultrawork-mode> in addition to the planning skill.
  • The two contracts add separate state, delegation, wait, and review requirements.
  • The planning request can become dominated by subagent barriers and continuation work instead of reaching the concise plan handoff.
  • In the observed run, continuation occurred after long waits and previously active child deliverables were not all available to the resumed parent, causing more discovery and orchestration.

Evidence

Deterministic source evidence

  • codex-hook.ts defines the unbounded substring detector and injects additional context when it matches.
  • isUltraworkPrompt is only the regex test.
  • codex-hook-trigger-policy.test.ts currently requires embedded ulw substrings to activate the hook and has no ulw-plan exclusion test.
  • ulw-plan/SKILL.md says to stop at sufficiency but also blocks dependent planning/final handoff until child lanes terminate or are recorded inconclusive.
  • ultrawork/SKILL.md adds a durable notepad and update_plan transition protocol; its child barrier adds further wait/respawn requirements.
  • In 4.16.3, full-workflow.md explicitly says elapsed time alone never justifies cancelling, replacing, or failing the high-accuracy reviewer.

Runtime evidence from the affected run

  • Planning-only request remained active for approximately six hours.
  • One small apply_patch execution reported 974.6 seconds wall time before yielding a running cell.
  • A later wait on another patch execution reported 375.7 seconds wall time.
  • A focused test invocation reported 249.7 seconds before yielding, while the same targeted tests later completed in 0.001 and 0.015 seconds. This refutes the target tests themselves as the main delay.
  • After continuation/interruption, only the root agent remained visible; final deliverables from several previously active child lanes were unavailable.
  • The packaged hook probe above reproduces on both installed 4.16.2 and current 4.16.3.

Root Cause

The confirmed LazyCodex root cause is prompt-routing collision:

  1. ULTRAWORK_CURRENT_PROMPT_PATTERN matches ulw anywhere, without token boundaries or exclusions for explicit ulw-* skill names.
  2. $omo:ulw-plan therefore activates both the selected planner and the generic Ultrawork hook.
  3. The injected full workflow compounds the planning skill's own delegation and wait rules.
  4. When Codex has a slow tool call or loses a child completion across continuation, the combined contracts lack a progress-aware bounded degradation path, so the workflow can keep waiting or re-orchestrating for hours.

Competing hypotheses were checked:

  • Upstream Codex tool/control-plane stalls are a real contributing trigger, supported by the related upstream reports, but they do not explain the deterministic extra LazyCodex directive.
  • Slow target tests were ruled out by direct millisecond test runtimes.

Proposed Fix

  1. Give explicit LazyCodex skill invocations precedence over the generic keyword detector. At minimum, $omo:ulw-plan, $omo:ulw-loop, and $omo:ulw-research should not implicitly activate full Ultrawork unless a separate explicit Ultrawork activation is also present.
  2. Replace arbitrary substring matching with an activation parser or a Unicode-aware standalone-token rule that excludes hyphenated skill names, identifiers, and filenames.
  3. Add a liveness backstop for combined planner/reviewer workflows: track last meaningful progress, persist child IDs/status/results before waiting, warn on staleness, and allow a lane to become durably inconclusive after a bounded recovery sequence.
  4. Reconcile continuation from the exact recorded phase instead of re-running completed research or respawning equivalent lanes.

Verification Plan

  • Hook unit tests must return no additional context for:
    • $omo:ulw-plan RCA and improvement plan only
    • [$omo:ulw-plan](...)
    • refactor ulw_helper.ts
    • 하이ulw
  • Existing intended activation forms such as ulw fix this and please ulw this change must still inject <ultrawork-mode>.
  • Add a precedence test where $omo:ulw-plan plus a separate explicit Ultrawork activation follows the documented intended behavior.
  • Run the packaged CLI smoke probe against the marketplace payload, not only source imports.
  • Add an integration fixture that invokes $omo:ulw-plan and verifies that the planner reaches its approval/plan stop condition without a second Ultrawork state machine.
  • Simulate a slow child/tool plus continuation and verify bounded, durable recovery without losing completed child evidence or re-running completed research.

This issue or PR was generated by LazyCodex. Tag: lazycodex-generated

ameforce avatar Jul 10 '26 15:07 ameforce

New runtime evidence: 22h34m Birkin session

This session adds a second, larger reproduction of the liveness failure described here and confirms that the uncapped dual-review rule is independently sufficient to keep planning active for hours.

Environment

  • Session ID: 019f5913-0c8e-7103-8a70-12d6a3675a6d
  • Codex CLI: 0.144.1
  • OMO/LazyCodex plugin: 4.17.0
  • OS: Windows
  • Latest source checked: LazyCodex 3d7416bff3e6c80ebf5542b4dd12f5c76298d46d; upstream Codex 7f3eb8a2233aceba3e7962123da84379ee305bb2

Observed runtime

  • First WebUI request to verified push: 22h34m41.669s.
  • Session usage: 8,917,030 tokens.
  • Before implementation, the session ran at least 14 numbered paired Momus + independent CLI review rounds (R4 through R17), plus earlier unnumbered plan reviews.
  • Repeated findings were mostly orchestration-contract refinements: immutable plan receipts, Windows process-broker identity, patch/index recovery, screenshot freshness, and goal-completion versus push ordering.
  • The user explicitly intervened after 22 hours: "finish and push now; stop repeating regression checks."
  • After the workflow abandoned the exhaustive review state machine and switched to a minimal implementation plan, backend and frontend implementation began within about 2.5 minutes.
  • The product then completed successfully: commit f8aa6b8d2d0c938853487271b89f979e8df2dd2e, SOURCE_HEAD == origin/main, exactly eight requested files, full suite 755 passed, final focused suite 33 passed.
  • Raw transcript: %CODEX_HOME%/sessions/2026/07/13/rollout-2026-07-13T10-24-08-019f5913-0c8e-7103-8a70-12d6a3675a6d.jsonl.

Confirmed source mechanism

  • The current canonical ulw-plan full workflow requires a fresh Momus + CLI round and says to resubmit both fresh until each approves; it defines no round, elapsed-time, or no-progress cap.
  • This is packaged LazyCodex policy, not an upstream Codex rule. Upstream Codex continues while a goal remains Active, but it does not define Momus, independent CLI review, or retry policy.
  • LazyCodex already has bounded precedents: the ULW final re-review is capped at two, and review-work warns against repeated wait/follow-up cycles. The uncapped ulw-plan rule is therefore an inconsistent policy gap.

Root-cause refinement

The prompt-routing collision in the issue body remains valid, but this run shows an additional deterministic liveness defect: once high-accuracy planning is active, ulw-plan itself requires fresh full dual-review rounds until unanimous approval. Each reviewer can discover another orchestration invariant, so progress can remain technically active while product implementation never starts. An unlimited goal amplifies this because there is no budget or timeout boundary that returns control to the user.

Proposed fix

  1. Run one full dual-plan review, then allow at most two cited-delta re-review rounds.
  2. After the cap, persist remaining blockers and return control to the user instead of silently starting another full round.
  3. Treat an explicit user instruction such as finish, start work, stop reviewing, or push as an exit from plan-review retry mode; carry unresolved findings into execution/review TODOs.
  4. Add a contract test that rejects unbounded wording such as until each approves unless a numeric retry/no-progress cap is present.
  5. Apply the same affected-lane retry cap to the start-work global review gate.

Verification

  • A permanently dissenting reviewer terminates after the documented cap and produces a resumable blocker report.
  • A user stop reviewing and start instruction prevents another review round.
  • A normal plan that converges in one or two repair rounds still receives both required approvals.
  • Goal continuation does not restart completed plan-review rounds.

This issue or PR was generated by LazyCodex. Tag: lazycodex-generated

ashmoonori-afk avatar Jul 14 '26 00:07 ashmoonori-afk

Fixed on dev by code-yeongyu/oh-my-openagent#6279 (merge commit).

The Codex ultrawork UserPromptSubmit trigger pattern is now /(?:ultrawork|ulw(?!-(?:plan|research)))/i, so invoking $omo:ulw-plan (or ulw-research) no longer injects the full <ultrawork-mode> directive on top of the planning contract. Bare ultrawork, standalone ulw, and ulw-loop still trigger as before. Locked with given/when/then tests covering both the carve-out and the preserved triggers. Thanks for the deterministic root-cause and repro, @ameforce. Ships in the next stable lazycodex release; closing as fixed on dev.

code-yeongyu avatar Jul 22 '26 02:07 code-yeongyu