# How TencentDB Agent Memory Handles Verbose Intermediate Logs in Long-Horizon Tasks

> Learn how TencentDB Agent Memory manages verbose logs in long tasks using its dual logging system. Get detailed traces without impacting production traffic.

- Repository: [Tencent Cloud/TencentDB-Agent-Memory](https://github.com/TencentCloud/TencentDB-Agent-Memory)
- Tags: how-to-guide
- Published: 2026-08-24

---

**TencentDB Agent Memory employs a two-layer logging architecture that combines a global `log.verbose` flag with session-level `debugVerboseLogging` to capture detailed step-by-step traces of multi-turn sessions without polluting production traffic logs.**

This open-source proxy implements a dual-configuration system that allows developers to diagnose complex, long-horizon reasoning chains. By separating global request lifecycle logging from per-session pipeline state inspection, the system maintains high performance in production while providing granular visibility into cache hits, extraction decisions, and turn-sequencing across extended conversational sessions.

## Two-Layer Logging Architecture for Long-Horizon Tasks

The proxy distinguishes between **global** traffic logging and **session-specific** debugging to manage verbosity efficiently. This separation ensures that enabling detailed traces for a single long-horizon task does not force DEBUG-level noise across the entire process.

### Global Proxy Logger (`log.verbose`)

The global logger, implemented in [`MemoryProxy/src/report/log.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/report/log.ts), handles all request/response lifecycle events including upstream calls, rate-limiting, and storage operations. When enabled, it adds **DEBUG** level entries that contain intermediate payloads and timing information.

Configuration occurs via CLI flag or YAML:

- **CLI**: Pass `--verbose` or `-v`
- **YAML**: Set `log.verbose: true`

According to the source code in [`MemoryProxy/src/config.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/config.ts) (lines 84-86), the `buildConfig()` function merges these inputs during initialization. The logger writes to either Console or a rotating file (`proxy.log`), depending on the environment.

### Session-Level Debug Logger (`debugVerboseLogging`)

For granular inspection of individual long-horizon sessions, the system uses `sessionInit.debugVerboseLogging`, defined in [`MemoryProxy/src/config.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/config.ts) at line 427. This boolean defaults to `false` and is checked by the pipeline manager before emitting internal state dumps.

When activated, [`MemoryProxy/src/utils/pipeline-manager.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/utils/pipeline-manager.ts) prints the full `PipelineState` object after each turn using `console.log` statements. These logs expose:

- Cache layer interactions (`L1`, `L2a`, etc.)
- Extraction gating decisions
- Turn-sequencing state transitions

This approach isolates verbose intermediate logs to specific sessions, keeping the global logger clean for normal traffic analysis.

## Configuring Verbose Intermediate Logs

Enable verbosity at different scopes depending on whether you need process-wide diagnostics or targeted session tracing.

**Global verbose mode (all requests):**

```bash
proxy --verbose

```

**Process-wide via YAML:**

```yaml
log:
  verbose: true

```

**Session-level for specific long-horizon tasks:**

```yaml
sessionInit:
  debugVerboseLogging: true

```

The following TypeScript example demonstrates how the configuration objects interact:

```typescript
import { buildConfig } from "./config.js";

// CLI overrides enable global verbosity
const cfg = buildConfig({ verbose: true });

if (cfg.log.verbose) {
  // All log calls now emit at DEBUG level
  log.debug("proxy:verbose", { msg: "starting long-horizon task", taskId });
}

// Inside the pipeline manager (pseudo-code)
if (ctx.config.sessionInit.debugVerboseLogging) {
  console.log("[pipeline] state after turn", JSON.stringify(state, null, 2));
}

```

## Implementation Details in Source Code

The handling of verbose intermediate logs spans several critical files in the `MemoryProxy/src` directory.

### Extraction-Gate Diagnostics

In [`MemoryProxy/src/extraction-gate.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/extraction-gate.ts) (lines 390-424), the `logExtractionSkipped()` function checks the global `log.verbose` flag before printing detailed skip reasons, such as "extraction disabled for skill." This allows developers to trace why particular extraction steps were bypassed during multi-turn sessions.

### Pipeline State Inspection

The pipeline manager in [`MemoryProxy/src/utils/pipeline-manager.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/utils/pipeline-manager.ts) performs the heavy lifting for session-level verbosity. When `ctx.config.sessionInit.debugVerboseLogging` evaluates to `true`, the manager serializes the current pipeline context, including cache hit/miss statistics and extraction decisions, directly to stdout.

### Telemetry and Usage Logs

Even when `log.verbose` is enabled, telemetry payloads sent to ClickHouse, Opik, or Langfuse remain compact. As implemented in [`MemoryProxy/src/report/log.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/report/log.ts) (see comment at line 97), verbose logging only adds a `debug` field to the JSON payload rather than expanding the full message size. The [`MemoryProxy/src/session/init-telemetry.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/session/init-telemetry.ts) module captures first-sentence telemetry specifically for bypass paths when verbosity is required.

## Summary

- **Two-layer architecture**: Global `log.verbose` for process-wide DEBUG logs and `sessionInit.debugVerboseLogging` for per-session pipeline inspection.
- **Configuration sources**: CLI flags (`--verbose`), YAML settings, and programmatic `buildConfig()` overrides.
- **Key files**: [`MemoryProxy/src/config.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/config.ts) (configuration), [`MemoryProxy/src/report/log.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/report/log.ts) (global logger), [`MemoryProxy/src/utils/pipeline-manager.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/utils/pipeline-manager.ts) (session state), and [`MemoryProxy/src/extraction-gate.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/extraction-gate.ts) (extraction decisions).
- **Performance isolation**: Session-level logging prevents verbose intermediate logs from impacting global traffic log readability.
- **Telemetry safety**: Verbose mode adds debug metadata without bloating analytics payloads sent to external observability platforms.

## Frequently Asked Questions

### How do I enable verbose logging for a single long-horizon session?

Set `sessionInit.debugVerboseLogging: true` in your YAML configuration file. This activates detailed `console.log` output in [`MemoryProxy/src/utils/pipeline-manager.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/utils/pipeline-manager.ts) that dumps the full `PipelineState` after each turn, showing cache behavior and extraction decisions without enabling global DEBUG noise for other requests.

### What is the difference between global and session-level verbose logging?

Global `log.verbose` (enabled via `--verbose` or YAML) activates DEBUG-level entries in [`MemoryProxy/src/report/log.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/report/log.ts) for all requests, writing to either Console or `proxy.log`. Session-level `debugVerboseLogging` targets only specific long-horizon tasks, printing pipeline state via `console.log` only when that session is active.

### Where are verbose intermediate logs stored?

Global verbose logs emit to the configured `log` destination—either the Console or a rotating file (`proxy.log`)—as implemented in [`MemoryProxy/src/report/log.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/report/log.ts). Session-level verbose logs print directly to stdout via `console.log` statements in the pipeline manager, making them suitable for containerized environments where stdout is collected by log aggregators.

### Do verbose logs affect telemetry payload size?

No. According to [`MemoryProxy/src/report/log.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/report/log.ts), the `log.verbose` flag does not expand telemetry payload size for ClickHouse, Opik, or Langfuse sinks. It only injects a `debug` field into the JSON payload. The full verbose diagnostics remain in the proxy logs rather than being transmitted to external telemetry systems.