Fix module/cluster prompts exceeding codex input cap; fix resume skipping missing module docs - #94
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two independent failures observed while generating docs for wazuh (822 modules, 20.8k components):
input_too_largeon module generation.format_user_promptinlines 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_prompthas the same exposure.Resume silently skipped missing docs.
run_module_agent(caw and pydantic-ai backends) andgenerate_parent_module_docsreturned early wheneveroverview.mdexisted.overview.mdonly 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 exceedsMAX_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 hasread_code_components/str_replace_editor). Same guard onformat_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).overview.mdearly-return on the root module (emptymodule_path) so every other module is checked against its own doc file.