Skip to content

bufio.Scanner 10MB token limit may truncate large transcript lines #328

@khaong

Description

@khaong

Problem

parseTranscriptFromLine in agent/claudecode/transcript.go uses bufio.Scanner with a 10MB max token size. Claude Code tool_use JSONL lines can embed large file contents, and if a single line exceeds that limit, parsing will error.

This affects all callers:

  • ExtractAllModifiedFiles
  • CalculateTotalTokenUsage
  • Other transcript parsing functions

Impact

If a transcript line exceeds 10MB, file extraction and token usage calculation will fail. In ExtractAllModifiedFiles, the error triggers a fallback to main-transcript-only extraction, potentially missing subagent files.

Suggested Fix

Consider switching to a bufio.Reader-based parser (like ClaudeCodeAgent.ExtractModifiedFilesFromOffset) that doesn't have fixed token limits.

Context

Identified during review of #323 (ENT-297 fix).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions