Problem
The provider loops limit individual tool results, but do not bound the accumulated conversation sent on subsequent requests. Productive sequences of distinct calls can therefore replay a growing history until requests become expensive or exceed a model's context window.
This remains an issue even after repeated-state suppression and no-progress detection: legitimate calls with unique arguments still accumulate.
Evidence and reproduction
Audited main at 7289751459ceace471ac771f3a0ec39b972d1949. Area: AI provider orchestration. Findings come from source inspection and isolated Python execution of the relevant source functions with mocked CAD/model boundaries; no paid model requests or live CAD mutations were made.
An isolated execution of the Gemini child used 65 distinct tool calls, each returning a 20,024-byte projected tool result, below the individual 40 KiB bound. The context used the native engine so repeated vibecad_state_after was absent. The final outbound request serialized to 1,317,904 bytes. Earlier tool results were all replayed; no cumulative budget intervened.
This is a synthetic byte measurement, not an exact token count or a claim that every supported model rejects that particular size. Prompt caching may reduce processing charges on cache hits but does not remove logical context length.
Proposed fix
Add provider-aware input-history accounting before each request, including tools, system instructions, image context, and output reserve. Use a configurable high-water policy to compact or replace obsolete historical observations with bounded summaries/references before a hard limit is reached. Record actual provider usage where available and clearly distinguish estimates from measured tokens.
Preserve the current user obligation, live exact CAD state/revisions, unresolved operations, required tool-call/result pairs, and provider thought/signature requirements. Keep full source/API read tools available; handle large results deliberately rather than silently truncating exact source.
Acceptance tests
- A productive sequence of distinct results crosses the configured threshold and triggers controlled history management before another oversized request.
- Tool-call/result pairing and Gemini thought signatures remain valid.
- Critical revisions, pending jobs, failures, and user constraints survive compaction.
- Source/API reads and image-heavy turns are included in the budget policy.
- Short turns incur no additional model call.
- Compare cumulative request bytes, request count, and measured usage where available before/after.
Suggested priority: high for long sessions. This extends #130 and is separate from no-progress loop protection. Follow the repository's additive compatibility policy for new configuration and history-management behavior.
Problem
The provider loops limit individual tool results, but do not bound the accumulated conversation sent on subsequent requests. Productive sequences of distinct calls can therefore replay a growing history until requests become expensive or exceed a model's context window.
This remains an issue even after repeated-state suppression and no-progress detection: legitimate calls with unique arguments still accumulate.
Evidence and reproduction
Audited
mainat7289751459ceace471ac771f3a0ec39b972d1949. Area: AI provider orchestration. Findings come from source inspection and isolated Python execution of the relevant source functions with mocked CAD/model boundaries; no paid model requests or live CAD mutations were made.stop_reason == "max_tokens"), not input-history growth. A request rejected for excessive input does not reach that successful-response branch.An isolated execution of the Gemini child used 65 distinct tool calls, each returning a 20,024-byte projected tool result, below the individual 40 KiB bound. The context used the native engine so repeated
vibecad_state_afterwas absent. The final outbound request serialized to 1,317,904 bytes. Earlier tool results were all replayed; no cumulative budget intervened.This is a synthetic byte measurement, not an exact token count or a claim that every supported model rejects that particular size. Prompt caching may reduce processing charges on cache hits but does not remove logical context length.
Proposed fix
Add provider-aware input-history accounting before each request, including tools, system instructions, image context, and output reserve. Use a configurable high-water policy to compact or replace obsolete historical observations with bounded summaries/references before a hard limit is reached. Record actual provider usage where available and clearly distinguish estimates from measured tokens.
Preserve the current user obligation, live exact CAD state/revisions, unresolved operations, required tool-call/result pairs, and provider thought/signature requirements. Keep full source/API read tools available; handle large results deliberately rather than silently truncating exact source.
Acceptance tests
Suggested priority: high for long sessions. This extends #130 and is separate from no-progress loop protection. Follow the repository's additive compatibility policy for new configuration and history-management behavior.