Skip to content

Fix Codex DM provider trace cancellations - #500

Merged
100yenadmin merged 5 commits into
mainfrom
codex/worldos-codex-dm-trace-479
Jun 1, 2026
Merged

Fix Codex DM provider trace cancellations#500
100yenadmin merged 5 commits into
mainfrom
codex/worldos-codex-dm-trace-479

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Prevent Codex DM provider proof turns from retrying or safety-cancelling redundant narration/reward tool calls.
  • Record final Codex DM prose through the engine first, then mark the /chat DM line as engine_logged so /chat remains the turn-resolution signal without duplicating visible chronicle prose.
  • Update takeover truth docs and qa/SCORECARD.md with the final built-app Codex DM should avoid safety-cancelled setup/social tool calls #479 evidence.

Built-App Evidence

  • Final proof: /Volumes/LEXAR/Codex/worldos-built-app-playtest/codex-479-traceclean-nodup-proof-20260601T003002Z/
  • App/code SHA: b081092
  • Built app: dist/WorldOS.app local Mac
  • Provider: Codex DM
  • Live run: play-20260601003008, campaign camp_ffd97ffdb6ef, port 8767
  • /app-status: private art present at /Users/lume/ClawDnD-val/content/worlds/_private, Alfira active, writable /move, can_act=true, five enabled actions
  • /session-surface: remained live/actionable after one accepted/resolved /move
  • Provider trace: provider-errors.after-move.json reports zero parse errors and zero failed/error tool calls (completed=10, in_progress=10)
  • Native accessibility review: one opening narration row and one follow-up narration row; no duplicate chat/event prose

Tests

  • bash -n scripts/play_codex_dm.sh
  • python3 -m pytest servers/engine/tests/test_codex_provider_wrapper.py viewer/tests/test_live_narration_stream.py qa/test_macos_app_static.py -q
  • git diff --check
  • Built-app proof above via qa/ui_playtest_app.sh Part A plus one manual /move

Release Note

This is trace-clean branch diagnostic evidence for #479, not a full RRI release verdict. Release still requires the full #466 five-persona RRI with Mac built-app evidence plus support-VM heavy sweep evidence.

Refs #479. Do not close #479 until maintainers either accept this branch proof as sufficient after merge or a merged-main rerun proves non-reproduction.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed duplicate narration appearing in game chat when narration events are processed by the engine.
  • Improvements

    • Enhanced narration logging mechanism to ensure consistent narrative display across the system.
    • Updated system documentation with latest baseline build information and verification status.

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@100yenadmin, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 7 minutes and 27 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2ee2f2b4-b2ad-4976-812e-e94cd0b31be0

📥 Commits

Reviewing files that changed from the base of the PR and between 8516ecb and d8c247e.

📒 Files selected for processing (2)
  • scripts/play_codex_dm.sh
  • servers/engine/tests/test_codex_provider_wrapper.py
📝 Walkthrough

Walkthrough

Codex DM wrapper now logs narration events directly to the engine instead of relying on chat-row persistence. The wrapper discovers the active campaign ID, calls log_engine_narration() to record narration via the engine's server.log_event(), and marks the resulting chat row with engine_logged: true. The viewer suppresses duplicate narration for those marked entries. Documentation updated with #479 trace-clean evidence showing zero parse errors and zero failed tool calls.

Changes

Codex DM engine narration logging and viewer deduplication

Layer / File(s) Summary
Engine narration logging API and prompt rules
scripts/play_codex_dm.sh
chatlog() function expanded to accept optional third argument for extra JSON fields. New log_engine_narration() helper validates campaign ID and text, then invokes server.log_event() to persist narration. Prompt rule constants updated to guide the model on wrapper-driven narration logging and split persistence rules into OPENING_PERSIST_BEAT_RULE and MOVE_PERSIST_BEAT_RULE with updated reward-mutation constraints.
Wrapper narration logging on opening and move turns
scripts/play_codex_dm.sh, servers/engine/tests/test_codex_provider_wrapper.py
Opening and move prompts inject updated narration/persistence rule variables. After opening reply, wrapper discovers campaign ID, logs narration to engine, and writes chat row with engine_logged: true when successful. Move turns apply the same pattern with move-specific persistence rules. Contract tests assert narration logging occurs before chat rows, enforce opening vs move persistence beat distinctions, and validate rule presence in respective turn prompts.
Viewer deduplication of engine-logged narration
viewer/openworlds/app.jsx, viewer/tests/test_live_narration_stream.py
App-level /chat poll now filters entries where engine_logged === true before narration suppression/rendering, preventing duplicate beats while preserving turn-resolution signaling. Test verifies that /chat marked engine-logged clears pending state without adding narration, and subsequent /events beat renders exactly once in chronicle.
Evidence documentation for #479 trace-clean baseline
WorldOS-GUI-RUNBOOK.md, WorldOS-OPERATING-GOAL.md, WorldOS-RUNBOOK.md, qa/SCORECARD.md
Runbooks and scorecard updated to record #479 branch trace-clean proof (build SHA b081092, run codex-479-traceclean-nodup-proof-20260601T003002Z) with zero parse errors and zero failed tool calls. New baseline set to ff84444 across all ground-truth documents. Evidence descriptions emphasize narration-row non-duplication after engine-logging and deduplication confirmations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • electricsheephq/WorldOS#475: Introduces the Codex DM provider wrapper that this PR extends with narration logging and prompt rule updates.
  • electricsheephq/WorldOS#394: Implements the viewer-side /events//chat deduplication and pending-state logic that this PR builds on with engine_logged suppression.
  • electricsheephq/WorldOS#401: Establishes the narration-via-engine contract that this PR enforces via log_engine_narration() and viewer-side dedup to prevent /chat duplication.

Poem

🐰 The Codex bard now speaks to the engine's ear,
No chatlog echoes where narrations appear—
The viewer knows which tales are twice-told,
And renders each prose just once, pure and bold! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix Codex DM provider trace cancellations' directly addresses the main objective of the PR—eliminating safety-cancelled tool calls in the Codex DM provider.
Description check ✅ Passed The PR description covers key elements: summary of changes, built-app evidence details, tests run, and release notes. However, the CLA/Licensing checklist section is not filled in (checkboxes are unchecked).
Linked Issues check ✅ Passed The PR directly addresses all acceptance criteria from #479: opening prompt prevents roster mutation beyond player, narration logging prevents redundant tool calls, and built-app evidence confirms zero parse errors and zero failed tool calls.
Out of Scope Changes check ✅ Passed All changes align with #479 objectives: script modifications add engine narration logging and validation, tests verify narration deduplication and engine_logged behavior, documentation updates reflect final evidence, and viewer code prevents chronicle duplication.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
scripts/play_codex_dm.sh (1)

523-533: ⚡ Quick win

Extract the duplicated engine-log/chat-write flow into one helper.

The opening and move blocks duplicate the same control flow and warning/chat metadata logic, which increases drift risk when one path changes later.

♻️ Suggested refactor
+record_dm_reply() {
+  local campaign_id="$1" reply="$2" phase="$3"
+  if log_engine_narration "$campaign_id" "$reply"; then
+    chatlog dm "$reply" '{"engine_logged":true}'
+  else
+    echo "[codex-dm-provider] warning: could not record ${phase} narration through engine" >&2
+    chatlog dm "$reply"
+  fi
+}
...
-ENGINE_LOGGED=0
-if log_engine_narration "$ACTIVE_CAMPAIGN_ID" "$OPENING"; then
-  ENGINE_LOGGED=1
-else
-  echo "[codex-dm-provider] warning: could not record opening narration through engine" >&2
-fi
-if [ "$ENGINE_LOGGED" -eq 1 ]; then
-  chatlog dm "$OPENING" '{"engine_logged":true}'
-else
-  chatlog dm "$OPENING"
-fi
+record_dm_reply "$ACTIVE_CAMPAIGN_ID" "$OPENING" "opening"
...
-ENGINE_LOGGED=0
-if log_engine_narration "$ACTIVE_CAMPAIGN_ID" "$REPLY"; then
-  ENGINE_LOGGED=1
-else
-  echo "[codex-dm-provider] warning: could not record move narration through engine" >&2
-fi
-if [ "$ENGINE_LOGGED" -eq 1 ]; then
-  chatlog dm "$REPLY" '{"engine_logged":true}'
-else
-  chatlog dm "$REPLY"
-fi
+record_dm_reply "$ACTIVE_CAMPAIGN_ID" "$REPLY" "move"

Also applies to: 566-576

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/play_codex_dm.sh` around lines 523 - 533, The opening/move blocks
duplicate the engine-log then chat-write pattern (ENGINE_LOGGED,
log_engine_narration, chatlog), so extract that flow into a single helper (e.g.,
log_engine_and_chat or record_narration_and_chat) that: calls
log_engine_narration with the campaign and text, emits the same warning to
stderr when it fails, and then calls chatlog with the original message and JSON
metadata '{"engine_logged":true}' only when the engine log succeeded; replace
both the opening and move blocks with calls to this helper to eliminate
duplication and keep behavior identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/play_codex_dm.sh`:
- Around line 523-533: The opening/move blocks duplicate the engine-log then
chat-write pattern (ENGINE_LOGGED, log_engine_narration, chatlog), so extract
that flow into a single helper (e.g., log_engine_and_chat or
record_narration_and_chat) that: calls log_engine_narration with the campaign
and text, emits the same warning to stderr when it fails, and then calls chatlog
with the original message and JSON metadata '{"engine_logged":true}' only when
the engine log succeeded; replace both the opening and move blocks with calls to
this helper to eliminate duplication and keep behavior identical.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bd753883-a1ad-4031-bb87-566560382f9f

📥 Commits

Reviewing files that changed from the base of the PR and between ff84444 and 8516ecb.

📒 Files selected for processing (8)
  • WorldOS-GUI-RUNBOOK.md
  • WorldOS-OPERATING-GOAL.md
  • WorldOS-RUNBOOK.md
  • qa/SCORECARD.md
  • scripts/play_codex_dm.sh
  • servers/engine/tests/test_codex_provider_wrapper.py
  • viewer/openworlds/app.jsx
  • viewer/tests/test_live_narration_stream.py

@100yenadmin
100yenadmin merged commit f7ab6d7 into main Jun 1, 2026
10 checks passed
@100yenadmin
100yenadmin deleted the codex/worldos-codex-dm-trace-479 branch June 1, 2026 01:13
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 DM should avoid safety-cancelled setup/social tool calls

1 participant