Skip to content

fix(strategy): externalize task images before applying transcript cap - #2103

Open
SparshM8 wants to merge 3 commits into
entireio:mainfrom
SparshM8:fix/issue-2063-transcript-cap
Open

fix(strategy): externalize task images before applying transcript cap#2103
SparshM8 wants to merge 3 commits into
entireio:mainfrom
SparshM8:fix/issue-2063-transcript-cap

Conversation

@SparshM8

Copy link
Copy Markdown

This PR fixes issue #2063 where large task transcripts containing base64 images were being capped before externalization, leading to lost transcripts even when externalization was enabled.

Changes:

  • Reordered the condensation strategy to externalize images BEFORE applying the transcript cap.
  • Added a targeted boundary test to verify that images up to the 50MB cap are externalized and transcripts are preserved.
  • Verified that transcripts exceeding the cap after externalization are still safely handled.

Native test passed: TestCondenseSession_TaskRecordImageExternalizationBoundary

Copilot AI lite review requested due to automatic review settings August 23, 2026 11:24
@SparshM8
SparshM8 requested a review from a team as a code owner August 23, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes #2063 by aligning the subagent task transcript storage pipeline with the main session transcript pipeline so that inline base64 images are externalized before applying the 50MB blob cap, preventing transcripts from being dropped prematurely when externalization would have reduced them below the limit.

Changes:

  • Reordered prepareTaskTranscriptForStorage to run image externalization before enforcing agent.MaxChunkSize.
  • Added a boundary-focused test covering (1) oversized raw-but-externalizable images and (2) decoded-oversize images that must remain inline and still hit the cap.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cmd/entire/cli/strategy/manual_commit_condensation.go Moves the task transcript blob-size guard to run after image externalization and improves related warning logging.
cmd/entire/cli/strategy/manual_commit_condensation_test.go Adds a regression test to ensure externalization can prevent transcript loss when raw base64 exceeds the cap.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +245 to +248
// cap measures the size of the transcript that will be stored in git (after
// sanitization and image externalization, but before redaction). Oversized
// transcripts are dropped to keep the metadata branch pushable.
if len(externalized) > agent.MaxChunkSize {
Comment on lines +1212 to +1219
imgData := make([]byte, 40*1024*1024)
for i := range imgData {
imgData[i] = byte(i % 256)
}
base64Image := base64.StdEncoding.EncodeToString(imgData)
line := `{"role":"assistant","content":[{"type":"image","source":{"type":"base64","media_type":"image/png","data":"` + base64Image + `"}}],"message":{"id":"msg_123"}}` + "\n"

require.NoError(t, os.WriteFile(agentTranscriptPath, []byte(line), 0o644))
@SparshM8

Copy link
Copy Markdown
Author

Hi @entireio/cli-maintainers,

I've raised PR #2103 to address the transcript cap issue (#2063). I've included a targeted boundary test that verifies the fix by simulating large base64 images that exceed the cap before externalization but stay well within it after.

Could you please approve the CI workflows to run? I'm happy to address any feedback or adjust the aggregate asset policy if needed.

Thanks!

@SparshM8

Copy link
Copy Markdown
Author

I've refined the documentation to accurately reflect the pipeline order: sanitize -> externalize -> cap -> redact. I also optimized the boundary test to avoid large memory allocations while still verifying the 50MiB cap behavior correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants