Technical document

Designing and Measuring an OpenCode Adaptive Queue for GLM with a Logical Limit of 100

This article explains an OpenCode queue that combines a logical limit of 100, staged deployment, adaptive window, secret boundary, deadline, and verification responsibility to continuously feed independent read-only tasks to GLM-5.2.
AI Development / Parallel Processing~17 minPublication Date September 22, 2026Update date November 23, 2026
Illustration of controlling numerous GLM tasks with a central adaptive queue, with humans verifying the results.

Summary

Key points of this document

  • "100 parallel" is not the number of simultaneous launches, but the logical upper limit of the execution window.
  • Consolidating the path to GLM into OpenCode CLI
  • Before large-scale deployment, fail-closed with secret boundaries.

Overview

The "100 parallel" mentioned here does not mean 100 items were launched simultaneously. It's a design where the logical upper limit of the concurrent execution window is set to 100, starting with 4 items deployed at 1-second intervals, and the effective parallelism is constrained by success/failure feedback, CPU/RAM/file descriptor resource caps, and per-task deadlines. The important thing is not to reach the upper limit, but to safely replenish meaningful independent work and connect GLM's output to deterministic verification.

"100 parallel" is not the number of simultaneous launches, but the logical upper limit of the execution window.

When dealing with a large volume of AI processing, the number of tasks in a batch, the number of items that can be queued, the number of in-flight items sent to the provider simultaneously, and the number of processes that can be launched locally are different values. The '100' in this article refers to the logical upper limit of the concurrent execution window that the adaptive queue can take. It is not a setting to send 100 items simultaneously.

Effective parallelism is determined by the minimum of the adaptive window, local resource cap, and fixed upper limit. For example, even if the fixed upper limit is 100, if the resource cap calculated from available CPU, RAM, and file descriptors is 20, and the adaptive window based on provider response is 6, then actual concurrent execution is limited to 6 items. Increasing the upper limit will not allow execution beyond other constraints.

Ambiguity in this distinction leads to explanations not supported by actual measurements, such as '100 items launched simultaneously,' '100 times faster,' or 'stability verified up to 100 parallel.' 100 is a safety valve setting; to indicate performance, actual peak, success rate, timeout, processing time, and token count must be measured separately.

  • queued tasks: The total number of independent tasks waiting for execution.
  • in-flight calls: The number of calls sent to the provider and awaiting a response.
  • adaptive window: The current allowed number, which increases or decreases based on success and failure feedback.
  • logical limit: A fixed ceiling that is not exceeded under any conditions. In this article, it is 100.
// Concept of effective concurrency
effectiveConcurrency = min(
  adaptiveWindow,
  localResourceCap,
  logicalLimit, // 100
)

Consolidating the path to GLM into OpenCode CLI

If unique HTTP clients are added for each use case just because it's large-scale processing, authentication, endpoints, model IDs, timeouts, retries, and usage measurement become fragmented. Therefore, the execution path to GLM-5.2 is consolidated into OpenCode CLI, and the queue side only manages task classification, secret boundaries, process deadlines, deployment control, and metrics.

OpenCode will have a read-only auditing agent, rejecting write, edit, shell, subtask, and web access. Only the analysis target and output format are passed to the model; it is not responsible for implementation, merging, or deployment. It is also crucial not to treat states like missing final text, broken JSON, or provider error events (read mechanically from CLI exit codes and JSON events) as successful.

The purpose of consolidating the path is not to depend on a specific tool, but to be able to verify the communication contract with the provider in one place. Simply writing the model name in the settings does not confirm connectivity. The route and provider model are confirmed with actual call metrics, and in case of failure, process, format, 429, 5xx, and timeout are recorded separately.

  • OpenCode: Responsible for provider protocol, authentication store, model catalog, and JSON events.
  • Adaptive Queue: Responsible for classification, admission, deadlines, retries, parallelism, and metrics.
  • Parent Agent: Responsible for acceptance/rejection, actual changes, testing, high-impact decisions, and external operations.

Before large-scale deployment, fail-closed with secret boundaries.

The more parallelism is increased, the greater the risk of sending incorrect input widely at once. Therefore, the decision to send or not is made before adjusting processing capacity. Only PUBLIC or INTERNAL read-only analysis (after anonymization and content inspection) is sent to GLM. CONFIDENTIAL, SECRET, unclassifiable, or tasks requiring secret values are automatically rejected for safety.

The inspection target is not limited to the prompt body. Only relative paths are allowed for reference paths, and movement to parent directories, Git management information, environment files, credentials, secrets, private keys, certificates, state files, etc., are rejected. The body detects private keys, Bearer tokens, and assignment patterns for keys, tokens, and passwords. If suspicious strings remain even after redacting known patterns, the content is not sent.

Redaction is not a guarantee of safety. The target can sometimes be inferred from unique filenames, business terms, or data structures alone. Inputs that cannot be safely summarized are not diluted and sent; instead, they are retained by the parent agent or sent through an approved secure redaction channel. Since classification rejection is not a provider failure, error types are separated to avoid lowering the window for other safe tasks.

  • Sendable: PUBLIC, inspected INTERNAL, independent read-only analysis.
  • Not sendable: Unclassifiable, requires secret value, dangerous path, external write, high impact judgment.
  • After rejection: Do not resend the same input with only superficial changes; the parent should re-evaluate whether a safe summary can be created.

Separate arguments and deliverables into units that can be executed concurrently.

The premise of adaptive queues is that tasks are independent. Duplicating a large request like 'review everything' only leads to reading the same context repeatedly and giving the same feedback. Separate audit foci such as inventory for entry points and dependencies, errors for exceptions and retries, resources for resource release, edge cases for boundary values and race conditions, config for settings and ledgers, tests for existing tests and gaps, and counterexamples to disprove findings.

Each task is assigned a unique task ID, scope, audit focus, input classification, and expected deliverable format. Reading the same file from multiple perspectives is acceptable, but the same query should not be submitted redundantly. After completion, findings can be connected to subsequent practical work by separating them into triage, repair proposals, test proposals, counterexamples, and verification plans.

Not letting the queue empty and filling the slots are different. As long as safe, non-duplicate practical work remains, the next item is replenished with each completion event. Conversely, if natural work runs out, it terminates as an idle stop. No-ops solely to approach the upper limit, resending the same prompt, and padding that doesn't use deliverables are prohibited as they increase costs and pollute observations.

  • Independence: Multiple tasks do not own the same judgment or the same write.
  • Uniqueness: Detect duplicates using task ID and root cause fingerprint.
  • Connectivity: Connect findings to proposed fixes, test plans, counterexamples, and verification plans.
  • Natural termination: Record an idle stop when useful work has run out.

From an initial 4 and 1-second interval, it increases on success and halves on failure.

Provider processing capacity is not fixed; it varies with time, task length, and shared load. If all requests are sent at once up to the allowed limit at the start, many calls will be in-flight before the first failure signal returns. Therefore, the initial window is set to 4, and only one admission is made per second. The next item can be sent without waiting for a preceding response, but it will not be a burst.

The window is increased by 1 every time 3 consecutive successes occur, and halved if a provider-originated failure occurs. This is the additive increase/multiplicative decrease approach, which gradually probes for available capacity and quickly backs off when pressure is detected. Classification rejections and dangerous path rejections are not provider pressure, so they are excluded from window adjustment signals.

Before the logical upper limit of 100, a resource cap is set based on CPU, available memory, and file descriptors. OpenCode's child processes use sockets, pipes, configuration files, and standard output, so local resources may be exhausted before the model can respond. Settings, provider health, and terminal resources are observed separately.

// Pseudocode for adaptive window
window = min(initial_window, resource_cap, logical_limit)

for result in completion_stream:
    if result.is_policy_refusal:
        continue
    if result.is_provider_failure:
        success_streak = 0
        window = max(1, window // 2)
    else:
        success_streak += 1
        if success_streak >= 3:
            window = min(window + 1, resource_cap, logical_limit)
            success_streak = 0

Combine retry, deadline, and circuit breaker with different roles.

Unlimited retries for timeouts or 429s would cause old tasks to occupy slots for new tasks and resend the same context repeatedly. Retries are limited in number and include a short jitter. Each task has a deadline, and the entire run also has a separate deadline. The task deadline stops a single stagnation, and the run deadline limits the overall wall-clock time and external call count from above.

When a certain number of consecutive provider failures is reached, the circuit breaker opens, and during the cooling-off period, new calls are stopped. In this state, remaining tasks are not forced to be treated as successful, and the fallback reason is recorded. When success returns, operations are gradually resumed, not immediately returning to the previous high window.

Exploring replenishment sources also requires a deadline. If the process of finding the next task is slow, the queue stops in a state of 'there might still be work' even after provider calls have finished. By owning delayed exploration results without discarding them, and adhering to exploration unit and overall run deadlines, we can distinguish between an empty queue and stalled exploration.

  • Bounded retry: Limited retries only for temporary 429, 5xx, timeout, and process failures.
  • Task deadline: Prevents a single slow call from continuously occupying a slot.
  • Run deadline: Sets the overall stop time and records remaining items as incomplete.
  • Circuit breaker: Stops new submissions during consecutive failures, preventing amplification of provider pressure.

We measure not only the number of calls but also concurrency and adoption/rejection rates.

When processing large volumes, just looking at 'how many calls were made' doesn't tell you if the queue is healthy. In addition to calls, success, failure, timeout, retry, prompt token, and completion token, we record initial, peak, and final window, resource cap, provider error, fallback reason, replenishment count, duplicate rejection, exploration deadline, and idle stop.

It's also important not to save the model's output content to metrics. Logs should only retain route, model, count, tokens, concurrency, error type, and adoption/rejection counts and reasons. If prompts, raw responses, and sensitive values are duplicated to audit logs, the queue itself becomes a new channel for information leakage.

We also differentiate between adoption and success. Even if a provider call completes successfully, the content may not be correct. Success is the result of communication and format; adopted or rejected is a judgment made after the parent agent has verified evidence and tests. Without adoption/rejection reasons, we cannot compare how many GLM successes led to actual improvements.

// Example metrics without secrets
{
  "route": "opencode-cli",
  "model": "glm-5.2",
  "calls": 17,
  "successes": 5,
  "timeouts": 12,
  "retries": 12,
  "initialConcurrency": 4,
  "peakConcurrency": 6,
  "finalConcurrency": 5,
  "resourceCap": 20,
  "adopted": 0
}

Two actual measurements show differences in operating regions, not optimal values.

In one stable operation, with an effective concurrency of 3, there were 302 calls, 302 successes, 0 failures and timeouts, and a total of 217,844 tokens. In another load operation, with initial 4, peak 6, and resource cap 20, there were 17 calls, 5 successes, 12 timeouts, 12 retries, and a total of 2,364,476 tokens. The latter had a peak of 6, not reaching the resource cap of 20 or the logical limit of 100.

What can be directly inferred from these two is that in stable operation, many calls were completed without timeouts, and in the other operation, there were many timeouts and retries, with a large token volume recorded for few successes. Since this is not a controlled experiment with the same task difficulty, context length, provider state, and deadline, we cannot conclude that 'increased concurrency caused timeouts' or '3 is always optimal'.

Furthermore, these are not results measured in the vicinity of 100. 100 is a configured ceiling, and the actual measured range is from 3 to peak 6. To compare performance, you need to vary concurrency with the same task set, same deadline, and multiple runs, measuring completion time, success rate, p50/p95 latency, tokens, retries, and provider errors consistently.

  • Measured: Stable operation at low effective concurrency and load operation up to peak 6.
  • Not measured: 100 concurrent executions, success rate near 100, 100x speed improvement.
  • Not separated: Causality of concurrency, task granularity, context length, provider state, and deadline.
// Actual measurements generalized for public release
stable run
  calls=302, success=302, timeout=0
  effective concurrency=3
  total tokens=217,844

pressure run
  calls=17, success=5, timeout=12, retries=12
  initial=4, peak=6, resource cap=20
  total tokens=2,364,476

We do not equate GLM success with completion of a fix.

GLM can broadly handle exploration, auditing, refutation, proposed fixes, and test plans, but its output is untrustworthy. It may return suggestions based on non-existent symbols, false positives already defended at a higher level, or proposals reading old configurations. If successful responses are directly proceeded to patch, merge, and deploy, errors parallelized in large volumes will spread at the same speed.

For each finding, the parent agent collates actual code, canonical code, diffs, deterministic tests, and runtime proofs, and records the reasons for adoption or rejection. Writes to the same file, same symbol, generated products, DB, state, and lockfile are fixed to a single owner. Even if independent files can be written, generation, formatting, migration, and deployment are returned to a serial gate after merging.

If a finding arises during an audit, we don't stop the queue just for confirmation. Triage, repair proposals, test proposals, counterexamples, and verification plans are supplemented as independent read-only tasks, and the parent integrates them into a single fix. With this connection, model usage doesn't end with just problem discovery but leads to verifiable improvements.

  • GLM: Read, candidate generation, refutation, verification plan.
  • Single write owner: Implementation, conflict resolution, generated products, state changes.
  • Deterministic verifier: Lint, typecheck, unit test, integration test, runtime proof.
  • High-impact gates: Permissions, migration, external publication, merge, deploy, rollback.

Not suitable for tasks with low independence or tasks without verifiers.

This method is suitable for tasks that can be divided into different subjects or different audit focuses, and whose results can be verified mechanically or independently. These include searching for inconsistencies across many files, collating configuration ledgers, enumerating boundary values and exception paths, and identifying deficiencies in existing tests.

Conversely, it is not suitable for tasks that require continuous sharing of a single design decision, tasks that involve frequent writes to the same file, migration or state changes, investigations requiring credentials, or creative judgments for which there is no way to determine the correct answer. If indivisible tasks are forcibly expanded into 100 slots, integration work and false positive confirmations increase, making it slower than serial execution.

The decision to lower the limit is also part of operations. If timeout rates, 429/5xx errors, p95 latency, retry tokens, local memory, and FD usage increase, and completion time does not shorten even when the window is widened, review task granularity, context amount, deadline, and replenishment methods before the limit. Maintaining a circuit breaker until provider health returns may lead to faster recovery than continuing calls.

  • Suitable tasks: Independent audits, configuration collation, refutation, test perspectives, classification of public information.
  • Unsuitable tasks: Secret-dependent, writes to shared state, irreversible operations, unscoreable judgments.
  • Scaling down conditions: Timeout, retry, p95, resource usage increase, throughput does not improve.

The decision criteria to take away are feedback and verification, rather than limits.

The logical limit of 100 is a ceiling to accommodate many independent tasks in the future. Actual operation starts small with an initial 4 items, 1-second intervals, increment on success, halving on failure, resource caps, deadlines, and circuit breakers. Even if 100 is not reached, if meaningful work can be replenished after each completion and stable throughput maintained, the design's objective is met.

The key to transforming a large number of model calls into a safe development process lies in the secret boundary before transmission and the verification boundary after response. Only independent read-only tasks that are safe to send are allowed, GLM results are treated as untrusted, and acceptance or rejection is determined by a single write owner and deterministic verifier. It is more important to design what to reject, when to scale down, and how to verify, rather than the number of parallelisms.

Technical documents

We will continue to increase technical documentation.

We will continue to organize our thoughts on AI, cloud, business app development, requirements definition, and operational design into documents.

Go to technical documentation list