Skip to content

fix(coding-agent): avoid recursive render-signature array hashing - #690

Open
lcorncream wants to merge 2 commits into
code-yeongyu:mainfrom
lcorncream:fix/render-signature-array-tail-hashing
Open

fix(coding-agent): avoid recursive render-signature array hashing#690
lcorncream wants to merge 2 commits into
code-yeongyu:mainfrom
lcorncream:fix/render-signature-array-tail-hashing

Conversation

@lcorncream

@lcorncream lcorncream commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • hash omitted array items iteratively instead of recursively slicing each 40-item tail
  • preserve render-signature changes when an omitted array item changes
  • add focused regression coverage and the required interactive change record

Why

PR #88 introduced bounded render signatures to reduce resume and render work for large session payloads. Its array
tail path calls hashSignatureValue(value.slice(40)), so a large numeric array creates another progressively
smaller array and recursive call for every 40 items.

Tool results can contain those arrays through normal JavaScript serialization, including
Buffer.toJSON().data. A sufficiently large payload can therefore fail while the TUI computes its render cache
signature:

RangeError: Maximum call stack size exceeded
    at summarizeSignatureValue
    at hashSignatureValue

This change keeps nesting recursion governed by the existing depth limit while processing sibling tail items in
one iterative pass.

Related implementation history: #88. GitHub search found no matching issue or existing fix PR for this array-tail
failure.

Validation

  • npm run test --workspace @code-yeongyu/senpi -- test/render-signature.test.ts test/tool-execution-render-signature.test.ts test/assistant-message-render-signature.test.ts
  • npm run check
  • npm run build
  • npm test
  • constrained-stack component QA: 50,000-byte Buffer.toJSON().data reached
    ToolExecutionComponent.render() and rendered 7 lines
  • constrained-stack direct QA: 500,000 numeric items produced a bounded signature in 63 ms
  • isolated source TUI PTY smoke: boot, render, composer input, and clean exit; real auth hash unchanged

Expected merge conflict zones

  • packages/coding-agent/src/modes/interactive/components/render-signature.ts
  • packages/coding-agent/test/render-signature.test.ts
  • packages/coding-agent/src/modes/interactive/changes.md

Summary by cubic

Avoid stack overflows and preserve render cache correctness by hashing large array tails iteratively in the render signature. Large session payloads now render reliably.

  • Bug Fixes
    • Replaced recursive array-tail slicing with a single iterative hash pass, keeping recursion depth bounded and ensuring changes in omitted items still affect the signature.
    • Added regression tests (including a constrained-stack run) and relocated the change note in changes.md.

Written for commit 5fadce3. Summary will update on new commits.

Review in cubic

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant