fix(debug): bound unbounded SDK message log writes - #1076
Conversation
|
Thanks for taking this up! Great heuristic, it definitely needs to be bounded, but I think the solution isn't super useful here. I don't think truncating model responses is useful. That is one of the primary ways we debug and analyze what the model is trying to do. Maybe truncating it only on prod builds, but even then, when we ask for logs on support tickets, this becomes a pretty hard blocker. The behavior to have What do you think? |
|
@gewenyu99 🤦 ...now it makes total sense. Yes I totally agree here. I would follow your suggestion: one artifact per run, keep the last N runs, delete the oldest when past N, and never stop writing mid-run. Would you say setting N to 5 as a named constant that is easy to change if that is the wrong number would be the right approach here? I am much less sure about what dominates size inside a single run 🤔 I have not measured a real wizard log yet. Could you share a sample log for reference? I am especially interested in Also, one more thing - Looking back at #578, the lowest-risk first step there was dropping pretty-printing ( |
Problem
Agent sessions can write unbounded SDK payloads into
debug.log(e.g. largetool_resultcontent), so a single run can grow the log without a ceiling and make debugging slow or disk-heavy.Closes #578
Changes
logToFilewrite at 8KBTest plan
pnpm exec vitest run src/lib/agent/__tests__/sdk-message-log.test.ts src/utils/__tests__/debug.test.tstool_resultformats to ~2KB; original object unchangedlogToFilestays under the 8KB line cap; further writes stop at the 10MB file ceilingLLM context
Co-authored with Cursor. Implemented and verified locally (unit tests + manual size-cap checks) against #578.