Skip to content

[codex] stop caching Codex runtime tasks - #1515

Merged
qdaxb merged 1 commit into
mainfrom
codex/remove-codex-runtime-cache
Jun 22, 2026
Merged

qdaxb merged 1 commit into
mainfrom
codex/remove-codex-runtime-cache

Conversation

@qdaxb

@qdaxb qdaxb commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Stop persisting discovered Codex threads into runtime-work/index.json.
  • Treat native Codex as the source of truth for Codex runtime tasks: lists, transcripts, sends, and archives resolve live discovered threads instead of store-backed records.
  • Reject store-backed Codex task creation/import paths so stale runtime=codex records no longer reappear in wework.
  • Update runtime work tests for stale cached Codex records, live discovery, and rejected Codex index writes.

Root Cause

Wework merged live Codex discovery with ~/.wegent-executor/runtime-work/index.json. Archived or synthetic runtime=codex records in the local runtime index could still be shown even when Codex itself no longer listed them.

Validation

  • uv run --project executor black executor/runtime_work/rpc_handler.py executor/tests/runtime_work/test_local_task_store.py
  • uv run --project executor isort executor/runtime_work/rpc_handler.py executor/tests/runtime_work/test_local_task_store.py
  • PYTHONPATH=/Users/axb-mac/.codex/worktrees/0d27/Wegent uv run --project executor pytest executor/tests/runtime_work -q
  • Local exact check for /Users/axb-mac/dev/aigc/wegent_workspace/Wegent title hi: handler now returns only the live Codex thread.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Codex runtime task handling and filtering logic
    • Enhanced concurrency controls for simultaneous SDK task operations
    • Stricter validation to reject invalid runtime task creation requests
  • Tests

    • Updated test suite to reflect new Codex runtime task semantics and behavior

@coderabbitai

coderabbitai Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5f5a8ad9-9c0a-4873-9266-f8045baff128

📥 Commits

Reviewing files that changed from the base of the PR and between 95344e1 and 42f690e.

📒 Files selected for processing (2)
  • executor/runtime_work/rpc_handler.py
  • executor/tests/runtime_work/test_local_task_store.py

📝 Walkthrough

Walkthrough

rpc_handler.py replaces all hardcoded == "codex" runtime checks with _is_codex_runtime(), adds an in-memory _running_sdk_task_ids set for concurrent SDK send prevention, and reworks _load_payload_task to prefer discovered tasks over stored tasks for Codex runtimes. Tests are updated to match all new semantics and migrate fork/IM fixtures from codex to claude_code.

Changes

Codex Runtime Discrimination, SDK Concurrency Guard, and Task Resolution

Layer / File(s) Summary
_is_codex_runtime() adoption across filtering and helper methods
executor/runtime_work/rpc_handler.py
Replaces all direct == "codex" / != "codex" / .lower() != "codex" comparisons with _is_codex_runtime(...) in poll_codex_updates_once, _list_visible_tasks, _codex_session_messages, _archive, _import_fork, _executor_session_metadata, _codex_thread_id, and _adapter_method; _adapter_method now returns an explicit unsupported_runtime error for Codex tasks.
In-memory SDK concurrency guard
executor/runtime_work/rpc_handler.py
Adds _running_sdk_task_ids set to the handler; _send_sdk_codex_task checks and inserts into this set to block duplicate concurrent sends; _run_sdk_codex_task removes the id on completion instead of writing running=False to the store.
Task-resolution overhaul in _load_payload_task and _transcript
executor/runtime_work/rpc_handler.py
_load_payload_task gains an optional discovered_tasks kwarg; resolution prefers store.get_task() only for non-Codex runtimes and falls back to _find_discovered_task() otherwise; _find_discovered_task normalizes workspace_path and raises KeyError on no match; _transcript now refreshes discovered tasks and passes them along.
Tests: SDK concurrency, Codex rejections, archive/listing assertions
executor/tests/runtime_work/test_local_task_store.py
Adds _sdk_codex_record helper; new tests assert runtime.tasks.create with runtime="codex" and Codex fork imports are rejected; concurrency/cleanup assertions switch from store running flag to handler._running_sdk_task_ids membership; archive test asserts KeyError on store removal; listing test asserts discovered Codex records are removed after listing.
Tests: discovery stub updates and listing/transcript tests
executor/tests/runtime_work/test_local_task_store.py
Discovery stubs across streaming, transcript, IM, and listing tests are updated to return _sdk_codex_record(...) instead of empty lists; two new listing tests assert stale cached Codex tasks are hidden when discovery is empty, and only the live discovered thread is shown when discovery returns a record.
Tests: fork and IM overlay tests migrated to claude_code
executor/tests/runtime_work/test_local_task_store.py
Fork transfer, import, archive-restore, parent-metadata, followup-session, and IM overlay tests are reworked to use runtime="claude_code" with executorSession-style runtime handles; assertions check claude_code task fields and record.runtime_handle["executorSession"]; IM overlay test constructs the handler with explicit codex_discovery=EmptyDiscovery().

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • wecode-ai/Wegent#1502: Directly modifies the same executor/runtime_work/rpc_handler.py runtime/task handling for Codex (task selection, listing, transcript, and concurrency guards) and updates the same executor/tests/runtime_work/test_local_task_store.py to validate the new Codex RPC semantics — the predecessor slice of these changes.

Poem

🐇 Hoppity hop through the runtime maze,
No more hard-coded "codex" strings to blaze!
A helper function now leads the way,
_is_codex_runtime saves the day.
The guard set tracks what's running with care,
And discovered tasks float free through the air! 🌟

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/remove-codex-runtime-cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@qdaxb
qdaxb marked this pull request as ready for review June 22, 2026 06:37
@qdaxb
qdaxb merged commit 04d4daf into main Jun 22, 2026
20 of 21 checks passed
@qdaxb
qdaxb deleted the codex/remove-codex-runtime-cache branch June 22, 2026 06:37
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.

1 participant