You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--max-tokens-per-node is not actually enforced during prompt construction.
no CAPPING based on MAX_TOKEN supported by model , maybe adding a MAX_TOKEN FLAG can be useful ?
Functions like generate_toc_init, generate_toc_continue, and ChatGPT_API_with_finish_reason appear to send raw or multi-page inputs to OpenAI without validating token length.
The system assumes high-context models (e.g., GPT-4-32k), but fails silently on lower ones.
Expected Behavior
The CLI should:
Clip or truncate input prompts based on --max-tokens-per-node
Warn or skip LLM usage if the input exceeds model limits
Avoid crashing if the API call returns an unexpected format (unpacking issue)
Suggested Fixes
Enforce prompt length budget:
Add count_tokens(prompt, model) checks before each LLM call ?
Truncate input text or skip summarization if it exceeds max-tokens-per-node ?
Improve error handling:
Safeguard unpacking in ChatGPT_API_with_finish_reason() with:
Test setup:
PageIndexCLI (main branch, April 27)gpt-4o-mini(context ~8k tokens)Observed Behavior
Repeated 413 errors (
tokens_limit_reached) from OpenAI API despite:--max-tokens-per-node 100)gpt-4o-mini)Eventually crashes with:
Excessive retries: code continues attempting oversized calls without checking token count.
Root Cause (Hypothesis)
--max-tokens-per-nodeis not actually enforced during prompt construction.generate_toc_init,generate_toc_continue, andChatGPT_API_with_finish_reasonappear to send raw or multi-page inputs to OpenAI without validating token length.Expected Behavior
--max-tokens-per-nodeSuggested Fixes
Enforce prompt length budget:
count_tokens(prompt, model)checks before each LLM call ?max-tokens-per-node?Improve error handling:
ChatGPT_API_with_finish_reason()with:Add a
--safe-modeor--skip-llmflag to avoid LLM calls altogether for lightweight use ? add --max_total_tokens flag ?Confirmed Working (Sanity Check)
gpt-4o-mini— confirming it’s a token overflow issue.