You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(codex): preserve native mixed history and tool records - #905
Project native Codex subagent activity, collaboration calls and dynamic tools through the existing stream bridge. Preserve mixed user content in message metadata, and return an oversized indivisible transcript record alone instead of aborting pagination.
Why
Direct history viewing and import can fail on otherwise valid native histories containing these records. Related to #904. This does not address the separate transient duplicate-rendering report (#903).
How to test
Run the CLI tests streamEventBridge.test.ts, pageCodexTranscript.nativeHistory.test.ts and readCodexUserMessageContent.test.ts: 33 passed.
Run adjacent runtime.test.ts, rolloutMapper.test.ts and pageCodexTranscript.test.ts: 279 passed; the missing-CLI error-class assertion failed identically with unmodified base production sources. CLI typecheck and build passed.
Read-only native paging completed for six affected local histories with unique message IDs. After switching the local daemon to the build, the actual encrypted cloud RPC returned all 1,984 projected records across 26 pages for one affected conversation, including a record larger than 1 MB. No conversation contents or credentials are included in this PR.
Notes
Draft: end-to-end cloud import/takeover has not been rerun; browser confirmation is pending. Successful history reads are not claimed as a completed import.
Mixed user content is preserved in meta.codexNativeContent. Images show an explicit unavailable-preview placeholder; original URL/data or local path is retained. Local image files are not copied.
Activity completion does not imply that a child agent has finished. Live completion fields are retained even when absent from the started event.
Unknown user-content types still fail explicitly. The larger-record behavior matches existing rollout paging.
No server/authentication changes. Existing native histories remain unchanged. The 0.3 port has not been performed; this draft covers the current 0.2 CLI line.
AI-assisted implementation and verification. The automated checks and read-only live verification above were performed by the assistant; no personal human UI acceptance is claimed.
Checklist
PR targets dev
Linked related issue
Added regression tests
Updated behavior documentation
Disclosed AI assistance and validation limits
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Note
Preserve native Codex mixed user content and tool records in history
Adds readCodexUserMessageContent in readCodexUserMessageContent.ts, which builds display text from text, mention, skill, image, audio, and local-media parts and keeps the original native parts alongside it. Inline media bytes are excluded from display text.
The stream bridge now recognizes native subagent, collaboration, and dynamic-tool records as tool contexts, and forwards mixed user content through the history projector instead of rejecting non-text user messages.
Provider-originated user messages and direct transcript messages carry the native Codex content in their metadata.
Unsupported or malformed native content throws a sanitized projection error that reports only a validated type identifier, not payload text. See codexNativeProjectionError.
Risk: pageCodexNativeTranscript now returns an oversized single record as its own page instead of erroring; mixed user media that was previously rejected is now imported with native metadata — check pageCodexTranscript.nativeHistory.test.ts and the feature matrix in codex-feature-matrix.md.
User messages can retain supported native content, including skill references, mentions, and media references, alongside readable text. Images and audio show a preview-unavailable notice while their original references are preserved.
Conversation history now displays subagent activity, collaboration tools, and dynamic tool calls with their results.
Bug Fixes
Oversized transcript records are returned on their own instead of being skipped.
Unsupported content is reported clearly, without exposing private payload details.
The changes project mixed Codex user content and native activity records into app-server and direct transcript paths. They retain supported native content in message metadata, add sanitized projection errors, and allow an oversized first transcript record to be returned alone.
Changes
Codex Native History
Layer / File(s)
Summary
Project native user content apps/cli/src/backends/codex/utils/readCodexUserMessageContent.ts, apps/cli/src/backends/codex/utils/codexNativeProjectionError.ts, apps/cli/src/backends/codex/utils/readCodexUserMessageContent.test.ts
The new projection helper formats supported text, skill, mention, image, and audio content. It retains original content for supported non-text parts and text annotations. Projection errors use a sanitized wire-type identifier.
Bridge native records into history apps/cli/src/backends/codex/appServer/streamEventBridge.ts, apps/cli/src/backends/codex/appServer/session/projectCodexNativeHistoryItem.ts, apps/cli/src/backends/codex/appServer/runtime.ts, apps/cli/src/backends/codex/localControl/rolloutMapper.ts, apps/cli/src/backends/codex/rollout/projectCodexRolloutActions.ts, apps/cli/src/backends/codex/appServer/streamEventBridge.test.ts
The stream bridge recognizes subagent activity, collaboration tool calls, and dynamic tool calls. User-text updates and projected actions can carry native content, which imported messages store as codexNativeContent. Tests cover native tool inputs and results in history and live projections.
Map and page direct transcripts apps/cli/src/backends/codex/directSessions/mapCodexRolloutLineToDirectMessages.ts, apps/cli/src/backends/codex/directSessions/pageCodexNativeTranscript.ts, apps/cli/src/backends/codex/directSessions/pageCodexTranscript.nativeHistory.test.ts, docs/codex-feature-matrix.md
Direct transcript mapping adds native content to message metadata. Paging returns an oversized first record alone. Tests cover mixed content, import behavior, and call/result rows for native tool records. The feature matrix describes these projection and paging behaviors.
sequenceDiagram
participant Codex as Codex user message
participant Bridge as streamEventBridge
participant Projector as readCodexUserMessageContent
participant History as projectCodexNativeHistoryItem
participant Runtime as runtime
Codex->>Bridge: user message content
Bridge->>Projector: content parts
Projector-->>Bridge: text and optional nativeContent
Bridge-->>History: provider-user-text update
History-->>Runtime: projected user-text action
Runtime->>Runtime: attach codexNativeContent when present
happier-dev/happier#740: This PR extends the shared native-record projection path used by PR #740 to additional collaboration and dynamic-tool records.
Suggested labels: needs:maintainer
Suggested reviewers: leeroybrun
Merge Risk: Minimal · up to d36f5
The change projects native Codex subagent, collaboration and dynamic-tool history, preserves mixed user content, and returns an oversized record alone when paging. No concrete merge-blocking risk was established. The one open question is whether an in-progress tool could be shown with a premature result. Evidence suggests this is unlikely, but it is unconfirmed.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main changes: preserving native mixed history and tool records for Codex.
Description check
The description follows the required template. It explains the changes, motivation, testing, risks, validation limits, and checklist status. The screenshots section is not needed because this is not a…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description follows the required template. It explains the changes, motivation, testing, risks, validation limits, and checklist status. The screenshots section is not needed because this is not a UI change.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
…lures
Accept Codex 0.167 audio and file-id media inputs at the shared native user
content boundary. Preserve text annotations using either supported spelling.
Report the projection phase and sanitized unsupported type without including
native content bodies or paths in errors.
Preserve client message correlation alongside retained native content when
combining the two projection changes. Validate the real native provider
catalog, paging, media adoption, encrypted importer and HTTP commit boundary,
including no partial writes when a later history page is unsupported.
Refs happier-dev#904
Co-authored-by: kairan <kairan0@qq.com>
[Medium impact] The reviewed changes appear safe to merge; no actionable defect was established.
Summary
The PR extends the shared Codex stream bridge to preserve native activity, collaboration, dynamic tool records, and mixed user content.
Codex activity and dynamic tool records appear as tool rows.
Codex user messages show mixed content and retain its original parts.
Native transcript paging returns oversized records one at a time.
Review used source inspection; no tests or live UI checks were run during this review.
Acknowledged limits from kairan0: the 0.3 port is not performed; end-to-end cloud import/takeover and browser confirmation remain pending; local media files are not copied and previews remain unavailable; unknown content types fail explicitly; the separate transient duplicate-rendering report is outside scope.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Native history] --> B[Shared stream bridge]
C[Live notifications] --> B
B --> D[Tool calls and results]
B --> E[User text and original content]
D --> F[Direct paging or stored messages]
E --> F
Thanks @kairan0 for the investigation and fix. Keeping native history and live events on the shared Codex bridge is the right approach, and preserving mixed user content addresses a real gap behind #904.
I added support for the current native media shapes, payload-free projection diagnostics, and a test that imports a complete encrypted transcript and verifies that unsupported content on a later page causes no partial writes. I also integrated the current dev changes while preserving both client-message correlation and native content. Focused coverage and the CLI typecheck pass on d36f5e8.
The source change is recommended to merge. I marked the PR ready for review and approved its fork CI run; required CI and approving review still need to finish before merging. The 0.3 adaptation is applied locally, with focused tests passing, but its wider validation remains blocked by existing destination errors. Reporter-cloud takeover and browser confirmation have not been reproduced here.
9-9: Major · Data Integrity & Integration · Heavy lift
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Do not project an active native tool as completed.
If thread/items/list returns a dynamicToolCall or collabAgentToolCall with status: 'inProgress', this line sends it as item/completed. The new bridge branch then emits a tool-result row. Direct history shows a result before completion, and a one-shot import can persist that premature result. Route nonterminal history items through the started path; emit a result only for terminal status. Codex 0.167 defines inProgress for both tool types. (github.com)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Follow-up on d36f5e893116aec91a2301b9d4b1c67ab64773fd: the required review is now approved, and no actionable code finding remains from the final review.
Merge is currently blocked by CI run 43094858253. After fork-run approval and one native rerun, GitHub still reports startup_failure, zero jobs, and an internal-error annotation. None of the required test/build checks executed. Auto-merge is disabled for the repository, so I cannot queue the merge. No further author changes are requested on the evidence available; the next action is to recover CI and obtain successful required checks on this head, then merge. The local 0.3 adaptation remains uncommitted, with broader validation blocked as noted above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Project native Codex subagent activity, collaboration calls and dynamic tools through the existing stream bridge. Preserve mixed user content in message metadata, and return an oversized indivisible transcript record alone instead of aborting pagination.
Why
Direct history viewing and import can fail on otherwise valid native histories containing these records. Related to #904. This does not address the separate transient duplicate-rendering report (#903).
How to test
streamEventBridge.test.ts,pageCodexTranscript.nativeHistory.test.tsandreadCodexUserMessageContent.test.ts: 33 passed.runtime.test.ts,rolloutMapper.test.tsandpageCodexTranscript.test.ts: 279 passed; the missing-CLI error-class assertion failed identically with unmodified base production sources. CLI typecheck and build passed.Notes
meta.codexNativeContent. Images show an explicit unavailable-preview placeholder; original URL/data or local path is retained. Local image files are not copied.Checklist
devOpen in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Note
Preserve native Codex mixed user content and tool records in history
readCodexUserMessageContentin readCodexUserMessageContent.ts, which builds display text from text, mention, skill, image, audio, and local-media parts and keeps the original native parts alongside it. Inline media bytes are excluded from display text.codexNativeProjectionError.pageCodexNativeTranscriptnow returns an oversized single record as its own page instead of erroring; mixed user media that was previously rejected is now imported with native metadata — checkpageCodexTranscript.nativeHistory.test.tsand the feature matrix in codex-feature-matrix.md.Macroscope summarized d36f5e8.
Summary by CodeRabbit