Skip to content

fix(responses): bound terminal guard delta retention - #2195

Merged
Ingwannu merged 1 commit into
devfrom
ingw/terminal-guard-delta-retention
Aug 20, 2026
Merged

fix(responses): bound terminal guard delta retention#2195
Ingwannu merged 1 commit into
devfrom
ingw/terminal-guard-delta-retention

Conversation

@Ingwannu

@Ingwannu Ingwannu commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • pass heartbeat and tool_call_delta events through the terminal guard without retaining them in its per-turn seen list
  • keep semantic start/completion/text events available to continuation analysis and request rebuilding
  • add a regression that classifies a 1 MiB tool-argument fragment as passthrough-only

Why

openai-chat now emits liveness during buffered tool-call deltas. The terminal guard already stopped retaining heartbeats, but it still retained every tool_call_delta, duplicating arbitrarily large argument fragments in memory even though neither terminal analysis nor continuation rebuilding consumes those events.

This is the runtime fix behind the valid retention finding raised on #2181. It does not loosen EOF/tool-call safety or change continuation decisions.

Verification

  • taskset -c 0,1 bun test tests/terminal-guard.test.ts — 19 passed
  • taskset -c 0,1 bun run typecheck — passed
  • taskset -c 0,1 bun run privacy:scan — passed
  • git diff --check — passed

Full-suite note: an earlier CPU-limited run reached unrelated environment failures (react/jsx-dev-runtime missing in a GUI suite and a 30-image native Claude test timing out under the two-core cap). The focused runtime suite and typecheck are green on the exact head.

Integration note

This is TypeScript-only and has no current Go counterpart. Per maintainer policy, the author will not approve or merge this PR. Please review and merge only after exact-head CI is green.

Refs #2181

Summary by CodeRabbit

  • Bug Fixes

    • Improved terminal event handling so heartbeat signals and large tool-argument updates pass through without being retained in the per-turn event history.
    • Continued retaining tool-start and text-update events for consistent terminal behavior.
  • Tests

    • Added coverage for passthrough and retained terminal event types.

@Ingwannu
Ingwannu requested a review from lidge-jun as a code owner August 20, 2026 11:54
@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 20, 2026
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f624007c-cb2c-4c72-a639-c53c85c63a20

📥 Commits

Reviewing files that changed from the base of the PR and between f2ebd30 and bbf29b3.

📒 Files selected for processing (2)
  • src/server/responses/terminal-guard.ts
  • tests/terminal-guard.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The terminal guard adds isTerminalGuardPassthroughOnly for heartbeat and tool-call-delta events. The event stream forwards these events without buffering them. Tests cover passthrough and retained event types.

Changes

Terminal guard passthrough

Layer / File(s) Summary
Passthrough classification and validation
src/server/responses/terminal-guard.ts, tests/terminal-guard.test.ts
The guard exports a predicate for heartbeat and tool-call-delta events. It uses the predicate to avoid buffering those events while preserving downstream emission. Tests verify heartbeat and tool-call fragments as passthrough-only, while tool starts and text deltas remain retained.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to bbf29

This localized change stops retaining large tool-call fragments while preserving semantic events needed for continuation handling. No actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested reviewers: lidge-jun

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the terminal guard change and the bounded retention of response deltas.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ingw/terminal-guard-delta-retention

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Ingwannu

Copy link
Copy Markdown
Owner Author

Exact-head CI is now fully green on bbf29b3c92a3b6b9af81d8ef275f4bb3bed92977.

The first Linux shard initially failed because the unrelated Codex autostart shim > an aged lock held by a live restore owner is never reclaimed test hit its 60-second timeout. I reran the failed jobs without changing the PR head; the same shard then completed successfully. All Linux shards, macOS, keyring/npm packaging smoke tests, gates, storage/API checks, privacy-related checks, and CodeRabbit now pass.

The diff remains limited to terminal-guard retention: heartbeat and tool-call delta events still flow downstream but are not duplicated in the guard retention array. This PR is ready for independent maintainer review. I will not self-approve or self-merge it.

@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 68 / 80

#2180이 openai-chat에 하트비트 넣었고, 가드는 하트비트만 seen에서 뺐음. tool_call_delta는 그대로 쌓임. 큰 args면 메모리만 두 배로 감. 이번 PR이 그 구멍을 막는 거임.

isTerminalGuardPassthroughOnlyheartbeattool_call_delta만 true임. analyzeTerminalTurntool_call_starttext_delta만 봄 (src/server/responses/terminal-guard.ts 쪽 도구 여부/텍스트 합치기). 컨티뉴 재빌드도 델타를 안 씀. 패스스루로 빼도 판단이 안 바뀜.

테스트가 헬퍼 함수만 봄. guardTerminalEventStream이 실제로 seen에 안 넣는 스트림 테스트는 아님. 분기가 그 함수 하나라서 큰 구멍은 아님. 1MiB args 케이스는 분류만 확인함.

#2156이랑 다른 선임. EOF truncation 아님. #2181에 나온 리텐션 지적 고치는 코드임. types.ts/config.ts 스플릿이랑도 상관 없음. 닫을 중복 아님.

작성자가 머지 안 한다고 적었음. CI만 그린이면 머지하면 됨.

해결방안: exact-head CI 그린 확인 후 dev에 머지. 리베이스 말고 이 패치 그대로. 스트림 테스트 하나 더 있으면 더 좋음. 없어도 머지 막지는 말 것.

이 댓글은 grok-bot이 작성했습니다

@Ingwannu
Ingwannu merged commit 03735ec into dev Aug 20, 2026
43 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants