Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: add debug docs

huanggawaedee3ee6b03b
diff --git a/docs/en/DebugTrace.md b/docs/en/DebugTrace.md
new file mode 100644
index 0000000000..1ca5e699e3
--- /dev/null
+++ b/docs/en/DebugTrace.md
@@ -0,0 +1,445 @@
+# Debug Trace
+
+JiuwenSwarm's debug tracing provides unified observability across **Agent and Code modes**, helping you reconstruct the full behaviour of a conversational run:
+
+- **Local debug dump**: a human-readable plain-text record of the run's **model output, reasoning, tool calls and results, and token usage**, written per run — works out of the box with no backend.
+- **Structured OTel trace** (optional): standard `gen_ai.*` spans exported via OTLP to backends such as Langfuse / Jaeger / Grafana for latency analysis and cross-run aggregation.
+- **Subagent data flow**: when the main agent delegates to a subagent (builtin or custom), the subagent's internal reasoning and tool calls also land in the same dump — no longer a "black box".
+
+The `/debug` directive and its parsing primitive are shared across both modes. The local-dump and OTel paths are independent yet cross-referenceable via `trace_id`.
+
+---
+
+## 1. Overview
+
+### 1.1 What problem it solves
+
+When debugging a misbehaving agent, the most common questions are:
+
+- What did the model actually output this round? Did it drift off-topic?
+- Which tools did it call? With what arguments? What did they return?
+- How many tokens did this round cost? How long did it take?
+- When it dispatched a subagent, what happened inside that subagent?
+
+Routine application logs (see [Logging System](Logs.md)) target system operation status, are scattered by component, and rarely tell "the full story of one run". Debug tracing is built for exactly this: **organised per run, in time order, focused on model and tool behaviour**, written to a single file you can read directly.
+
+### 1.2 Core capabilities
+
+| Capability | Description |
+|------------|-------------|
+| Request-level trigger | Type `/debug <your question>` to enable the dump for just this round — no config change |
+| Config-level always-on | Turn the dump on globally or per-mode in `config.yaml` |
+| Unified across modes | Agent / Code both support `/debug`, sharing one directive primitive |
+| Subagent data flow | Records the full flow of builtin subagents (TaskTool) and custom subagents (AgentTool), tagged by source |
+| Structured OTel (optional) | Emits standard `gen_ai.*` spans, backend-agnostic, cross-referenceable with the local dump |
+| Local offline upload | With the OTel `file` exporter, spans can be batch-uploaded to Langfuse later |
+| Safe | Secret-like fields are always masked; large payloads are truncated; write failures never affect the model run |
+
+### 1.3 Mode support
+
+Both modes support debug tracing; they differ only in the dump directory and the config block used:
+
+| Mode | `/debug` | Local dump file | OTel config block |
+|------|----------|-----------------|-------------------|
+| `agent.plan` / `agent.fast` | ✅ | `~/.jiuwenswarm/.agent/traces/dump-agent-<session>.txt` | `agent_observability` |
+| `code.normal` / `code.plan` | ✅ | `~/.jiuwenswarm/.code/traces/dump-code-<session>.txt` | `agent_observability` |
+
+> Both modes share the same OTel backend stack (OTel Collector + Langfuse). See [Section 5](#5-local-file-mode-offline-upload-to-langfuse) and `deploy/observability/`.
+
+---
+
+## 2. Prerequisites
+
+### 2.1 Base environment
+
+| Item | Description |
+|------|-------------|
+| Config file | `~/.jiuwenswarm/config/config.yaml` (default template: `jiuwenswarm/resources/config.yaml`) |
+| Data directory | `~/.jiuwenswarm/`; override with the `JIUWENSWARM_DATA_DIR` env var |
+| Entry point | `/debug` is a TUI / Web frontend slash command, passed through to the backend for parsing |
+
+---
+
+## 3. Quick Start
+
+In any mode, type:
+
+```
+/debug help me fix the failing tests in tests/test_login.py
+```
+
+After the round finishes, open the dump for the current mode to see the complete record (model output, every tool call and result, token usage, elapsed time — and if a subagent was dispatched, the subagent's full behaviour):
+
+```
+~/.jiuwenswarm/.agent/traces/dump-agent-<session_id>.txt # Agent mode
+~/.jiuwenswarm/.code/traces/dump-code-<session_id>.txt # Code mode
+```
+
+**No config change required.**
+
+---
+
+## 4. Usage
+
+> The sections below are organised by *what you want to do*; all of them apply to Agent / Code alike — there is no per-mode split.
+
+### 4.1 Ad-hoc debugging of one request (request-level)
+
+For "it occasionally breaks and I don't want to change config". Prefix any message with `/debug`:
+
+```
+/debug <your question>
+```
+
+- Effective for **this round only**; subsequent rounds return to normal.
+- A bare `/debug` (no question) is rejected, so an empty request never reaches the model.
+- In Plan mode, even if a `<system-reminder>` block is injected before `/debug`, it is still recognised.
+
+### 4.2 Always-on dump (config-level)
+
+For "I always want a record for a certain mode". Edit `~/.jiuwenswarm/config/config.yaml`:
+
+```yaml
+debug_trace:
+ enabled: true # always-on globally (all Agent / Code sub-modes)
+ # or only for a specific mode:
+ # agent:
+ # enabled: true
+```
+
+Takes effect on the **next request** (each run reads the latest config — hot-reloadable).
+
+### 4.3 Tracing subagent data flow
+
+When the main agent delegates work to a subagent (the builtin `task` tool, or a custom agent created via `/agents`), the subagent's full behaviour appears automatically in the dump, distinguished by a `source=` tag:
+
+| Source tag | Meaning |
+|------------|---------|
+| `source=main` | The main agent itself |
+| `source=subagent:builtin:<type>` | A builtin subagent (e.g. explore / plan / code / browser) |
+| `source=subagent:custom:<name>` | A custom subagent created via `/agents` |
+
+Enabled by default. To stop recording subagent flow (Agent / Code only), turn it off in config:
+
+```yaml
+debug_trace:
+ agent:
+ include_subagent_flow: false
+```
+
+> When off, the subagent still executes normally — it just is not written to the dump (behaviour identical to having debug disabled).
+
+### 4.4 Reporting structured OTel traces
+
+OTel supports four exporter modes — pick by whether you are always online:
+
+#### 4.4.1 OTLP gRPC → Collector → Langfuse (recommended, always-online)
+
+The app sends spans to the local Collector; Langfuse credential auth is handled by the Collector. Start the stack first:
+
+```bash
+cd deploy/observability
+docker-compose up -d
+```
+
+Then configure (`agent_observability` for Agent/Code):
+
+```yaml
+agent_observability:
+ enabled: true
+ exporter: otlp_grpc
+ endpoint: http://localhost:4317
+ sample_rate: 1.0
+```
+
+#### 4.4.2 OTLP HTTP → Langfuse direct (always-online, bypasses Collector)
+
+```yaml
+agent_observability:
+ enabled: true
+ exporter: otlp_http
+ endpoint: https://cloud.langfuse.com/api/public/otel/v1/traces
+ langfuse_public_key: "pk-lf-xxx"
+ langfuse_secret_key: "sk-lf-xxx"
+```
+
+#### 4.4.3 Local `file` mode + offline upload (offline / two-phase)
+
+For when you cannot stay connected to a backend, or want to accumulate a batch of traces before replaying. See [Section 5](#5-local-file-mode-offline-upload-to-langfuse).
+
+#### 4.4.4 console (quick verification)
+
+```yaml
+agent_observability:
+ enabled: true
+ exporter: console
+```
+
+Spans are printed as JSON to the console — handy for a quick local wiring check.
+
+---
+
+## 5. Local file mode: offline upload to Langfuse
+
+When you cannot (or don't want to) stay connected to a Collector, use the `file` exporter to write spans to local disk, then batch-upload them later with `deploy/observability/upload_traces_to_langfuse.py`. This is the "two-phase" approach offered by the deploy stack and **works for Agent / Code alike**.
+
+### 5.1 How it works
+
+```
+ App (file exporter) ──writes──► ~/.jiuwenswarm/.trace/traces-<YYYY-MM-DD>.jsonl
+ │
+ upload_traces_to_langfuse.py
+ ▼
+ Local OTel Collector (:4318) ──OTLP HTTP + Basic Auth──► Langfuse (:3000)
+```
+
+- The `file` exporter writes spans into **one per-day** `traces-<YYYY-MM-DD>.jsonl`, stored flat under `traces_dir` (default `~/.jiuwenswarm/.trace`). **Each line is a standalone single-span OTLP JSON.**
+- Spans from different traces are **interleaved** in the same daily file — on upload the Collector re-groups them by the `traceId` carried on each span, so interleaving does not affect replay.
+- Disk writes are flushed asynchronously by the `BatchSpanProcessor` (default every 5s / 512 spans, and on shutdown), **never blocking the business thread**.
+- `session.id` is read by Langfuse from span attributes, not from the filename.
+
+### 5.2 Step 1 — configure the file exporter
+
+Edit `~/.jiuwenswarm/config/config.yaml` (`agent_observability` covers both Agent and Code):
+
+```yaml
+agent_observability:
+ enabled: true
+ exporter: file
+ traces_dir: "" # empty → default ~/.jiuwenswarm/.trace
+ file_retention_days: 7 # stale .jsonl files are lazily pruned
+ sample_rate: 1.0
+```
+
+### 5.3 Step 2 — start the Collector + Langfuse stack
+
+```bash
+cd deploy/observability
+docker-compose up -d # ~30-60s to become healthy on first start
+docker-compose ps # check status
+```
+
+Langfuse UI:
+
+- URL: `http://localhost:3000`
+- Login: `[email protected]` / `jiuwenswarm`
+- Project keys: `pk-lf-jiuwen` / `sk-lf-jiuwen` (auth is handled by the Collector's `otel-collector-config.yaml`; **the upload script itself needs no credentials**)
+
+### 5.4 Step 3 — run the upload script
+
+```bash
+cd deploy/observability
+
+# When traces_dir is not configured, trace files land in ~/.jiuwenswarm/.trace/ by default;
+# running with no arguments uploads that default directory:
+python upload_traces_to_langfuse.py
+
+# Or pass the default directory explicitly (equivalent to the line above):
+python upload_traces_to_langfuse.py ~/.jiuwenswarm/.trace
+python upload_traces_to_langfuse.py --dir ~/.jiuwenswarm/.trace
+
+# Upload a single day's file from the default directory:
+python upload_traces_to_langfuse.py --file ~/.jiuwenswarm/.trace/traces-2026-07-24.jsonl
+
+# Upload a custom directory / pass a custom Collector endpoint:
+python upload_traces_to_langfuse.py ./traces_run_001 --endpoint http://localhost:4318/v1/traces
+```
+
+The script POSTs each `.jsonl` file line-by-line to the Collector's OTLP HTTP endpoint (default `http://127.0.0.1:4318/v1/traces`, no auth), which forwards to Langfuse. After the run it prints the trace IDs that were successfully replayed:
+
+```
+[upload] source=~/.jiuwenswarm/.trace files=3 endpoint=http://127.0.0.1:4318/v1/traces
+[upload] total_lines=128 ok=128 fail=0 elapsed=0.6s
+[upload] trace_ids (3):
+ 4f3c1a8b9d2e4f6081a3c5b7d9e1f2a3
+ 8e1c0b2d4f6a8c9e1d3b5a7c9e1f0a2b
+ 1a2b3c4d5e6f70819203a4b5c6d7e8f9
+```
+
+Exit codes: `0` all succeeded; `1` some lines failed; `2` path not found or no `.jsonl` files.
+
+### 5.5 Notes
+
+- **Use `127.0.0.1`, not `localhost`**: on macOS, `getaddrinfo("localhost")` returns IPv6 `::1` first; Docker Desktop's IPv6 port-forward returns `502 Bad Gateway`, failing every upload. The script defaults to `127.0.0.1`; if you pass `--endpoint`, keep it that way.
+- **Data directory**: the script defaults to `~/.jiuwenswarm/.trace`; if `JIUWENSWARM_DATA_DIR` is set it reads `<that dir>/.trace`, matching the file exporter's output path.
+- **Cleanup**: `*.jsonl` older than `file_retention_days` is lazily deleted by the exporter (a sweep runs at most every 64 exports) — no manual cleanup needed.
+- **Stop the stack**: `docker-compose down` (keep data) / `docker-compose down -v` (remove data volumes too).
+
+---
+
+## 6. Output
+
+### 6.1 Dump file locations
+
+| Mode | Path |
+|------|------|
+| Agent | `~/.jiuwenswarm/.agent/traces/dump-agent-<session_id>.txt` |
+| Code | `~/.jiuwenswarm/.code/traces/dump-code-<session_id>.txt` |
+| OTel file mode | `~/.jiuwenswarm/.trace/traces-<YYYY-MM-DD>.jsonl` |
+
+- A local dump is **one file per session**, opened in append mode: rounds of one session append chronologically, separated by `run start` / `run end` boundaries.
+- The `session_id` is sanitised to safe characters and cannot escape its directory.
+
+### 6.2 Dump file format
+
+```text
+========== run start ==========
+timestamp=2026-07-24 10:12:31.123
+mode=agent.plan
+session_id=sess_a1b2
+request_id=req_c3d4
+otel_trace_id=4f2e...e1 ← empty when OTel is not enabled
+otel_span_id=8a3f...b2
+input=help me fix the failing tests ← user input preview
+
+[INFO] mode=agent.plan source=main category=text
+ | Let me look at the test file and the error first.
+
+[DEBUG] mode=agent.plan source=main category=tool_call
+ | tool_name=bash tool_call_id=call_123
+ | arguments={"command":"pytest -q tests/test_login.py"}
+
+[DEBUG] mode=agent.plan source=main category=tool_result
+ | tool_name=bash tool_call_id=call_123
+ | result: FAILED tests/test_login.py::test_login - AssertionError ...
+
+[DEBUG] mode=agent.plan source=main category=context_usage
+ | input_tokens=1234 output_tokens=567 total_tokens=1801 model_name=...
+
+========== subagent start ==========
+timestamp=2026-07-24 10:12:40.002
+source=subagent:builtin:explore_agent
+prompt=find every call site of login() in the repo
+... (the subagent's model output, tool calls, etc., same format) ...
+========== subagent end ==========
+timestamp=2026-07-24 10:12:52.880
+source=subagent:builtin:explore_agent
+status=ok
+
+========== run end ==========
+timestamp=2026-07-24 10:12:58.456
+status=ok
+elapsed_ms=27333
+chunks=42
+```
+
+On error or cancellation, `run end` writes `status=error` (with `error_type` / `error`) or `status=cancelled`.
+
+### 6.3 Recorded categories
+
+| category | Meaning | Default |
+|----------|---------|---------|
+| `text` | Model natural-language output | yes (`include_model_output`) |
+| `reasoning` | Reasoning fragments | yes (`include_reasoning`) |
+| `tool_call` | Tool call (name, ID, arguments) | yes (`include_tool_args`) |
+| `tool_result` | Tool result / error | yes (`include_tool_result`) |
+| `tool_update` | Tool progress update | yes |
+| `context_usage` | Token usage, model name | yes |
+| other | Controller output / messages / todos, etc. | yes |
+
+### 6.4 Cross-referencing the OTel trace
+
+The dump's `run start` contains `otel_trace_id` / `otel_span_id` (empty when OTel is off). Paste it into the Langfuse / Jaeger search box to locate the full span tree for this run; conversely, a Langfuse trace can lead you back to the local dump.
+
+---
+
+## 7. Configuration Reference
+
+### 7.1 `debug_trace` — Agent / Code local text dump
+
+```yaml
+debug_trace:
+ enabled: false # global switch (true = always-on for Agent/Code)
+ agent: # agent mode (agent.plan / agent.fast …)
+ enabled: false # agent-mode-only switch
+ dump_enabled: true # write local dump when debug is on
+ otel_enabled: false # also force-enable OTel during debug
+ include_model_output: true
+ include_reasoning: true
+ include_tool_args: true
+ include_tool_result: true
+ include_subagent_flow: true # record subagent data flow
+ code: # code mode (code.normal / code.plan …)
+ enabled: false
+ dump_enabled: true
+ otel_enabled: false
+ include_model_output: true
+ include_reasoning: true
+ include_tool_args: true
+ include_tool_result: true
+ include_subagent_flow: true
+ limits:
+ tool_args_max_chars: 2000 # tool-args truncation threshold
+ tool_result_max_chars: 8000 # tool-result truncation threshold
+ generic_payload_max_chars: 4000 # generic payload / run input threshold
+ max_model_output_chars: # empty = never cap model output; a number caps it
+ redaction:
+ redact_prompts: false # secret-key masking is always on regardless of these
+ redact_completions: false
+```
+
+### 7.2 `agent_observability` — Agent / Code structured OTel
+
+```yaml
+agent_observability:
+ enabled: false # single-agent observability master switch
+ exporter: file # otlp_grpc / otlp_http / file / console
+ endpoint: http://localhost:4317 # OTLP endpoint (not needed for file/console)
+ service_name: jiuwenswarm-agent # OTel resource service.name
+ sample_rate: 1.0 # sampling rate (0.0-1.0)
+ redact_prompts: false # redact prompt content
+ redact_completions: false # redact completion content
+ attribute_value_max_length: 10240 # max OTel attribute value length
+ langfuse_public_key: "" # Langfuse OTLP auth public key (needed for otlp_http direct)
+ langfuse_secret_key: "" # Langfuse OTLP auth secret key
+ traces_dir: "" # file exporter output dir, default ~/.jiuwenswarm/.trace
+ file_retention_days: 7 # file exporter retention in days
+```
+
+> **How the two blocks relate**: `debug_trace` governs Agent/Code local text dumps; `agent_observability` governs Agent/Code OTel spans. Both share the same `deploy/observability` backend stack. The single coupling point is `debug_trace.<mode>.otel_enabled` — it lets a `/debug` run temporarily pull up Agent/Code OTel.
+
+### 7.3 Resolution rules (debug_trace)
+
+```
+debug_enabled = request has /debug OR debug_trace.<mode>.enabled
+dump_enabled = debug_enabled AND debug_trace.<mode>.dump_enabled != false
+otel_enabled = debug_enabled AND debug_trace.<mode>.otel_enabled
+```
+
+- `<mode>` collapsing: a mode name starting with `code` uses the `code` section, otherwise `agent`.
+- Config reading is best-effort: any failure falls back to "request-level-only" behaviour.
+
+---
+
+## 8. FAQ
+
+**Q: I typed `/debug` but no dump file appeared?**
+Check: ① you looked in the right path for the current mode (see 6.1); ② data-directory permissions; ③ whether the app logs contain a warning like `[DebugTrace] disabled ... open failed`.
+
+**Q: Where is the dump file?**
+By mode, under `~/.jiuwenswarm/.agent/traces/` or `.code/traces/`. If `JIUWENSWARM_DATA_DIR` is set, the corresponding subdirectory under `<that dir>/`.
+
+**Q: Why is the subagent section empty?**
+Make sure `include_subagent_flow` is not `false`, and that this round is actually a debug state (`/debug` or config always-on). In a non-debug state the subagent takes the original path and is not recorded. (Subagent data flow currently applies to Agent / Code only.)
+
+**Q: I enabled OTel but there is no trace in Langfuse / the collector?**
+First verify spans are produced with `exporter: console` or `exporter: file`; in `file` mode check that `~/.jiuwenswarm/.trace/` contains `*.jsonl`. For always-online mode, confirm the `endpoint` is correct and the Collector is up (`docker-compose up`). See [Logging System](Logs.md) to check whether the service started normally.
+
+**Q: Offline file-mode upload fails with 502 for every line?**
+Almost always because the endpoint was written as `localhost`. On macOS use `127.0.0.1:4318` instead (see 5.5).
+
+**Q: Will the dump leak sensitive information?**
+Secret-like fields (`password` / `token` / `api_key` / `authorization` / `cookie`, etc.) are **always masked** as `***`, independent of the `redaction` switches; large payloads are truncated per `limits`. For fuller redaction, enable `redact_prompts` / `redact_completions`.
+
+**Q: Does enabling debug affect model-run performance or cause errors?**
+No. The whole mechanism is best-effort: any write failure is swallowed and warned about, never affecting the model run; in a non-debug state the subagent path is identical to having it disabled.
+
+---
+
+## 9. Related Documentation
+
+- [Logging System](Logs.md) — system-level operation logs (complementary to this doc)
+- [Modes](Modes.md) — `agent.*` / `code.*` mode descriptions and switching
+- [Configuration](Configuration.md) — full `config.yaml` field reference
+- [Slash Commands Reference](SlashCommands.md) — list of slash commands including `/debug`
+- `deploy/observability/` — one-command OTel Collector + Langfuse stack and the offline upload script (`README.md`)
diff --git a/docs/en/SUMMARY.md b/docs/en/SUMMARY.md
index 2eea7ff8d4..640891fb49 100644
--- a/docs/en/SUMMARY.md
+++ b/docs/en/SUMMARY.md
@@ -43,6 +43,7 @@
- [ACP Plugin Usage](ACP_Client_Config.md)
- [Desktop auto-update design](WindowsAutoUpdateDesign.md)
- [Logging System](Logs.md)
+ - [Debug Trace](DebugTrace.md)
- [Development practices](development-practices/README.md)
- [Daily report generator practice](development-practices/JiuwenSwarm-Daily-Report-Generator.md)
- [Code review assistant practice](development-practices/JiuwenSwarm-Code-Review-Assistant.md)
diff --git a/docs/zh/SUMMARY.md b/docs/zh/SUMMARY.md
index 84356e7e9d..5559052464 100644
--- a/docs/zh/SUMMARY.md
+++ b/docs/zh/SUMMARY.md
@@ -45,6 +45,7 @@
- [ACP 插件使用](ACP插件使用.md)
- [桌面端自动更新设计](windows自动更新设计.md)
- [日志系统](日志.md)
+ - [调试追踪(Debug Trace)](调试追踪.md)
- [开发实践](开发实践/README.md)
- [日报生成器开发实践](开发实践/JiuwenSwarm日报生成器开发实践.md)
- [代码审查助手开发实践](开发实践/JiuwenSwarm代码审查助手开发实践.md)
diff --git "a/docs/zh/\350\260\203\350\257\225\350\277\275\350\270\252.md" "b/docs/zh/\350\260\203\350\257\225\350\277\275\350\270\252.md"
new file mode 100644
index 0000000000..5fc985b23f
--- /dev/null
+++ "b/docs/zh/\350\260\203\350\257\225\350\277\275\350\270\252.md"
@@ -0,0 +1,445 @@
+# 调试追踪(Debug Trace)
+
+JiuwenSwarm 的调试追踪为 **Agent、Code 两种模式**提供统一的可观测能力,帮助你复盘一次对话 run 的完整行为:
+
+- **本地调试 dump**:以人类可读的纯文本记录**模型输出、推理过程、工具调用与结果、token 用量**,按 run 落盘,开箱即用、无需任何后端。
+- **结构化 OTel trace**(可选):把标准 `gen_ai.*` span 经 OTLP 上报到 Langfuse / Jaeger / Grafana 等后端,做耗时分析与跨 run 聚合。
+- **子智能体数据流**:主 agent 派发的子智能体(内置 / 自定义)其内部推理与工具调用也会进入同一份 dump,不再是"黑盒"。
+
+`/debug` 指令、指令解析原语在 Agent / Code 两种模式间共享;本地 dump 与 OTel 两条链路相互独立,又可通过 `trace_id` 互查。
+
+---
+
+## 1. 功能介绍
+
+### 1.1 它解决什么问题
+
+排查一个跑偏的智能体,最常被问到的几个问题:
+
+- 模型这一轮到底输出了什么?有没有"跑题"?
+- 它调了哪些工具?参数是什么?返回了什么?
+- 这一轮消耗了多少 token?耗时多久?
+- 当它派发了一个子智能体去干活时,子智能体内部到底发生了什么?
+
+常规应用日志(见 [日志系统](日志.md))面向系统运行状态、按组件分散,很难拼出"一次 run 的完整故事"。调试追踪就是为这一场景设计:**按 run 为单位、按时间顺序、聚焦模型与工具行为**,写到一个文件里供你直接阅读。
+
+### 1.2 核心能力
+
+| 能力 | 说明 |
+|------|------|
+| 请求级触发 | 输入 `/debug <你的问题>`,仅本轮开启 dump,无需改配置 |
+| 配置级常开 | 在 `config.yaml` 里全局或按模式常开 dump |
+| 两模式统一 | Agent / Code 均支持 `/debug`,指令解析共享同一原语 |
+| 子智能体数据流 | 记录内置子 agent(TaskTool)与自定义子 agent(AgentTool)的完整流,标签区分来源 |
+| 结构化 OTel(可选) | 产出标准 `gen_ai.*` span,后端无关,可与本地 dump 互查 |
+| 本地离线上传 | OTel 用 `file` 模式落盘后,可离线批量上传到 Langfuse |
+| 安全 | 密钥类字段始终打码;大 payload 自动截断;写入失败绝不影响模型 run |
+
+### 1.3 两种模式的支持情况
+
+两种模式都支持调试追踪,区别仅在 dump 落盘目录与所用的配置块:
+
+| 模式 | `/debug` | 本地 dump 文件 | OTel 配置块 |
+|------|----------|----------------|-------------|
+| `agent.plan` / `agent.fast` | ✅ | `~/.jiuwenswarm/.agent/traces/dump-agent-<session>.txt` | `agent_observability` |
+| `code.normal` / `code.plan` | ✅ | `~/.jiuwenswarm/.code/traces/dump-code-<session>.txt` | `agent_observability` |
+
+> 两种模式共享同一套 OTel 后端栈(OTel Collector + Langfuse),详见 [第 5 节](#5-本地-file-模式离线上传到-langfuse) 与 `deploy/observability/`。
+
+---
+
+## 2. 环境前置要求
+
+### 2.1 基础环境
+
+| 项 | 说明 |
+|----|------|
+| 配置文件 | `~/.jiuwenswarm/config/config.yaml`(默认模板 `jiuwenswarm/resources/config.yaml`) |
+| 数据目录 | `~/.jiuwenswarm/`,可用环境变量 `JIUWENSWARM_DATA_DIR` 覆盖 |
+| 入口 | `/debug` 是 TUI / Web 前端斜杠命令,原样透传到后端解析 |
+
+---
+
+## 3. 快速上手
+
+在任意模式下输入:
+
+```
+/debug 帮我把 tests/test_login.py 里失败的用例修好
+```
+
+本轮结束后,按当前模式打开对应的 dump 文件即可看到完整记录(模型输出、每个工具调用与结果、token 用量、耗时;若有子 agent 派发,还包括子 agent 的全部行为):
+
+```
+~/.jiuwenswarm/.agent/traces/dump-agent-<session_id>.txt # Agent 模式
+~/.jiuwenswarm/.code/traces/dump-code-<session_id>.txt # Code 模式
+```
+
+**无需修改任何配置。**
+
+---
+
+## 4. 使用方法
+
+> 下面按"你想做什么"组织,所有用法对 Agent / Code 两种模式都适用,不再按模式区分。
+
+### 4.1 临时调试单次请求(请求级)
+
+适合"偶尔出问题、不想改配置"。在任意对话里加 `/debug` 前缀:
+
+```
+/debug <你的问题>
+```
+
+- 仅**本轮**生效,后续轮次恢复正常。
+- 裸 `/debug`(不带问题)会被拒绝,避免空请求打到模型。
+- Plan 模式下,即使 `/debug` 前面被注入了 `<system-reminder>` 块,也能正确识别。
+
+### 4.2 常开调试 dump(配置级)
+
+适合"某个模式总是想留底"。编辑 `~/.jiuwenswarm/config/config.yaml`:
+
+```yaml
+debug_trace:
+ enabled: true # 全局常开(Agent / Code 所有子模式)
+ # 或只对某个模式常开:
+ # agent:
+ # enabled: true
+```
+
+修改后**下一轮请求即生效**(每次 run 读取最新配置,支持热加载)。
+
+### 4.3 追踪子智能体数据流
+
+当主 agent 通过子智能体(内置的 `task` 工具,或 `/agents` 创建的自定义 agent)派活时,子 agent 的完整行为会自动出现在 dump 里,并用 `source=` 标签区分来源:
+
+| 来源标签 | 含义 |
+|----------|------|
+| `source=main` | 主 agent 本身 |
+| `source=subagent:builtin:<类型>` | 内置子 agent(如 explore / plan / code / browser) |
+| `source=subagent:custom:<名称>` | `/agents` 创建的自定义子 agent |
+
+默认开启。若不想记录子 agent 流,可在配置里关闭(仅 Agent / Code 生效):
+
+```yaml
+debug_trace:
+ agent:
+ include_subagent_flow: false
+```
+
+> 关闭后,子 agent 仍正常执行,只是不再写入 dump(行为与未启用调试时一致)。
+
+### 4.4 结构化 OTel trace 上报
+
+OTel 支持四种 exporter 模式,按是否常在线选择:
+
+#### 4.4.1 OTLP gRPC → Collector → Langfuse(推荐,常在线)
+
+应用把 span 发给本地 Collector,Langfuse 的密钥认证由 Collector 侧统一处理。先启动栈:
+
+```bash
+cd deploy/observability
+docker-compose up -d
+```
+
+再配置(Agent/Code 用 `agent_observability`):
+
+```yaml
+agent_observability:
+ enabled: true
+ exporter: otlp_grpc
+ endpoint: http://localhost:4317
+ sample_rate: 1.0
+```
+
+#### 4.4.2 OTLP HTTP → Langfuse 直连(常在线,绕过 Collector)
+
+```yaml
+agent_observability:
+ enabled: true
+ exporter: otlp_http
+ endpoint: https://cloud.langfuse.com/api/public/otel/v1/traces
+ langfuse_public_key: "pk-lf-xxx"
+ langfuse_secret_key: "sk-lf-xxx"
+```
+
+#### 4.4.3 本地 `file` 模式 + 离线上传(离线 / 两阶段)
+
+适合无法常连后端、或想先攒一批 trace 再统一回放的场景。详见 [第 5 节](#5-本地-file-模式离线上传到-langfuse)。
+
+#### 4.4.4 console(快速验证)
+
+```yaml
+agent_observability:
+ enabled: true
+ exporter: console
+```
+
+span 以 JSON 打到控制台,适合本地快速验证链路是否通。
+
+---
+
+## 5. 本地 file 模式:离线上传到 Langfuse
+
+当无法(或不希望)常在线连 Collector 时,用 `file` exporter 把 span 写到本地磁盘,事后再用 `deploy/observability/upload_traces_to_langfuse.py` 批量上传。这是 deploy 栈提供的"两阶段"方案,**对 Agent / Code 两种模式都适用**。
+
+### 5.1 工作原理
+
+```
+ 应用(file exporter) ──写入──► ~/.jiuwenswarm/.trace/traces-<YYYY-MM-DD>.jsonl
+ │
+ upload_traces_to_langfuse.py
+ ▼
+ 本地 OTel Collector(:4318) ──OTLP HTTP+Basic Auth──► Langfuse(:3000)
+```
+
+- `file` exporter 把 span 写成**按天一个** `traces-<YYYY-MM-DD>.jsonl`,扁平存放于 `traces_dir`(默认 `~/.jiuwenswarm/.trace`),**每行是一个独立的单 span OTLP JSON**。
+- 不同 trace 的 span 在同一天文件里**交错存放**——上传时 Collector 按 span 自带的 `traceId` 重新归并,交错不影响回放。
+- 写盘由 `BatchSpanProcessor` 异步刷出(默认每 5s / 512 span,及 shutdown 时),**不阻塞业务线程**。
+- `session.id` 由 Langfuse 从 span 属性读取,与文件名无关。
+
+### 5.2 第一步:配置 file exporter
+
+编辑 `~/.jiuwenswarm/config/config.yaml`(`agent_observability` 同时覆盖 Agent / Code):
+
+```yaml
+agent_observability:
+ enabled: true
+ exporter: file
+ traces_dir: "" # 留空则默认 ~/.jiuwenswarm/.trace
+ file_retention_days: 7 # 超期的 .jsonl 会被惰性清理
+ sample_rate: 1.0
+```
+
+### 5.3 第二步:启动 Collector + Langfuse 栈
+
+```bash
+cd deploy/observability
+docker-compose up -d # 首次启动约 30-60s 健康
+docker-compose ps # 查看状态
+```
+
+Langfuse UI:
+
+- 地址:`http://localhost:3000`
+- 登录:`[email protected]` / `jiuwenswarm`
+- 项目密钥:`pk-lf-jiuwen` / `sk-lf-jiuwen`(密钥认证由 Collector 侧 `otel-collector-config.yaml` 处理,**上传脚本本身不需要密钥**)
+
+### 5.4 第三步:运行上传脚本
+
+```bash
+cd deploy/observability
+
+# 未配置 traces_dir 时,trace 文件默认落在 ~/.jiuwenswarm/.trace/,
+# 直接无参运行即可上传该默认目录:
+python upload_traces_to_langfuse.py
+
+# 也可显式指定默认目录(与上一条等价):
+python upload_traces_to_langfuse.py ~/.jiuwenswarm/.trace
+python upload_traces_to_langfuse.py --dir ~/.jiuwenswarm/.trace
+
+# 上传默认目录下的某一天文件:
+python upload_traces_to_langfuse.py --file ~/.jiuwenswarm/.trace/traces-2026-07-24.jsonl
+
+# 上传自定义目录 / 指定 Collector 端点:
+python upload_traces_to_langfuse.py ./traces_run_001 --endpoint http://localhost:4318/v1/traces
+```
+
+脚本把每个 `.jsonl` 文件逐行 POST 到 Collector 的 OTLP HTTP 端点(默认 `http://127.0.0.1:4318/v1/traces`,无鉴权),再由 Collector 转发到 Langfuse。结束后会打印本次成功回放的 trace ID 列表:
+
+```
+[upload] source=~/.jiuwenswarm/.trace files=3 endpoint=http://127.0.0.1:4318/v1/traces
+[upload] total_lines=128 ok=128 fail=0 elapsed=0.6s
+[upload] trace_ids (3):
+ 4f3c1a8b9d2e4f6081a3c5b7d9e1f2a3
+ 8e1c0b2d4f6a8c9e1d3b5a7c9e1f0a2b
+ 1a2b3c4d5e6f70819203a4b5c6d7e8f9
+```
+
+退出码:`0` 全部成功;`1` 存在失败行;`2` 路径不存在或无 `.jsonl` 文件。
+
+### 5.5 注意事项
+
+- **用 `127.0.0.1`,不要用 `localhost`**:在 macOS 上 `getaddrinfo("localhost")` 优先返回 IPv6 `::1`,Docker Desktop 的 IPv6 端口转发会返回 `502 Bad Gateway` 导致上传全部失败。脚本默认已用 `127.0.0.1`;若用 `--endpoint` 自定义请保持。
+- **数据目录**:脚本默认读 `~/.jiuwenswarm/.trace`,若设置了 `JIUWENSWARM_DATA_DIR` 则读 `<该目录>/.trace`,与 `file` exporter 的输出路径一致。
+- **清理**:超过 `file_retention_days` 的 `*.jsonl` 会被 exporter 惰性删除(每 64 次 export 触发一次清扫),无需手动清理。
+- **停止栈**:`docker-compose down`(保留数据)/ `docker-compose down -v`(连同数据卷一起清除)。
+
+---
+
+## 6. 产物说明
+
+### 6.1 dump 文件位置
+
+| 模式 | 路径 |
+|------|------|
+| Agent | `~/.jiuwenswarm/.agent/traces/dump-agent-<session_id>.txt` |
+| Code | `~/.jiuwenswarm/.code/traces/dump-code-<session_id>.txt` |
+| OTel file 模式 | `~/.jiuwenswarm/.trace/traces-<YYYY-MM-DD>.jsonl` |
+
+- 本地 dump **每个 session 一个文件**,追加模式:同一会话的多轮请求按时间顺序追加,用 `run start` / `run end` 边界分隔。
+- `session_id` 会被清洗为安全字符,无法逃逸出该目录。
+
+### 6.2 dump 文件格式
+
+```text
+========== run start ==========
+timestamp=2026-07-24 10:12:31.123
+mode=agent.plan
+session_id=sess_a1b2
+request_id=req_c3d4
+otel_trace_id=4f2e...e1 ← OTel 未启用时为空
+otel_span_id=8a3f...b2
+input=帮我修复失败的测试用例 ← 用户输入预览
+
+[INFO] mode=agent.plan source=main category=text
+ | 我先看一下测试文件和报错信息。
+
+[DEBUG] mode=agent.plan source=main category=tool_call
+ | tool_name=bash tool_call_id=call_123
+ | arguments={"command":"pytest -q tests/test_login.py"}
+
+[DEBUG] mode=agent.plan source=main category=tool_result
+ | tool_name=bash tool_call_id=call_123
+ | result: FAILED tests/test_login.py::test_login - AssertionError ...
+
+[DEBUG] mode=agent.plan source=main category=context_usage
+ | input_tokens=1234 output_tokens=567 total_tokens=1801 model_name=...
+
+========== subagent start ==========
+timestamp=2026-07-24 10:12:40.002
+source=subagent:builtin:explore_agent
+prompt=在仓库里找出所有调用 login() 的位置
+...(子 agent 的模型输出、工具调用等,同样格式)...
+========== subagent end ==========
+timestamp=2026-07-24 10:12:52.880
+source=subagent:builtin:explore_agent
+status=ok
+
+========== run end ==========
+timestamp=2026-07-24 10:12:58.456
+status=ok
+elapsed_ms=27333
+chunks=42
+```
+
+异常或取消时,`run end` 会写 `status=error`(含 `error_type` / `error`)或 `status=cancelled`。
+
+### 6.3 记录的内容类别
+
+| category | 含义 | 默认是否记录 |
+|----------|------|--------------|
+| `text` | 模型自然语言输出 | 是(`include_model_output`) |
+| `reasoning` | 推理片段 | 是(`include_reasoning`) |
+| `tool_call` | 工具调用(名称、ID、参数) | 是(`include_tool_args`) |
+| `tool_result` | 工具结果 / 错误 | 是(`include_tool_result`) |
+| `tool_update` | 工具进度更新 | 是 |
+| `context_usage` | token 用量、模型名 | 是 |
+| 其他 | 控制器输出 / 消息 / 待办等 | 是 |
+
+### 6.4 与 OTel trace 互查
+
+dump 的 `run start` 含 `otel_trace_id` / `otel_span_id`(OTel 未启用时为空)。把它复制到 Langfuse / Jaeger 搜索框,即可定位本次 run 对应的完整 span 树;反之,从 Langfuse 的 trace 也能回查本地 dump。
+
+---
+
+## 7. 配置参考
+
+### 7.1 `debug_trace` —— Agent / Code 本地文本 dump
+
+```yaml
+debug_trace:
+ enabled: false # 全局开关(true=Agent/Code 常开 dump)
+ agent: # agent 模式(agent.plan / agent.fast …)
+ enabled: false # 仅 agent 模式开关
+ dump_enabled: true # debug 开启时是否写本地 dump
+ otel_enabled: false # debug 时是否顺带 force-enable OTel
+ include_model_output: true
+ include_reasoning: true
+ include_tool_args: true
+ include_tool_result: true
+ include_subagent_flow: true # 记录子智能体数据流
+ code: # code 模式(code.normal / code.plan …)
+ enabled: false
+ dump_enabled: true
+ otel_enabled: false
+ include_model_output: true
+ include_reasoning: true
+ include_tool_args: true
+ include_tool_result: true
+ include_subagent_flow: true
+ limits:
+ tool_args_max_chars: 2000 # 工具参数截断阈值
+ tool_result_max_chars: 8000 # 工具结果截断阈值
+ generic_payload_max_chars: 4000 # 通用载荷 / run input 截断阈值
+ max_model_output_chars: # 空=不截模型输出;填数字则截断
+ redaction:
+ redact_prompts: false # 密钥字段始终打码,与这两个开关无关
+ redact_completions: false
+```
+
+### 7.2 `agent_observability` —— Agent / Code 结构化 OTel
+
+```yaml
+agent_observability:
+ enabled: false # 单 agent 可观测性总开关
+ exporter: file # otlp_grpc / otlp_http / file / console
+ endpoint: http://localhost:4317 # OTLP endpoint(file/console 模式不需要)
+ service_name: jiuwenswarm-agent # OTel resource service.name
+ sample_rate: 1.0 # 采样率 (0.0-1.0)
+ redact_prompts: false # 是否脱敏 prompt 内容
+ redact_completions: false # 是否脱敏 completion 内容
+ attribute_value_max_length: 10240 # OTel attribute value 最大长度
+ langfuse_public_key: "" # Langfuse OTLP 认证 public key(otlp_http 直连时需要)
+ langfuse_secret_key: "" # Langfuse OTLP 认证 secret key
+ traces_dir: "" # file exporter 输出目录,默认 ~/.jiuwenswarm/.trace
+ file_retention_days: 7 # file exporter 文件保留天数
+```
+
+> **两块配置的关系**:`debug_trace` 管 Agent/Code 的本地文本 dump,`agent_observability` 管 Agent/Code 的 OTel span。两者共用同一套 `deploy/observability` 后端栈。唯一耦合点是 `debug_trace.<mode>.otel_enabled`——它让一次 `/debug` 临时拉起 Agent/Code 的 OTel。
+
+### 7.3 配置生效规则(debug_trace)
+
+```
+debug_enabled = 请求带 /debug OR debug_trace.<mode>.enabled
+dump_enabled = debug_enabled AND debug_trace.<mode>.dump_enabled != false
+otel_enabled = debug_enabled AND debug_trace.<mode>.otel_enabled
+```
+
+- `<mode>` 归并:模式名以 `code` 开头走 `code` 段,否则走 `agent` 段。
+- 配置读取 best-effort:任何异常都回退到"仅请求级行为"。
+
+---
+
+## 8. 常见问题
+
+**Q:输入 `/debug` 后没看到 dump 文件?**
+检查:① dump 路径是否按当前模式找对了(见 6.1);② 数据目录权限;③ 应用日志里是否有 `[DebugTrace] disabled ... open failed` 之类的告警。
+
+**Q:dump 文件在哪?**
+默认按模式分别在 `~/.jiuwenswarm/.agent/traces/`、`.code/traces/`。若设置了 `JIUWENSWARM_DATA_DIR`,则在 `<该目录>/` 对应子目录下。
+
+**Q:为什么子智能体那一段没有内容?**
+确认 `include_subagent_flow` 没被关成 `false`,且本轮确实是 debug 态(`/debug` 或配置常开)。非 debug 态下子 agent 走原始路径,不会记录。(子智能体数据流目前仅作用于 Agent / Code。)
+
+**Q:开启了 OTel,但 Langfuse / collector 里没有 trace?**
+先用 `exporter: console` 或 `exporter: file` 验证 span 是否产出;`file` 模式下检查 `~/.jiuwenswarm/.trace/` 是否有 `*.jsonl`。常在线模式确认 `endpoint` 正确、Collector 是否 `docker-compose up` 启动。详见 [日志系统](日志系统) 排查服务是否正常。
+
+**Q:本地 file 模式上传全部 502 失败?**
+几乎都是把端点写成了 `localhost`。macOS 下请改用 `127.0.0.1:4318`(见 5.5)。
+
+**Q:dump 里会泄露敏感信息吗?**
+密钥类字段(`password` / `token` / `api_key` / `authorization` / `cookie` 等)**始终打码**为 `***`,与 `redaction` 开关无关;大 payload 按 `limits` 截断。如需更彻底脱敏,可开启 `redact_prompts` / `redact_completions`。
+
+**Q:开启调试会影响模型运行性能或导致报错吗?**
+不会。整套机制 best-effort:任何写入失败都被吞掉并告警,绝不影响模型 run;非 debug 态下子智能体路径与未启用时完全一致。
+
+---
+
+## 9. 相关文档
+
+- [日志系统](日志.md) — 系统级运行日志(与本文档互补)
+- [模式系统](模式系统.md) — `agent.*` / `code.*` 模式说明与切换
+- [配置信息](配置信息.md) — `config.yaml` 完整字段说明
+- [Slash 命令速查表](Slash命令表.md) — `/debug` 等斜杠命令一览
+- `deploy/observability/` — OTel Collector + Langfuse 一键部署栈与离线上传脚本(`README.md`)
diff --git a/jiuwenswarm/resources/config.yaml b/jiuwenswarm/resources/config.yaml
index d11c26d2ac..2302f8f7d8 100644
--- a/jiuwenswarm/resources/config.yaml
+++ b/jiuwenswarm/resources/config.yaml
@@ -402,14 +402,13 @@ agent_observability:
# ============================================================
# 控制非 team 模式(agent.* / code.*)的人类可读本地 dump。
# 生效逻辑(resolve_debug_trace_settings):
-# debug_enabled = 请求带 /debug OR debug_trace.enabled OR debug_trace.<mode>.enabled
+# debug_enabled = 请求带 /debug OR debug_trace.<mode>.enabled
# dump_enabled = debug_enabled AND debug_trace.<mode>.dump_enabled != false
# dump 写入 ~/.jiuwenswarm/.agent/traces/ 或 .code/traces/(按模式)。
# 与 agent_observability(OTel span)相互独立:本块只管本地文本 dump,
# OTel 接入在后续阶段。
# ============================================================
debug_trace:
- enabled: false # 全局开关(true=所有模式常开 dump)
agent: # agent 模式(agent.plan / agent.fast …)
enabled: false # 仅 agent 模式开关
dump_enabled: true # debug 开启时是否写本地 dump
diff --git a/jiuwenswarm/server/runtime/debug_trace/config.py b/jiuwenswarm/server/runtime/debug_trace/config.py
index 9753b56f02..acbbd69129 100644
--- a/jiuwenswarm/server/runtime/debug_trace/config.py
+++ b/jiuwenswarm/server/runtime/debug_trace/config.py
@@ -4,7 +4,7 @@
Merges the request-level ``/debug`` flag with the ``debug_trace`` config block:
- debug_enabled = request_debug OR debug_trace.enabled OR debug_trace.<mode>.enabled
+ debug_enabled = request_debug OR debug_trace.<mode>.enabled
dump_enabled = debug_enabled AND debug_trace.<mode>.dump_enabled != false
Per-mode ``include_*`` toggles, ``limits`` and ``redaction`` are read with
@@ -86,7 +86,6 @@ def resolve_debug_trace_settings(*, mode: str, request_debug: bool) -> DebugTrac
debug_enabled = bool(
request_debug
- or cfg.get("enabled")
or mode_cfg.get("enabled")
)
dump_enabled = debug_enabled and (mode_cfg.get("dump_enabled", True) is not False)
diff --git a/tests/unit_tests/agentserver/test_debug_trace.py b/tests/unit_tests/agentserver/test_debug_trace.py
index 0fe64aa046..feb16fd884 100644
--- a/tests/unit_tests/agentserver/test_debug_trace.py
+++ b/tests/unit_tests/agentserver/test_debug_trace.py
@@ -143,11 +143,6 @@ class TestSettings:
self._cfg(monkeypatch, {"code": {"otel_enabled": False}})
assert not resolve_debug_trace_settings(mode="code.normal", request_debug=True).otel_enabled
- def test_config_global_enabled(self, monkeypatch):
- self._cfg(monkeypatch, {"enabled": True})
- s = resolve_debug_trace_settings(mode="agent.plan", request_debug=False)
- assert s.enabled and s.dump_enabled
-
def test_config_mode_enabled(self, monkeypatch):
# only agent mode enabled -> code disabled
self._cfg(monkeypatch, {"agent": {"enabled": True}})
@@ -155,32 +150,32 @@ class TestSettings:
assert not resolve_debug_trace_settings(mode="code.normal", request_debug=False).enabled
def test_config_dump_disabled_escape_hatch(self, monkeypatch):
- self._cfg(monkeypatch, {"enabled": True, "code": {"dump_enabled": False}})
+ self._cfg(monkeypatch, {"code": {"enabled": True, "dump_enabled": False}})
s = resolve_debug_trace_settings(mode="code.normal", request_debug=False)
assert s.enabled and not s.dump_enabled
def test_config_include_toggles(self, monkeypatch):
- self._cfg(monkeypatch, {"enabled": True, "code": {"include_reasoning": False}})
+ self._cfg(monkeypatch, {"code": {"include_reasoning": False}})
s = resolve_debug_trace_settings(mode="code.normal", request_debug=False)
assert s.include_reasoning is False
assert s.include_model_output is True # untouched default
def test_config_limits_override(self, monkeypatch):
- self._cfg(monkeypatch, {"enabled": True, "limits": {"tool_args_max_chars": 100}})
+ self._cfg(monkeypatch, {"limits": {"tool_args_max_chars": 100}})
s = resolve_debug_trace_settings(mode="agent.plan", request_debug=False)
assert s.tool_args_max_chars == 100
assert s.tool_result_max_chars == 8000 # untouched default
def test_config_max_model_output_chars(self, monkeypatch):
- self._cfg(monkeypatch, {"enabled": True, "limits": {"max_model_output_chars": 500}})
+ self._cfg(monkeypatch, {"limits": {"max_model_output_chars": 500}})
s = resolve_debug_trace_settings(mode="agent.plan", request_debug=False)
assert s.max_model_output_chars == 500
# empty/null -> no cap
- self._cfg(monkeypatch, {"enabled": True, "limits": {"max_model_output_chars": ""}})
+ self._cfg(monkeypatch, {"limits": {"max_model_output_chars": ""}})
assert resolve_debug_trace_settings(mode="agent.plan", request_debug=False).max_model_output_chars is None
def test_config_redaction(self, monkeypatch):
- self._cfg(monkeypatch, {"enabled": True, "redaction": {"redact_completions": True}})
+ self._cfg(monkeypatch, {"redaction": {"redact_completions": True}})
s = resolve_debug_trace_settings(mode="agent.plan", request_debug=False)
assert s.redact_completions is True
assert s.redact_prompts is False