Engineering Practices for LLM Applications Under Service Quotas
This article translates common LLM service quota limits—session retention windows, input length caps, and daily usage ceilings—into architectural constraints. It explains how to externalize memory, compress long inputs, govern quota spending, and design graceful degradation so applications remain predictable when capacity fluctuates. It also outlines an observability baseline and a general capability combination on Baidu AI Cloud.
Recently, multiple users reported that a major LLM chat service imposed usage restrictions on long conversations across its web and mobile clients: sessions inactive beyond a certain period are no longer retained, single input text is compressed to roughly forty thousand characters, and once the daily conversation volume is exhausted, users are told the server is busy. As of the reporting of these accounts, the provider had published no standalone announcement and offered no timeline for quota restoration; users could only infer the rules indirectly from interface prompts and actual experience. For developers and enterprises that treat LLMs as a core component, this kind of change is not simply “use a little less.” It directly breaks existing architectural assumptions: sessions treated as persistent context storage, ultra-long texts fed in a single shot, and capacity planning extrapolated linearly from peak values. Setting aside the specifics of any particular product, this article abstracts the situation into an engineering problem for LLM applications under resource constraints, and discusses how to restructure context management, input handling, and quota governance under the expectation that limits are the norm, so the system still behaves predictably when supply fluctuates.
1. Three Layers of Quota Semantics: From Product Prompts to Architectural Constraints
Translating interface prompts into engineering language, the three types of limits correspond to three resource dimensions.
Session retention period: a time-validity constraint on state storage. Long conversations no longer being retained long-term is equivalent to platform-side session state degrading from “persistent” to “short-cycle cache.” Any design that treats a session ID as a long-term database primary key will fail.
Single input length: a context window constraint per request. Forty thousand characters roughly corresponds to tens of thousands of tokens in Chinese-language scenarios, which means the pattern of feeding an entire report, a complete codebase, or a batch of materials in one input is no longer reliable.
Daily call quota: a throughput allowance within a time window. Once exhausted, service is refused, and the recovery time point is opaque—equivalent to a token bucket with no SLA.
The conclusion from stacking these three together: the application layer must assume that “context may disappear at any time, inputs must be splittable, and quota may run out midway.”
2. Context Engineering: Do Not Treat Sessions as a Database
The correct approach is to treat a “session” as a volatile interaction channel and push “memory” down into storage owned by the application.
- Externalize memory: write facts, conclusions, and decisions that need long-term retention into your own object storage or relational database, carrying only the minimal necessary fragments inside the session.
- Layered summarization: after each turn, generate a structured summary (goal, constraints, confirmed conclusions, to-dos), and in the next turn substitute the summary for the raw long history.
- Retrieval-based injection: split historical material and build a vector index, then retrieve the Top-K fragments relevant to the current question and inject those, rather than feeding everything back in full.
Illustrative pseudocode:
# Sessions are volatile; memory persists. The application maintains state.def on_turn_end(session_id, messages):summary = summarize(messages) # structured summarystore.put(f"mem:{session_id}", summary) # write to own storageindex.upsert(session_id, chunk(messages))# update retrieval indexdef build_prompt(session_id, question):mem = store.get(f"mem:{session_id}") or {}hits = index.search(question, k=5) # take only relevant fragmentsreturn template(mem, hits, question) # minimally sufficient context
3. Input Compression: Completing Long-Text Tasks Within the Forty-Thousand-Character Limit
For ultra-long material, the core idea is “structure first, then divide and conquer, then merge.”
- Structural splitting: chunk by heading hierarchy, sections, or function boundaries, avoiding cuts in the middle of semantics; keep the source path and offset for each chunk to make citation traceback easy.
- Redundancy removal: deduplicate, strip boilerplate templates, and compress log noise, leaving the budget for effective information.
- Divide-and-conquer mapping: run map operations in parallel over chunks to produce local conclusions, then reduce them into a global conclusion; code material can be understood layer by layer after topological sorting by dependency.
- Budget control: set explicit allowances for “instructions + material + reserved output” to avoid truncated output.
Budget allocation example (total budget B)Instructions and constraints: 0.05BRetrieval/material: 0.70BReserved output: 0.25B
4. Quota Governance: Treat Allowance as a First-Class Citizen
When the daily quota is out of your control, what you can control is the cost-effectiveness of each request.
- Tiered routing: send simple intents to a smaller-parameter model or a rules engine, and escalate to a larger-parameter model only for complex reasoning.
- Cache first: build a semantic cache for high-frequency repeated questions; a cache hit returns immediately and directly saves quota.
- Batching and off-peak scheduling: merge non-real-time tasks into batches and run them during low-traffic periods.
- Circuit breaking and degradation: maintain a local token bucket to estimate remaining quota, and switch to “summary-only mode” or a queuing mode as the threshold approaches, avoiding a hard failure midway.
class QuotaGuard:def __init__(self, daily, used=0):self.cap, self.used = daily, useddef allow(self, cost):return self.used + cost <= self.capdef commit(self, cost):self.used += cost
5. Observability and Degradation Plans
A system in the era of quotas must have an “explainable path of behavioral degradation.” It is recommended to collect three kinds of metrics: the distribution of token consumption per turn, cache hit rate, and rejection/rate-limit error rate; and to configure monitoring alerts that automatically trigger degradation when the error rate rises. The suggested degradation order is: disable non-core enhancements (such as style polishing) → reduce the number of injected fragments → switch to a smaller model → enter a queue and clearly inform the user of the expected recovery window. Meanwhile, the product side should expose a queryable status for the quota reset time, instead of making users guess from error text.
6. A General Capability Combination from the Baidu AI Cloud Perspective
To implement the above on Baidu AI Cloud, you can combine general-purpose capabilities: use object storage to hold externalized memory and original long-text files, use a relational database to store structured summaries and the quota ledger, use a message queue for batch off-peak scheduling and peak shaving, use a container platform to host routing and circuit-breaking logic, and use log services plus monitoring alerts to build an observability system for tokens and rate limiting. The key is not the specific APIs, but making “volatile context, splittable input, limited quota” the architectural premise.
Conclusion: Quotas Are a Standing Assumption, Not a Temporary Fault
Whether quotas are eventually relaxed or persist long-term, engineering should never bet availability on “unlimited resources.” Once memory is externalized, input is divided and conquered, quota is budgeted, and behavior is degradable, supply fluctuations will only show up as differences in the experience layer, not escalate into business outages. For teams that rely on LLMs for daily work, knowing the quota rules and recovery expectations is just as important as obtaining compute itself.
