Adapting LLM Apps to Rate Limits: Context, State, and Budget Architecture
This article explains how to redesign LLM-powered applications when a shared inference service tightens usage limits. It breaks down the three dimensions of quotas—context length, session retention, and call frequency—and maps each to concrete architecture changes: context budgeting with rolling summaries, externalized session state, tiered caching and semantic deduplication, asynchronous batch processing, and observability with budget alerts. A practical engineering checklist is included to help teams keep user experience stable as quotas shrink.
1. The Signal: What Quota Tightening Tells Us About Resource Governance
Users have recently reported that a class of conversational LLM services began tightening long-conversation capabilities in mid-November: inactive historical sessions are no longer retained, the text volume allowed in a single prompt has been reduced to roughly 40,000 characters, and daily limits now apply to the number of conversation turns and generations. Earlier in the year, the same type of service had already reduced the number of input edits and repeated generations allowed.
Put together, the conclusion is straightforward. A publicly available, free inference service is fundamentally shared scheduling over finite compute. Any expectation of “unlimited volume, unlimited length, unlimited retention” conflicts with the cost model. Rate limits are therefore not a product defect but an inevitable resource governance mechanism.
For developers, the real task is not to complain about quotas but to reshape application architecture from “assume resources are infinite” to “assume resources are scarce and fluctuating.”
2. The Three Dimensions of Rate Limits and Their Technical Implications
1. Context length limit
A cap on single-input size directly breaks the “stuff an entire manual into the prompt” approach. It requires moving long-document handling to retrieval augmentation: split documents, vectorize them, retrieve a few relevant chunks per question, and assemble those chunks into the prompt.
2. Session history retention policy
Reclaiming inactive sessions means conversation state cannot rely solely on platform-side storage. Session history should be externalized to your own storage, with the business side owning lifecycle management and hot/cold tiering.
3. Call frequency and daily quota
Edits, regenerations, and concurrent requests all consume quota. You need request budgets, deduplication, caching, and queuing to turn “users casually refreshing” into “controlled calls.”
3. Architecture Changes
1. Context budget and compression
Set a hard budget for the prompt and allocate it by priority: system instructions > current question > retrieved chunks > history summary.
def build_prompt(system, question, retrieved, history_summary, budget=12000):parts = [("system", system), ("q", question),("ctx", "\n".join(retrieved)), ("hist", history_summary)]used, out = 0, []for role, text in parts:cost = len(text)if used + cost > budget:text = text[: max(0, budget - used)]cost = len(text)out.append((role, text)); used += costif used >= budget:breakreturn out
Do not stack raw conversation history. Use rolling summaries instead: at the end of each turn, merge the old summary with the new conversation into a shorter summary whose length stays roughly constant.
2. Externalize session state
Write raw session content to your own storage keyed by session ID; the platform side handles inference only. A conversation can continue past the retention window because the state lives on the business side.
3. Tiered caching and semantic deduplication
Identical requests hit the cache directly; similar questions are merged via vector similarity to avoid wasting quota. Meter and rate-limit write operations (edits, regenerations) separately.
4. Batching and asynchrony
Send non-real-time tasks (batch summarization, offline labeling) to a message queue and consume them at a steady rate within the quota, smoothing peaks and filling valleys.
5. Observability and budget alerts
Instrument each call type: input length, output length, cache hit rate, remaining quota. Set threshold alerts and automatically degrade to retrieval-summary mode as the limit approaches.
4. Engineering Checklist
- On the input side, pre-check and truncate length; split and ingest oversized documents first.
- On the session side, define inactive-reclaim and archival policies with hot/cold tiered storage.
- On the call side, implement token-bucket rate limiting, idempotency keys, and retry backoff.
- On the quality side, build an evaluation set for summaries and retrieved chunks to prevent off-topic answers after compression.
- On the cost side, allocate quota per business line and keep an elastic scaling path, switching to self-hosted or higher-assurance service tiers when necessary.
5. Conclusion
Rate limits are a normal constraint of shared inference services. Make these five things solid—context compression, externalized state, caching and deduplication, asynchronous batching, and observable budgets—and your application will keep a stable experience even as quotas tighten, instead of being thrown off rhythm by a single announcement.
