Skip to content

[P2][OCR] Reduce redundant context serialization and oversized string allocation #51

Description

@Ryder-Sun

Source: OCR_ANALYSIS_REPORT.md, OpenCode Review report generated on 2026-08-12.

Findings: M-5, L-2. The context-pack code serializes near-limit records more than once and allocates full UTF-8 buffers before rejecting oversized strings. This is not currently a correctness failure, but it increases CPU and memory pressure around the 2 MB context-pack boundary.

Expected fix:

  • Reuse the canonical JSON string returned by size enforcement.
  • Add a cheap pre-check before allocating full buffers for clearly oversized strings.
  • Add performance-oriented regression coverage around near-limit payloads.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:harnessMulti-Agent orchestration, run state, and collaborationenhancementNew feature or requestpriority:p2Platform expansion after core runtime work

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions