Skip to content

Reduce repeated Codex context and fix grouped workflow paths #403

Closed

Description

@Jammy2211

Overview

Reduce repeated instruction and tool-result context in Codex after grouping the workspace into family folders. Preserve provider delegation, approval, review, Heart and release controls.

Plan

  • Slim root, Brain and Mind instruction surfaces and retain on-demand details.
  • Read workflow references only for the current step and execution environment.
  • Bound tool output and document compact completed-phase handoffs.
  • Resolve grouped/flat repository paths consistently.
  • Measure static context reductions and validate generated instructions, paths and workflow invariants.
Detailed implementation plan

Work classification: library (Brain conductor decision; infrastructure repositories).
Primary repo: PyAutoBrain. Also PyAutoMind.
Branch: feature/codex-context-efficiency.
Worktree: /home/jammy/Code/PyAutoLabs/.worktrees/codex-context-efficiency.
Branch survey: Brain main clean; Mind main with unrelated deletion of draft/maintenance/pyautobrain/workspace_resolver_fanout.md, preserved. No active claims on either repo.

Key files: Brain AGENTS.md, bin/install.sh and workspace-policy generator, skills/WORKFLOW.md, MODEL_DELEGATION.md, start_dev and prm procedure/reference files; Mind AGENTS.md, repos_sync generation surfaces, and context-size reporting. Keep explanatory detail in linked references; generated blocks change at their owner. Reuse the existing repository resolver rather than invent another layout heuristic. Keep flat bundles and remote clones supported. Reduce start/close mandatory reading without dropping gates; unchanged instructions need not be reread. Report lines/bytes and approximate tokens with explicit static-estimate limits. Validate installer and repos_sync drift, focused existing workflow tests, grouped/flat paths and independent review. No model configuration changes, merge or release authorization.

Original Prompt

Reduce repeated Codex context after workspace regrouping

Type: maintenance
Target: organs
Repos:

  • @PyAutoBrain
  • @PyAutoMind
    Difficulty: medium
    Autonomy: supervised
    Priority: high
    Status: draft
    Filed: 2026-09-19

Original request

Can you do another review of codex token usage, is there anything we can do to be more efficient? We did one recently and it helped, but theres more tasks with astra you can review to assess and we did the reorg of PyAutoLabs

Approval of the resulting five recommendations:

ok do all of that

Approved scope

  1. Slim root, Brain and Mind instructions; preserve mandatory policies and provider-specific delegation.
  2. Make workflow reference reads conditional on the environment and current step; reuse unchanged loaded instructions.
  3. Bound tool output: targeted reads, summaries, failure excerpts and external full logs.
  4. Correct grouped-layout path guidance using the existing repository resolver, preserving flat task-bundle/remote layouts.
  5. Define compact handoffs at completed phase boundaries without interrupting authorized work or weakening independent review.

Keep Astra Medium unchanged, retain concise folder routing guides, and preserve every safety, approval, review, Heart and release gate. Related broader backlog: reduce_session_token_load.md; Cortex/Memory prose and completion-record redesign are outside this task.

Implementation and validation

Use feature/codex-context-efficiency in isolated Brain and Mind worktrees. Move explanatory AGENTS prose to references, update authoritative generators rather than generated copies, shorten and index start/close workflow instructions, and add a deterministic context-size report/budget check for maintained surfaces. Validate generated blocks, grouped/flat path examples, existing installer/workflow tests and independent review. Record before/after bytes and lines; do not claim measured runtime savings from static size reductions.

Activity

  1. Jammy2211 commented on Sep 19, 2026

    @Jammy2211
    ContributorAuthor

    Implementation is ready for review in PyAutoBrain#404 and PyAutoMind#425.

    • Maintained root/Brain/Mind instruction surfaces: 43,365 → 25,731 bytes (40.7% smaller after root activation); this is a static reduction, not measured runtime billing savings.
    • Conditional workflow reads, bounded tool output, grouped/flat path normalization and completed-phase handoffs implemented. Claude delegation, independent review and safety gates retained.
    • Brain: 982 tests passed in clean test environment; Mind: 579 full-suite tests, then 36 final affected tests. Independent review CLEAN on Brain 696f023 / Mind 401c2cbc.
    • Heart remains STALE: release validation incomplete: no rehearsal for current source. Development PRs only.
    • Root activation is prepared and checked, but waits until both main checkouts contain the new references. See Brain docs/context_efficiency.md. Merge remains human-authorized.
  2. Jammy2211 commented on Sep 19, 2026

    @Jammy2211
    ContributorAuthor

    Final validation: Brain 982 tests and Mind 582 tests passed; Sphinx passes with warnings treated as errors. Both PRs now have green applicable GitHub checks. Independent review includes the docs-build and isolated-checkout follow-up fixes (Brain 68889b0 / Mind 335d0b3f). Root activation remains prepared for after both merges, per docs/context_efficiency.md. No merge performed.

  3. Jammy2211 commented on Sep 19, 2026

    @Jammy2211
    ContributorAuthor

    Shipped in #404 and PyAutoLabs/PyAutoMind#425; both merged after all applicable CI jobs passed.

    Implemented all five approved token-efficiency changes and activated the root instructions. Combined maintained AGENTS size is 40.7% smaller (static bytes; no runtime savings claim). Brain 982 and Mind 582 tests passed, docs built with warnings as errors, and independent review was CLEAN. Root instruction and context-budget checks pass.

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