Skip to content

fix(core): compact on request byte envelope - #35687

Closed
fengjikui wants to merge 1 commit into
anomalyco:devfrom
fengjikui:byte-compaction
Closed

fix(core): compact on request byte envelope#35687
fengjikui wants to merge 1 commit into
anomalyco:devfrom
fengjikui:byte-compaction

Conversation

@fengjikui

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #35013

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds an optional compaction.max_request_bytes guard for proactive compaction. The existing token-based behavior remains unchanged unless the setting is configured; when it is configured, the serialized request envelope can trigger compaction before a provider rejects the request for size.

This keeps the fallback conservative for providers/routes that can hit request-size limits before the token context threshold.

How did you verify your code works?

  • bun typecheck from packages/core
  • bun test --timeout 30000 test/session-compaction.test.ts test/config/config.test.ts from packages/core
  • bun test --timeout 30000 test/session-runner.test.ts --grep 'compaction|overflow' from packages/core
  • bunx prettier --check packages/core/src/config/compaction.ts packages/core/src/session/compaction.ts packages/core/test/config/config.test.ts packages/core/test/session-compaction.test.ts
  • git diff --check
  • pre-push bun turbo typecheck completed successfully: 30/30 tasks

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Related PRs Found

Based on the search, I found several related PRs that involve compaction and request sizing in the core package:

  1. fix(core): estimate semantic request context - Recent PR addressing request context estimation, likely related to the same issue space

  2. fix: bound compaction request size - Directly related to bounding request size during compaction

  3. fix(core): guard non-reducing compaction - Related compaction guard mechanism

These PRs are related to compaction and request size management, which is the core concern of the current PR (#35687). However, they don't appear to be duplicates—rather, they're part of an evolving compaction strategy for handling request size limits.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(v2): Fable/Zen request-size 400 bypasses auto-compaction

1 participant