TencentCloud/TencentDB-Agent-Memory · warning

[offload-client] compaction returned ${response.status}

Error message

[offload-client] compaction returned ${response.status}

What it means

OffloadApiClient.compaction POSTs the current conversation to /v2/offload/compact and is documented to return null on timeout/failure so the caller keeps the original uncompressed messages. This warning is logged when the server answers with a non-2xx HTTP status; the method then returns null. Losing compaction degrades token savings but never breaks the conversation.

Source

Thrown at MemoryCore/src/offload-client/offload-api-client.ts:153

      total_tokens: req.totalTokens,
      message_tokens: req.messageTokens,
    });

    try {
      const controller = new AbortController();
      const timer = setTimeout(() => controller.abort(), this.config.compactionTimeoutMs);

      const response = await fetch(url, {
        method: "POST",
        headers: this.buildHeaders(),
        body,
        signal: controller.signal,
      });

      clearTimeout(timer);

      if (!response.ok) {
        this.logger.warn(`[offload-client] compaction returned ${response.status}`);
        return null;
      }

      const json = (await response.json()) as any;
      if (json.code !== 0 || !json.data) {
        this.logger.warn(`[offload-client] compaction error: ${json.message ?? "unknown"}`);
        return null;
      }

      return { messages: json.data.messages, report: json.data.report };
    } catch (err) {
      this.logger.warn(`[offload-client] compaction failed: ${err}`);
      return null;
    }
  }

  private buildHeaders(): Record<string, string> {
    return {

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Read the status code in the warning: fix apiKey/serviceId for 401/403, serverUrl for 404, and check server health/logs for 5xx.
  2. Verify server reachability with checkHealth() before relying on remote compaction.
  3. Confirm the caller handles the null return by falling back to the original messages (the intended contract).
  4. Reduce payload size (send fewer messages or pre-trim) if the status is 413.
  5. Retry after transient 5xx; compaction is idempotent per call.

Example fix

// before: assume compaction always succeeds
const result = await client.compaction(req);
messages = result!.messages;
// after: honor the null fallback contract
const result = await client.compaction(req);
if (result) {
  messages = result.messages;
} else {
  logger.warn("compaction unavailable, keeping original messages");
}
Defensive patterns

Strategy: fallback

Validate before calling

const health = await client.checkHealth();
if (!health) {
  logger.warn("offload server down — using local messages without compaction");
}

Type guard

function isCompactionResult(r: CompactionResult | null): r is CompactionResult {
  return r !== null && Array.isArray((r as CompactionResult).messages);
}

Try / catch

const result = await client.compaction(req).catch(() => null);
if (isCompactionResult(result)) {
  messages = result.messages;
} else {
  logger.warn("compaction unavailable — keeping original messages");
}

Prevention

When it happens

Trigger: compaction() is called and fetch() resolves with response.ok === false: 401/403 from invalid apiKey or X-TDAI-Service-Id, 404 from wrong serverUrl or pre-v2 server, 413 when the messages array exceeds server body limits, 5xx when the server's compaction pipeline fails. (Timeout/abort and JSON code!==0 paths log different messages.)

Common situations: Offload server down or upgraded to a different API path; credentials rotated without updating OffloadClientConfig; very large context_window conversations producing oversized request bodies; server-side model/backend outage causing 502/503.

Related errors


AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01). Data as JSON: /api/errors/1999b1bd2de53a16. Report an issue: GitHub.