Skip to content

fix: raise pydantic-ai request_limit for complex modules and make it configurable - #115

Draft
fabceolin wants to merge 2 commits into
FSoft-AI4Code:mainfrom
fabceolin:fix/request-limit-complex-modules
Draft

fabceolin wants to merge 2 commits into
FSoft-AI4Code:mainfrom
fabceolin:fix/request-limit-complex-modules

Conversation

@fabceolin

@fabceolin fabceolin commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

pydantic-ai's own default (UsageLimits(request_limit=50)) is too low for "complex" modules whose agent loop reads several code components and/or spins off sub-module docs via generate_sub_module_documentation_tool.

On a real-world run (voll-intelligence, a 5,381-file TypeScript monorepo, 16,720 functions), 4 modules hit UsageLimitExceeded mid-run and were skipped outright:

ERROR    Failed to process module app_integration_bff/app_integration_travel_search: The next request would exceed the request_limit of 50.

No retry, no fallback to the configured fallback-model, and no CLI flag to raise the limit.

Fix

  1. Raise the default limit to 100 via UsageLimits(request_limit=100), passed explicitly to both agent.run(...) call sites in pydantic_ai_backend.py (run_update_agent and run_module_agent).
  2. Make the limit a real, first-class configuration knob instead of a hardcoded constant — some repos/modules need more than 100 requests per agent run. request_limit now follows the exact same pattern as the other generation knobs (max_tokens, max_token_per_module, ...):
    • Config.request_limit in the backend (codewiki/src/config.py), default DEFAULT_REQUEST_LIMIT = 100
    • --request-limit on codewiki generate and codewiki config set
    • persisted in ~/.codewiki/config.json, shown in codewiki config show (text and --json)

Usage

# One-off override for this run
codewiki generate --request-limit 200

# Persist a higher default
codewiki config set --request-limit 200
codewiki config show

Validation

  • All 4 modules that previously failed with request_limit=50 succeeded on the exact same input once the limit was raised to 100, with no other change.
  • Config.from_cli(...) with and without a request_limit override; PydanticAIBackend._agent_usage_limits picks up the configured value.
  • Configuration.to_dict/from_dict/to_backend_config round-trip for request_limit.
  • codewiki config set --request-limit N + codewiki config show end-to-end (isolated HOME).
  • codewiki generate --help shows the new flag; invalid (< 1) values are rejected the same way as the sibling max_* options.

🤖 Generated with Claude Code

pydantic-ai's own default (UsageLimits(request_limit=50)) is too low for
"complex" modules whose agent loop reads several code components and/or
spins off sub-module docs via generate_sub_module_documentation_tool.

On a real-world run (voll-intelligence, a 5,381-file TypeScript monorepo,
16,720 functions), 4 modules hit UsageLimitExceeded mid-run and were
skipped outright — no retry, no fallback to the configured fallback-model,
and no CLI flag to raise the limit. All 4 succeeded on the same input once
the limit was raised to 100, with no other change.
@fabceolin
fabceolin marked this pull request as draft September 25, 2026 11:53
The previous commit fixed UsageLimitExceeded on complex modules by raising
pydantic-ai's request_limit from 50 (its own default) to 100, but hardcoded
the new value with no way to tune it. Some repos/modules need more than
100 requests per agent run, so expose it the same way as the other
generation knobs (max_tokens, max_token_per_module, ...):

- Config.request_limit (backend), default DEFAULT_REQUEST_LIMIT = 100
- --request-limit on `codewiki generate` and `codewiki config set`
- persisted in ~/.codewiki/config.json, shown in `codewiki config show`
@fabceolin fabceolin changed the title fix: raise pydantic-ai request_limit from 50 to 100 for complex modules fix: raise pydantic-ai request_limit for complex modules and make it configurable Sep 25, 2026

This branch has not been deployed

No deployments
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