Skip to content

Fix overview generation failing on large repos (codex input_too_large) - #92

Merged
anhnh2002 merged 2 commits into
mainfrom
fix/overview-prompt-file-paths
Aug 16, 2026
Merged

Fix overview generation failing on large repos (codex input_too_large)#92
anhnh2002 merged 2 commits into
mainfrom
fix/overview-prompt-file-paths

Conversation

@anhnh2002

@anhnh2002 anhnh2002 commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Problem

On large repos, every parent/repo overview call fails. The overview prompt embeds the entire module tree (every module's components list, json.dumps(indent=4)) plus the full markdown of every child doc. On wazuh that is ~2.2M chars — over codex's hard per-turn input cap of 1,048,576 chars. codex rejects the turn instantly (input_too_large, code -32602), and the failure surfaced misleadingly as LLM returned empty content ... (possible output truncation at max_tokens) — 84 consecutive overview failures in a single wazuh run.

Fix

  • build_overview_structure strips components lists recursively and replaces inlined child docs with an absolute docs_path per child (None when the doc file is missing). Measured on wazuh: overview prompts drop from ~2.2M to ~83K chars.
  • REPO_OVERVIEW_PROMPT / MODULE_OVERVIEW_PROMPT now instruct the agent to read the referenced doc files itself. backend.complete() runs with ToolGroup.READER (codex: --sandbox read-only), so file reads are available. Format placeholders are unchanged, so the MCP prompt_server rendering path keeps working.
  • coding-agent-wrapper is pinned to a fork branch (https://github.com/anhnh2002/caw/tree/fix/codex-exec-robustness) carrying the matching codex provider fixes: prompt via stdin (argv size limits), codex exec resume sandbox flag mapping, and no longer silently returning an empty turn when the codex CLI exits nonzero after printing a plain-text Error: line.
  • Second commit is mechanical lint cleanup of the touched files (the Lint job runs ruff over whole changed files, including pre-existing violations); it also removes two duplicated dict keys in EXTENSION_TO_LANGUAGE.

Tests

  • New tests/test_overview_structure.py: components stripped at every depth, docs referenced by absolute path and not inlined, target marking, and a wazuh-scale synthetic tree staying an order of magnitude under the codex cap.
  • Full suite: 46 passed. ruff check + ruff format --check clean on all changed files.
  • Verified live against the failed wazuh run: a previously-failing parent overview now generates correctly (the codex agent reads the child docs from the given paths).

anhnh2002 and others added 2 commits August 16, 2026 17:23
Parent/repo overview prompts embedded the entire module tree — every
module's components list — as indent-4 JSON plus the full markdown of every
child doc. On large repos (wazuh: ~2.2M chars) that exceeds codex's hard
per-turn input cap of 1,048,576 chars, so every overview call failed with
input_too_large, surfaced misleadingly as "LLM returned empty content".

- build_overview_structure now strips components lists recursively and sets
  an absolute docs_path per child instead of inlining docs (None when the
  doc is missing). Wazuh-scale prompts drop from ~2.2M to ~83K chars.
- REPO_OVERVIEW_PROMPT / MODULE_OVERVIEW_PROMPT instruct the agent to read
  the referenced files itself (backend.complete runs with ToolGroup.READER,
  so file reads are available). Placeholders are unchanged, keeping the MCP
  prompt_server rendering path working.
- Pin coding-agent-wrapper to the fork branch carrying the matching codex
  provider fixes (stdin prompts, resume sandbox flag, and surfacing CLI
  failures that were silently returned as empty turns).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The Lint job runs ruff (modern defaults) over every changed file, so the
pre-existing violations in documentation_generator.py and prompt_template.py
count against this PR. Mechanical cleanup only: import sorting, ruff format,
Dict/List -> dict/list, explicit Optional, timezone-aware metadata timestamp,
no mutable argument defaults, and dropping two duplicated dict keys
(".hpp"/".jsx" in EXTENSION_TO_LANGUAGE). The two intentional blanket
`except Exception` handlers are noqa'd with justification.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@anhnh2002
anhnh2002 force-pushed the fix/overview-prompt-file-paths branch from 2f6c782 to 72c3574 Compare August 16, 2026 10:26
@anhnh2002
anhnh2002 merged commit 003b876 into main Aug 16, 2026
2 checks passed
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