Technical document

AI Agent Platform Design with Shared Memory and Model Router

We explain a design that combines versioned shared memory, routing by Luna, the low cost and large capacity of GLM, and the delegation of difficult problems to Sol, to prevent sending confidential information to unauthorized models.
AI Development / Agent Platform~17 minPublication Date September 22, 2026Update date November 23, 2026
Illustration of an AI model router that safely distributes normal and difficult tasks, centered around shared memory.

Summary

Key points of this document

  • Before adding more models, fix the order of judgment.
  • Shared memory passes verifiable states, not conclusions.
  • Luna as a second-stage router before reading the main content.

Overview

While sending all tasks to the highest-tier model tends to stabilize quality, it quickly consumes costs and usage quotas. Conversely, uniformly directing tasks to inexpensive, high-volume models can lead to rework on difficult problems and the unauthorized transfer of information across boundaries. First establishing data boundaries, and then using shared memory and a model router within those boundaries, is a prerequisite for simultaneously managing quality, cost, and available capacity.

Before adding more models, fix the order of judgment.

In a platform using multiple models, the order of judgment is more important than a list of model names. First, classify the sensitivity of the input and references, then narrow down the allowed providers, and finally compare difficulty, cost, latency, and remaining quota. If cost is considered first, an irreversible failure can occur where confidential information is discovered after being sent to a cheaper model.

In this paper, Luna is treated as responsible for routing decisions, GLM for high-volume processing centered on public information, and Sol for difficult problems and approved confidential processing. However, this design does not make model names synonymous with permissions themselves. Actual permissions are determined by a policy that bundles provider, contract, processing region, retention period, learning usage, and auditability.

The term "shared memory synchronization" also refers to a generalized method where multiple agents exchange versioned work states, not a specific product or project name. Instead of sharing entire conversation histories without limit, only the minimum information necessary for the next agent to begin independent verification is synchronized.

  • Phase 1: Determine data classification and sendability.
  • Phase 2: Select candidates based on difficulty and cost from the allowed providers.
  • Phase 3: Determine the execution destination based on remaining quota, latency, and failure status.
  • Do not speculatively route unknown input to a cheaper path; instead, default to the confidential path or return it to a human.

Shared memory passes verifiable states, not conclusions.

If entire conversations, attachments, retrieved files, and tool results are saved directly to shared memory between agents, the scope of leakage expands along with convenience. The shared information should primarily consist of task ID, purpose, current state, assignee, summary of judgment, reference to evidence, verification results, unconfirmed items, and sensitivity labels. The secret content remains in its original storage location, and shared memory only holds references with authorization checks.

Updates use compare-and-swap with 'version' and 'expectedVersion'. If two agents update from the same version, one is stopped as a 409-equivalent conflict, and integration occurs after reloading the latest state. With last-write-wins, routing reasons, confidentiality labels, and unresolved verifications could be overwritten by older values.

Each item is tagged with source, createdAt, expiresAt, classification, and allowedProviders. Summaries generated by AI are saved with verified=false and are not treated as facts until another agent or human verifies the actual data. Preventing expired results from being automatically injected into new tasks is also necessary to avoid incorrect long-term memories.

  • Synchronize state, summary, references, and verification results, not the main content.
  • Do not silently resolve version conflicts; require re-reading and integration.
  • Make sensitivity and allowed providers mandatory items in the shared state.
  • Attach source, verification status, and expiration to AI-generated memories.
// Generalization example of shared memory
{
  "taskId": "architecture-review",
  "version": 12,
  "state": "needs_deep_review",
  "classification": "confidential",
  "allowedProviders": ["approved-sol-route"],
  "decisionSummary": "Refutation of boundary conditions required",
  "evidenceRefs": ["artifact://review-input/42"],
  "verified": false,
  "expiresAt": "2026-08-09T00:00:00Z"
}

Luna as a second-stage router before reading the main content.

If Luna is given a raw prompt and then asked 'which model to send it to,' the router itself becomes a destination for confidential information. Therefore, the first stage is a deterministic local process. It scans input fields, attachments, references, tool permissions, and shared memory to determine data classification and the provider allowlist. If confidential or undecidable, Luna is bypassed, and it is fixed to an approved path.

What Luna receives is routing metadata such as a publishable summary, language, input/output format, number of files to be changed, breadth of dependencies, required tools, number of attempts, test scope, and deadline. Luna returns candidates for normal processing, high-volume processing for GLM, difficult problems for Sol, and human confirmation. The final decision is made by a codified policy engine, and the allowlist is not extended solely by model output.

Difficulty cannot be measured solely by 'long text'. Authorization, migration, concurrent updates, financial calculations, external publication, irreversible rollbacks, and contract changes across multiple systems are high-risk even with short inputs. Conversely, classifying large volumes of public documents or performing standardized transformations, even with large token counts, are suitable for GLM if independent verification can be prepared.

// Pseudocode for routing order
const classification = classifyLocally(input, references);
const allowed = providerPolicy[classification];

if (classification === "unknown") return requireHumanReview();
if (allowed.equals(["approved-sol-route"])) return routeToSol();

const metadata = buildSanitizedRoutingMetadata(input);
const suggestion = await lunaSuggest(metadata);

return enforcePolicy({
  suggestion,
  allowedProviders: allowed,
  remainingQuota,
  riskSignals,
});

GLM's low unit cost and large usage quota are used for high-volume processing.

According to official information confirmed on August 8, 2026, GLM's standard API pricing is: GLM-4.7 at $0.60 USD per million input tokens and $2.20 USD per million output tokens; GLM-5.1 at $1.40 USD per million input tokens and $4.40 USD per million output tokens. At the same time, GPT-5.6 Sol is $5 USD for input and $30 USD for output, and Luna is $1 USD for input and $6 USD for output. The difference in token unit price alone is significant, making GLM meaningful for classifying public information, generating candidates, standardized transformations, and iterative processes that can be independently scored.

The nominal limits for Coding Plan are approximately 80 prompts per 5 hours and 400 per week for Lite; 400 and 2,000 for Pro; and 1,600 and 8,000 for Max. Official descriptions also indicate that one prompt roughly corresponds to 15-20 model calls. However, these limits are estimates and can change due to congestion, model, task complexity, and terms of service. The router does not embed fixed values but incorporates usage API or management screen values as operational settings.

It is important to note that the Coding Plan quota is not for general API use but is limited to personal use within officially supported coding tools. It cannot be repurposed for designs that call this quota from the backend of a self-made SaaS. For unsupported uses, standard APIs should be used, and contracts, rate limits, and resale restrictions should be checked separately. The cheaper and larger the quota, the more its usage conditions must be included as architectural assumptions.

  • Suitable for GLM: Public information, large volume, standardized, re-executable, mechanically scorable processes.
  • Suitable for Luna: Classification of routing metadata (excluding secrets) and general auxiliary judgments.
  • Suitable for Sol: Complex design, refutation, authorization, migration, irreversible judgments.
  • Set prices and quotas as configurable values with a confirmation date, do not hardcode them into articles or code constants.

Define conditions for escalating to Sol proactively, not after failure.

If delegating to Sol is only considered 'if GLM fails,' retries will consume cost and time, and incorrect changes will remain in shared memory. Authentication/authorization, data loss, migration, distributed updates, consistency across multiple providers, contract changes, irreversible rollbacks, and final pre-publication decisions should be sent to Sol as difficult problems from the outset.

Even for normal tasks, if the same test fails twice, Luna's difficulty assessment is high, the scope of impact expands midway, assumptions conflict between shared memory and actual code, or there is no reliable scorer, the task is escalated to Sol. The decision criteria include not only token count or file count but also potential loss upon failure and verifiability.

Results returned by Sol are not automatically correct. Final diffs, tests, static analysis, permissions, migration dry-runs, and rollback procedures must be verified with actual data. Delegating to high-performance models is not a reason to skip verification, but a means to concentrate computational resources on more difficult issues.

  • Pre-escalation: Permissions, migration, irreversible operations, multiple boundaries, processes with high potential loss.
  • Mid-process escalation: Repeated failures, expanding scope of impact, assumption mismatches, unscorable tasks.
  • Completion criteria: Determined by diffs and verification results, not by the model's self-declaration.

Stop confidential information before the provider boundary.

Judging security solely by the provider's country of origin overlooks contract differences, retention periods, processing regions, training use, administrator privileges, and audit functions within the same provider. In implementation, register approvedClassifications, retention, trainingUse, processingRegions, toolPermissions, and contractVersion for each provider, and ensure that the sending function itself fails if the confidential classification is not permitted for the path.

The classification target is not just the user's prompt. Secrets can also be present in system/developer instructions, shared memory, attachments, Git diffs, environment variables, tool results, search results, summaries of past turns, and error logs. Combine and scan everything immediately before creating the router input, and if even one secret candidate remains, fail-closed.

Redaction is a supplementary measure. Replacing secret values with local tokens and keeping the recovery table external can be used for routine processing, but the subject may sometimes be inferred from the context of the text, file names, or customer-specific data structures alone. Inputs that cannot produce a safe summary are not diluted and sent to GLM or Luna, but remain on an approved Sol path or for local processing.

  • public: Compare costs and quality within the provider allowlist.
  • internal: Only allow limited paths through anonymization and content inspection.
  • confidential: Fix to an organization-approved Sol path or local processing.
  • restricted / unknown: Do not send automatically; return for human verification.

Divide a single execution into classification, selection, verification, and recording.

At the start of execution, create a task envelope and record the input hash, classification, allowed providers, budget, deadline, required tools, and expected verification. After passing local classification, if no secrets are included, only routing metadata is passed to Luna, and the policy engine determines the candidates.

For processes sent to GLM, output schema, max tokens, timeout, retry count, and a scoring engine are mandatory. For example, for public document classification, we can check adherence to JSON Schema, not returning labels other than allowed ones, reproducibility for the same input, and citation positions from the extraction source. Results that do not pass the quality gate do not advance to 'verified' in shared memory.

When sending to Sol, distinguish and pass the reasons for the difficulty and facts confirmed by GLM or Luna. The final result includes route, model, policyVersion, classification, input hash, token, cost estimate, wait time, fallback, and verification results. It is also important not to duplicate the raw confidential text into the audit log.

In case of quota exhaustion or failure, fallback to a safe direction.

When GLM's usage quota decreases, for routine processing of public information, options include returning to the queue, switching to another allowed low-cost API, or escalating only urgent items to Sol. However, just because GLM is allowed does not mean it's acceptable to send to any provider in case of failure. Fallback destinations are also chosen within the allowlist of the same classification.

If Luna times out, do not infer-forward to GLM or Sol based on simple rules, but choose a definitive default path based on risk signals and classification. The order is: low-risk public processing to GLM, high-risk or unknown to Sol or human review. Ensure router failures do not become a bypass for information boundaries.

Partial success also requires attention. When eight out of ten items are processed by GLM and two are sent to Sol, maintain route and verification status at the item level, not the task level. Closing the entire task as successful would hide unprocessed items or different quality standards from shared memory.

  • quota shortage: Suspend low-priority tasks and reallocate using only allowed paths.
  • router failure: Use a definitive default path based on classification and risk.
  • model failure: Maintain timeout, retry limits, and circuit breakers per provider.
  • partial success: Save route, verification, and resume position for each item.

Observe misdelivery and rework, not just cost reduction.

If the success of the model router is measured only by 'reduced Sol usage,' it overlooks the cost of Sol redoing GLM's corrections and user wait times. Track first-pass rate per route, escalation rate to Sol, retry tokens, p50/p95 wait times, human rejections, and boundary rejection counts on the same screen.

The audit log retains routing decision, policyVersion, classification, allowed candidates, selection reason, fallback reason, input hash, token, estimated cost, and verification results. Prompt text, secret values, and attached content are not saved; if necessary, use references to access-controlled source data. This is to prevent the logging infrastructure itself from becoming a new leakage point.

When models, fees, or terms of service change, update the policyVersion and compare with a small amount of shadow routing. Even if the same public task is sent to candidate models to measure quality, cost, and time, only one production result is adopted. Confidential tasks must not be duplicated for shadow verification.

  • Efficiency: Token cost, total tokens, cost per completion including retries.
  • Quality: First-pass rate, escalation rate, rejections, unverified items.
  • Speed: Queue time, model time, verification time, p95.
  • Security: Cross-border rejection, unknown classification, allowlist violation, audit omission.

We prioritize validations that attempt to break boundaries over normal operations.

Unit tests confirm that public, internal, confidential, restricted, and unknown inputs result in the expected allowlist. We use spies to verify that secrets embedded not only in prompts but also in attachments, tool results, shared memory, and history summaries never cause Luna or GLM's send functions to be called.

For routing, we verify that the policy engine rejects Luna's proposals for out-of-allowlist GLMs, that confidential inputs do not flow to other providers when GLM quotas are exhausted, and that reasons for escalation to Sol are recorded. For shared memory, we validate concurrent updates to the same version, expiration, and handling of verified=false.

In E2E tests, we mock providers and inspect the envelope just before sending. Mocks that receive payloads containing potential secrets immediately fail the test. Finally, we smoke test that the same policy bundle hash as in production is deployed, that the body is not retained in audit logs, and that external providers can be stopped with a kill switch.

  • Even if secrets are mixed into something other than the prompt, unauthorized providers are not called.
  • Luna's suggestions cannot override policy.
  • Maintain classification even with quota shortages, timeouts, or partial successes.
  • Make policy changes, model changes, and fallback changes auditable.

This design still leaves classification errors and operational costs.

Local classifiers are not perfect. They may miss unknown secret formats, text in images, encrypted attachments, or information retrieved later by tools. Instead of defaulting unknowns to allow, we need to gradually add image OCR, archive expansion, reference inspection, and per-tool output classification.

If the shared memory summary is too small, Sol will re-investigate assumptions, increasing costs. If it's too large, old information and secrets will remain. We need to measure actual escalation rates and re-investigation times, and adjust schemas and TTLs for each task type. Not aiming for a single, universal memory format makes operations easier.

GLM's pricing and quotas, Sol and Luna's characteristics, and provider contract terms change. Therefore, instead of scattering model names throughout the source code, we manage capability, classification, cost, quota, and health as configurations. The figures in this article are as of August 8, 2026, and official information should be re-verified upon implementation.

The guiding principle to take away is to prioritize boundaries over cost.

The purpose of shared memory and the model router is not to show the same information to all models. It is to pass the minimum necessary state with versioning and first narrow down which models are allowed to see data based on its classification. Within that, Luna assists with distribution, GLM's low unit cost and large quota are used for high-volume processing, and Sol's computational resources are concentrated on difficult problems.

Safety is not a declaration of 'trusting a specific model,' but is built with a provider allowlist, local classification, fail-closed, separation of recovery tables, pre-send inspection, auditing, and boundary testing. Even if model names change, this order allows the same design decisions to be reused.

Initial applications are suitable for tasks that do not contain secrets and can be mechanically scored, such as classifying public documents or routine transformations. There, we measure cost per completion, initial pass rate, Sol escalation rate, and boundary rejections to confirm the reliability of the router itself before expanding the scope to secret processing.

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