Skip to content

Fix module/cluster prompts exceeding codex input cap; fix resume skipping missing module docs - #94

Merged
anhnh2002 merged 2 commits into
mainfrom
fix/module-prompt-input-too-large
Aug 17, 2026
Merged

Fix module/cluster prompts exceeding codex input cap; fix resume skipping missing module docs#94
anhnh2002 merged 2 commits into
mainfrom
fix/module-prompt-input-too-large

Conversation

@anhnh2002

@anhnh2002 anhnh2002 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Problem

Two independent failures observed while generating docs for wazuh (822 modules, 20.8k components):

  1. input_too_large on module generation. format_user_prompt inlines the entire module tree — every component of every module — into each module agent's prompt. On wazuh the tree alone formats to ~823k chars; together with an inlined 350k-char source file the prompt reached 1,175,972 chars, over codex's hard per-turn input cap of 1,048,576 chars (input_too_large, code -32602). Every remaining module failed deterministically. Same bug family as the overview prompts fixed in Fix overview generation failing on large repos (codex input_too_large) #92, in a different code path. format_cluster_prompt has the same exposure.

  2. Resume silently skipped missing docs. run_module_agent (caw and pydantic-ai backends) and generate_parent_module_docs returned early whenever overview.md existed. overview.md only proves the root module is done, so resuming a partial run skipped every nested module and parent that still lacked its own doc file.

Fix

  • prompt_template.py: build the prompt with the full tree exactly as before; only if it exceeds MAX_USER_PROMPT_CHARS (900k, leaving headroom for system prompt and protocol overhead), rebuild with a names-only tree (~26k chars for wazuh) plus a note pointing the agent at its reading tools. As a last resort, truncate inlined file contents (recoverable — the agent has read_code_components / str_replace_editor). Same guard on format_cluster_prompt. The duplicated tree-formatting closures are extracted into _format_module_tree_str. Prompts under the cap are byte-identical to before (verified against ml-agents, electron, and wazuh module trees).
  • Backends: gate the overview.md early-return on the root module (empty module_path) so every other module is checked against its own doc file.
  • Mechanical ruff cleanup on the touched backend files so the changed-files lint job passes.

anhnh2002 and others added 2 commits August 17, 2026 11:25
format_user_prompt embeds the whole module tree with every component
listed per file. On large repos (wazuh: 822 modules, ~823k chars) the
prompt exceeds codex's hard 1,048,576-char turn input limit
(input_too_large, code -32602), failing every remaining module. Same
bug family as the overview prompts fixed earlier on this branch.

Build the prompt unchanged first; only if it exceeds a 900k-char cap,
rebuild with a names-only tree (wazuh: 26k chars) plus a note pointing
the agent at its reading tools, and as a last resort truncate inlined
file contents. format_cluster_prompt gets the same guard. Prompts under
the cap are byte-identical to before. The duplicated tree-formatting
closures are extracted into _format_module_tree_str.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
run_module_agent (caw and pydantic-ai backends) and
generate_parent_module_docs returned early whenever overview.md was
present. overview.md only proves the ROOT module is done, so on a
resume after a partial run every nested module and parent without its
own doc file was silently skipped. Gate the overview.md check on the
root module (empty module_path) and let each module be checked against
its own doc file.

Also mechanical ruff cleanup on the touched files (Dict/List -> dict/
list, import sorting, format) so the changed-files lint job passes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@anhnh2002
anhnh2002 merged commit b243e0a into main Aug 17, 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