@yeaft/webchat-agent 1.0.18 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/yeaft/session.js CHANGED
@@ -218,26 +218,18 @@ export async function loadSession(options = {}) {
218
218
  }
219
219
 
220
220
  // ─── 3. Create trajectory trace ─────────────────────────
221
- // feat-always-on-trajectory-store: the trace is no longer gated on
222
- // config.debug. It is a TRAJECTORY STORE: every turn's full
223
- // (system_prompt, messages, tool_calls, tool_results, response, usage)
224
- // is persisted to ~/.yeaft/debug.db so it can serve two purposes:
225
- // 1. Debug panel hydration user opens "请求日志" and sees prior turns.
226
- // 2. SFT / RL training data scripts can later dump JSONL trajectories.
227
- // Cost is negligible (one insert per turn, WAL mode), and the data only
228
- // accumulates while the user actually uses the agent. The previous gate
229
- // silently discarded every turn unless the user had set debug:true in
230
- // ~/.yeaft/config.json, which nobody ever did — wasting the asset.
221
+ // Always-on request trace for the Debug panel. It is file-backed, not
222
+ // SQLite-backed: each request writes one bounded JSON file under
223
+ // `<yeaftDir>/debug/` (session traces are nested under
224
+ // `<yeaftDir>/sessions/<sessionId>/debug/requests/`). A request file stores one
225
+ // base request snapshot plus per-loop deltas, so 100-200 loop requests do
226
+ // not become hundreds of tiny files or repeated cumulative payloads.
231
227
  const trace = createTrace({
232
228
  enabled: true,
233
- dbPath: join(yeaftDir, 'debug.db'),
229
+ dirPath: yeaftDir,
234
230
  });
235
- // Bound disk growth: prune trajectories older than 10 days on session load.
236
- // Cheap (indexed DELETE + incremental_vacuum), runs once per process start,
237
- // not per turn. The always-on store stamps every turn with the *cumulative*
238
- // request/response (each long-session row is ~MB), so without a tight TTL the
239
- // file balloons — a real deployment hit 5GB in 15 days. 10 days keeps enough
240
- // history for debug-panel replay while capping the steady-state footprint.
231
+ // Hard cap debug history to the most recent 10 requests per Session. Trace
232
+ // failures are best-effort and must never stop the agent loop.
241
233
  try { trace.cleanup?.(10); } catch (err) {
242
234
  console.warn('[Yeaft] trace.cleanup failed:', err?.message || err);
243
235
  }
@@ -4452,7 +4452,7 @@ export async function handleYeaftFetchToolStats(_msg = {}) {
4452
4452
  }
4453
4453
 
4454
4454
  /**
4455
- * Hydrate the YeaftDebugPanel from the persistent SQLite trace. The
4455
+ * Hydrate the YeaftDebugPanel from the persistent file-backed trace. The
4456
4456
  * panel state (`yeaftDebugLoops` / `yeaftDebugTurnsById`) is otherwise
4457
4457
  * built ONLY from in-flight `loop` / `turn_open` events on the wire,
4458
4458
  * so a panel opened after a turn has finished sees nothing for that
@@ -4460,7 +4460,7 @@ export async function handleYeaftFetchToolStats(_msg = {}) {
4460
4460
  * splices into place.
4461
4461
  *
4462
4462
  * Inputs (all optional):
4463
- * - `limit` — legacy recent-detail loop cap; ignored by index-only
4463
+ * - `limit` — request cap; bounded by the file trace store
4464
4464
  * - `indexOnly` — list request summaries without loop/detail payloads
4465
4465
  * - `detailTurnId` — fetch full loops/tools for one request
4466
4466
  * - `sessionId` — narrow by Session
@@ -4473,7 +4473,7 @@ export async function handleYeaftFetchToolStats(_msg = {}) {
4473
4473
  * snapshot so the panel renders a placeholder instead of spinning.
4474
4474
  */
4475
4475
  export async function handleYeaftFetchDebugHistory(msg = {}) {
4476
- const limit = Number.isFinite(msg?.limit) ? Number(msg.limit) : 100;
4476
+ const limit = Number.isFinite(msg?.limit) ? Number(msg.limit) : 10;
4477
4477
  const dreamLimit = Number.isFinite(msg?.dreamLimit) ? Number(msg.dreamLimit) : 5;
4478
4478
  const sessionId = typeof msg?.sessionId === 'string' && msg.sessionId ? msg.sessionId : null;
4479
4479
  const threadId = typeof msg?.threadId === 'string' && msg.threadId ? msg.threadId : null;