← Back to PRs

#8360: Gateway: cap oversized transcript entries

by halbot2010 open 2026-02-03 23:00 View on GitHub →
app: web-ui gateway stale
## Problem OpenClaw session transcripts (JSONL) can be bloated by very large message/tool-result payloads (e.g. data URLs / screenshots), which later causes oversized history/context payloads and request failures. ## Fix Add a small gateway-side guard that caps a *single transcript JSONL entry* (default used here: 128KB). If an entry exceeds the cap, we: - write the full JSON entry to an artifact file under `artifacts/transcript-blobs/<sha256>.json` adjacent to the transcript - replace the transcript entry with a pointer + short preview This preserves continuity (pointer + hash) while preventing session JSONL bloat. ## Scope Wires the guard into gateway transcript append paths in `src/gateway/server-methods/chat.ts` (assistant transcript append helper + `chat.inject`). ## Tests Adds `src/gateway/transcript-sanitize.test.ts` covering passthrough + elision + artifact write. ## Notes - Artifact path is local-only and intended for operators/debugging. - The cap is hardcoded in this PR; happy to move to a config knob if preferred. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a gateway-side guard to cap the size of individual JSONL transcript entries (defaulting to 128KB). Oversized entries are written in full to a sidecar artifact file (keyed by sha256), and the transcript line is replaced with a small pointer/preview payload to prevent transcript bloat and downstream request failures. The guard is wired into both assistant transcript appends and `chat.inject`, and includes a new Vitest suite that verifies passthrough behavior and artifact creation for oversized message entries. <h3>Confidence Score: 4/5</h3> - This PR is reasonably safe to merge; changes are localized and covered by unit tests. - Core behavior is additive and focused on transcript writing paths, and the sanitizer is small and deterministic. Main remaining concerns are operational (sync fs + repeated mkdir) and information leakage (embedding absolute artifact paths in transcript entries). - src/gateway/transcript-sanitize.ts; src/gateway/server-methods/chat.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs