Skip to content

perf(agent-runtime): skip thinking token progress persistence - #465

Merged
jerryliang64 merged 1 commit into
masterfrom
codex/filter-thinking-token-persistence
Jul 31, 2026
Merged

jerryliang64 merged 1 commit into
masterfrom
codex/filter-thinking-token-persistence

Conversation

@jerryliang64

@jerryliang64 jerryliang64 commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • exclude system/thinking_tokens progress counters from thread message persistence
  • keep those events available through /runs/stream and run-event replay
  • preserve the final assistant message, including its complete thinking content
  • cover the behavior at both MessageConverter and AgentRuntime integration levels

Root cause

After a run commits, the incremental message flusher attempts to mirror every executor message into the thread store. thinking_tokens is emitted frequently as a progress counter, so persisting it creates one awaited remote append per update on OSS/FUSE-backed stores and backpressures consumption of subsequent model events.

The counter is transient metadata rather than conversation history. Filtering it at the existing storage boundary removes that write amplification without changing the streaming protocol or final transcript.

Validation

  • core/agent-runtime: ut run test (210 passing)
  • core/agent-runtime: ut run tsc
  • core/agent-runtime: ut run tsc:pub
  • repository lint: ut run lint
  • independent correctness/security review: LGTM

Summary by CodeRabbit

  • Bug Fixes
    • Improved transcript persistence by excluding temporary streaming events and thinking-progress updates.
    • Preserved assistant responses and their thinking content unchanged in stored conversations.
    • Streaming clients continue to receive thinking-progress updates in real time.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4368398b-8784-41b7-9262-1ad0ce21985b

📥 Commits

Reviewing files that changed from the base of the PR and between d6e4285 and c5d0c58.

📒 Files selected for processing (4)
  • core/agent-runtime/src/AgentRuntime.ts
  • core/agent-runtime/src/MessageConverter.ts
  • core/agent-runtime/test/AgentRuntime.test.ts
  • core/agent-runtime/test/MessageConverter.test.ts

📝 Walkthrough

Walkthrough

The runtime now excludes system/thinking_tokens progress messages from persisted transcripts, alongside stream_event messages. Tests verify SSE forwarding, transcript filtering, and preservation of assistant content.

Changes

Transient storage filtering

Layer / File(s) Summary
Extend storage filtering
core/agent-runtime/src/AgentRuntime.ts, core/agent-runtime/src/MessageConverter.ts
filterForStorage removes system/thinking_tokens messages and retains existing stream_event filtering. Documentation describes both transient message types.
Validate streaming and persistence
core/agent-runtime/test/AgentRuntime.test.ts, core/agent-runtime/test/MessageConverter.test.ts
Tests verify SSE forwarding, exclusion from persisted threads, and unchanged assistant messages, including thinking content.

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

Possibly related PRs

  • eggjs/tegg#433: Extends the same MessageConverter.filterForStorage persistence filtering.
  • eggjs/tegg#434: Modifies transcript persistence and transient message filtering.
  • eggjs/tegg#449: Modifies AgentRuntime partial transcript persistence.

Suggested reviewers: akitasummer

✨ 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 codex/filter-thinking-token-persistence

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

core/agent-runtime/src/AgentRuntime.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

core/agent-runtime/src/MessageConverter.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

core/agent-runtime/test/AgentRuntime.test.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 1 others

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.

@jerryliang64
jerryliang64 marked this pull request as ready for review July 31, 2026 02:10
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@jerryliang64
jerryliang64 merged commit 82c1e1f into master Jul 31, 2026
11 of 12 checks passed
@jerryliang64
jerryliang64 deleted the codex/filter-thinking-token-persistence branch July 31, 2026 02:10
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