Skip to content

perf: reduce Codex workflow token overhead #409

Closed

Description

@Jammy2211

Overview

Make Codex delegation selective and reduce repeated context/coordination while retaining Brain/Mind gates and preserving Claude delegation. Add a read-only completed-task usage report and comparison protocol.

This task is explicitly authorized to use a separate PyAutoBrain/PyAutoMind worktree concurrently with codex-hook-parity; it must preserve that task's branches, claims, and changes.

Plan

  • Split provider policy: preserve Anthropic delegation semantics exactly, while making OpenAI execution direct by default with bounded delegation exceptions.
  • Retain Brain/Mind routing, approval and health gates, registries, conflict-aware worktrees, and independent review while reducing repeated ceremony.
  • Slim auto-loaded instructions through task-specific linked references, concise skill descriptions, and authoritative generated blocks.
  • Bound delegated context, coordination, responses, repeated checks, and chat-visible logging.
  • Add a privacy-conscious, read-only completed-task usage meter and a documented 3–5-task comparison protocol without inventing billing or savings.
Detailed implementation plan

Affected Repositories

  • PyAutoMind (primary)
  • PyAutoBrain

Branch Survey

Repository Current Branch Dirty?
./PyAutoMind main clean except this task's approved draft prompt
./PyAutoBrain main clean

codex-hook-parity actively claims both repositories. The user explicitly authorized an isolated concurrent worktree for this task. Its worktree, branches, claims, and changes must not be modified.

Suggested branch: feature/codex-token-efficiency

Implementation Steps

  1. Split delegation policy by provider in the workspace-root AGENTS.md, PyAutoBrain/skills/WORKFLOW.md, and dependent start/ship documentation. Preserve Anthropic's Fable → Opus, Opus → Opus, Sonnet mechanical-floor, and tutorial-prose behavior exactly. For OpenAI, make direct execution the default and delegate selectively for independent parallel work, noisy or long-running execution, and independent review.
  2. Retain Brain/Mind routing, planning and approval gates, task registries, conflict-aware worktrees, Heart gates, and independent review. Reduce overhead without bypassing these controls.
  3. Slim auto-loaded instructions and workflow prose by moving task-specific detail behind links, keeping skill descriptions short and unambiguous, and preserving generated blocks as authoritative rather than duplicating them.
  4. Bound coordination: delegate with minimal relevant context, require concise structured returns, reuse a worker for coherent follow-ups, avoid repeating unchanged checks, and keep full execution logs outside chat while returning only decision-relevant excerpts.
  5. Add a read-only, standard-library usage meter, tentatively PyAutoBrain/bin/codex_usage.py, with meaningful parser fixtures. It must read only explicitly selected rollout files, extract and report metadata only, use the last cumulative counters, cache results separately, treat cached input as included in input and reasoning as included in output, summarize every observed model/effort value, document explicit parent/child de-duplication and inherited-event uncertainty, avoid raw conversation content and secrets in output, keep missing usage unknown/incomplete, and report duration and coordination counts without claiming causality or inventing billing. Document a comparison protocol across 3–5 completed tasks including outcome, corrections, and total parent/children where aggregation is reliable; no new expensive runs are required. Astra Medium is already configured; do not add an unnecessary local configuration edit.

Validation

  • Run the relevant existing skill, installer, and documentation checks.
  • Run focused fixture tests for the usage-meter parser, cumulative-counter handling, parent/child de-duplication and aggregation uncertainty, privacy boundary, model/effort changes, and malformed or missing input.
  • Keep any workspace-root AGENTS.md update reproducible through an appropriate tracked PyAutoBrain documentation/install step rather than relying on an unexplained local-only patch.
  • Snapshot before/after byte counts for commonly loaded instructions and skill metadata.

Key Files

  • PyAutoBrain/skills/WORKFLOW.md — concise shared workflow and provider routing.
  • PyAutoBrain/skills/ — dependent start/ship references and concise discovery metadata.
  • PyAutoBrain/bin/codex_usage.py — explicit-file read-only usage reporter.
  • PyAutoBrain/tests/ — meter and workflow-policy fixtures.
  • PyAutoBrain/AGENTS.md, PyAutoMind/AGENTS.md — slim auto-loaded guidance without damaging generated sections.
  • Tracked PyAutoBrain install/template documentation — reproducible workspace-root policy update.

Original Prompt

Click to expand starting prompt

ok do all 5, but delegation works very well on claude so ensure we dont lose the delegation policy there.

Follow-up authorization:

Allow a separate worktree

Activity

  1. Jammy2211 commented on Sep 18, 2026

    @Jammy2211
    CollaboratorAuthor

    Development RED override exercised — PR open

    The live human authorized task #409 contemporaneously:

    yes commit, push and open the PR for

    Exact current Heart reasons at shipping:

    • RED: install verification FAILED (testpypi; checks F)
    • RED: release validation FAILED (stage integrate)
    • YELLOW: manifest drift: remote-session blocks (generated) — 2 mismatch(es) vs PyAutoMind/repos.yaml

    Passed branch gates: PyAutoBrain full suite 915 passed; focused suite 41 passed; four changed skills validated; live usage smoke matched the audited counters and all 80 collaboration calls; independent working-tree review CLEAN.

    The authorized development actions are complete: commit a7d8fce, normal push, and pending-release PR PyAutoLabs/PyAutoBrain#387. Heart remains RED. This authorization does not permit merge, release, release rehearsal, required-check bypass, branch-protection bypass, or any claim that the branch repairs Heart.

  2. Jammy2211 commented on Sep 18, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Merged PyAutoLabs/PyAutoBrain#387 at reviewed head a7d8fce (merge commit 0a21749). Codex now uses direct execution for routine sequential work with bounded delegation, while Claude's Fable/Opus/Sonnet policy is preserved. The workflow core is smaller, the explicit-file usage meter and comparison protocol are included, and workspace-root activation is reproducible through the installer.

    Validation: 915 full Brain tests, 41 focused tests, four skill validations, live counter/80-call smoke, independent review CLEAN, and all PR checks green. The development RED override remains a historical shipping fact; this merge did not resolve Heart's install/release failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions