agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

Codex plugin integration gaps cause incorrect dashboard activity/state detection

Open prod-blip opened this issue 7 months ago • 2 comments

Summary

Several Codex-specific integration gaps cause AO to mis-detect activity/state in the dashboard and lifecycle paths.

These issues affect Codex-backed sessions, especially orchestrators, and show up as missing activity, incorrect active state, and failure to use native Codex session logs.

Problems Included

1. Web dashboard backend does not load the Codex agent plugin

The web service layer does not register the Codex agent plugin, so dashboard-side sessionManager.get() / sessionManager.list() cannot run Codex activity enrichment.

Impact:

  • Codex sessions can come through with activity: null
  • dashboard falls back to rendering unknown

2. Web package is missing the Codex plugin dependency

The web package does not include @aoagents/ao-plugin-agent-codex as a dependency, so the web layer cannot reliably import/register the plugin.

Impact:

  • runtime/plugin registration failures in the web app
  • broken Codex-specific enrichment path

3. Codex native JSONL parsing assumes the wrong shape

Native Codex session JSONL uses nested payload fields such as:

  • payload.cwd
  • payload.model
  • payload.msg
  • nested token usage under payload info

The current integration assumes older flat fields in some places.

Impact:

  • session file matching can fail
  • model/thread/cost extraction can fail
  • activity/session info can be incomplete or null

4. Codex terminal idle prompt is misclassified as active

Fallback terminal activity detection does not properly recognize Codex prompt lines such as:

  • › ...

Impact:

  • idle orchestrator sessions remain incorrectly marked active
  • .ao/activity.jsonl keeps being refreshed with false active entries

5. Native Codex session matching truncates oversized session_meta

The current cwd matcher reads only the first 4 KB of the native session file when trying to parse session_meta.

For orchestrator sessions, the first session_meta line can exceed that size because it embeds large instruction payloads.

Impact:

  • JSON parsing fails on truncated session_meta
  • cwd matching fails
  • AO falls back to .ao/activity.jsonl instead of using the native Codex session file

Expected Behavior

For Codex-backed sessions, AO should:

  • load the Codex plugin everywhere it builds session state, including the web backend
  • correctly parse modern native Codex JSONL payload structure
  • correctly match native session files to worktrees
  • prefer native Codex session files for activity/session info when available
  • classify Codex prompt-idle states correctly instead of marking them active

Actual Behavior

Codex-backed sessions can show:

  • unknown activity in dashboard views
  • incorrect active activity when idle
  • fallback .ao/activity.jsonl behavior even when a native Codex session file exists
  • incomplete session info due to JSONL parsing mismatch

Proposed Fix

Implement a single Codex integration cleanup covering:

  1. Register Codex plugin in the web service backend
  2. Add @aoagents/ao-plugin-agent-codex to the web package dependencies
  3. Update Codex JSONL parsing to support nested payload.* fields
  4. Update terminal idle detection for Codex prompt patterns like › ...
  5. Update native session matching to read a complete session_meta line instead of truncating at 4 KB

Tests

Add or update regression coverage for:

  • web Codex plugin registration
  • nested native Codex JSONL parsing
  • Codex prompt idle detection
  • oversized session_meta line matching during cwd detection

Impact

Without this fix, Codex-backed AO sessions can be misrepresented in the dashboard and lifecycle pipeline, especially for orchestrators, leading to incorrect activity rendering and degraded status detection.

prod-blip avatar Apr 12 '26 16:04 prod-blip

I checked current main; a few bullets here look fixed now. packages/web/package.json depends on @aoagents/ao-plugin-agent-codex, packages/web/src/lib/services.ts imports/registers pluginAgentCodex, and packages/web/src/__tests__/services.test.ts has a registration test. The Codex plugin also accepts payload-wrapped JSONL via getCodexPayload() and has payload-wrapped session/restore tests.

The closeout items I would still gate before closing this:

  • The issue calls out Codex's › ... idle prompt. detectActivity() still only treats bare >, $, and # as idle prompts, so the terminal fallback can still misclassify an idle Codex pane as active when native JSONL is missing or unreadable. Add › to that prompt regex and cover both some output\n› and Working...\nDone\n› .
  • Keep one regression that forces native JSONL discovery to fail and then asserts AO activity JSONL fallback state is used. The important failure mode was not just parsing Codex; it was dashboard state becoming unknown/wrong when native discovery failed.
  • Cost is now extracted, but it is a hard-coded estimate in getSessionInfo(). For a safety dashboard, I'd add cost provenance somewhere in the returned session info: source=codex-jsonl-estimate, model/rate version, and an explicit unknown/estimated flag. That keeps budget alarms from looking like provider-billed truth when models or cached/reasoning token rates change.
  • Keep the parser fixture matrix focused on real Codex shapes: payload-wrapped session_meta.cwd, turn_context.payload.model, event_msg.payload.info.total_token_usage, legacy event_msg.msg.token_count, malformed lines, and a session with only metadata and no cost.

That would turn this from "Codex works on the happy path" into "dashboard state and cost fail closed enough for operators to trust it."


Generated with ax.

Necmttn avatar Jun 21 '26 06:06 Necmttn

This issue was created before the AO rewrite and is no longer relevant to the current codebase, so we’re closing it as part of the repository cleanup.

AO is now available as an app on macOS and Windows, with iOS currently in beta and Android coming soon.

If the issue still exists in the latest version of AO, feel free to open a new issue with updated details, reproduction steps, logs, and screenshots where applicable.

Stay connected with AO:

GitHub: https://github.com/AgentWrapper/agent-orchestrator Discord: https://discord.gg/kGbBRRDPv X: https://x.com/aoagents LinkedIn: https://www.linkedin.com/company/agent-orchestrator Instagram: https://www.instagram.com/aoagents

illegalcall avatar Jul 25 '26 05:07 illegalcall