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(host-runtime): preserve External Side Chat context via thread/inject_items - #551
Codex Desktop initializes Side Chat by sending thread/inject_items with a boundary message ("inherited history is reference-only…"). For External Harness Threads this method was not in the External Thread allow-list, so Host answered -32076 External Thread does not support thread/inject_items and Desktop reported Error opening side chat (Case B in #550).
External Harness sessions have no raw item-history mutation API, and dropping or fake-acknowledging the message would change Side Chat semantics. This PR takes option 2 from #550: Host buffers the boundary context and merges it into the first real Turn input, without creating a synthetic native Turn.
thread/inject_items is routed to External Threads. Only user message items whose content parts are text (input_text / text) are accepted; anything else is rejected with -32602, so context that would be lost is never acknowledged.
Accepted text is kept in ExternalThread.pendingInjectedText (deduplicated) and combined with the next turn/start text (pending…\n\ntext). The buffer is cleared only after the native turn.start succeeds, so a failed start keeps the context for the retry.
Idle release is blocked while injected text is pending, so the context is not dropped with the Session.
New helpers live in external-thread-inject.ts to keep app-server-host.ts from growing further.
Related issues
Refs #550. This covers Case B (completed source Turn → thread/inject_items). It does not address Case A (source Turn still running → -32080 External Fork Checkpoint is unavailable), so this PR should not close the issue.
Test plan
Automated (run in this worktree, macOS arm64, based on main1aa9f65):
npm run typecheck — passed
npm run lint (eslint + tools/check-boundaries.mjs) — passed
npx prettier --check on the 4 changed files — passed
npx vitest run --config tests/vitest.config.js packages/host-runtime/test/app-server-host.projection-3.test.ts — 49 passed, including two new tests:
Fork → thread/inject_items → first Turn: the derived Session's Turn input is Side conversation boundary.\n\nsynthetic.
Non-text item (input_image) → -32602.
npx vitest run --config tests/vitest.config.js packages/host-runtime — 1048 passed, 1 failed on the full-package run: harness-plugin-loader.test.ts > gives later plugins a full timeout after earlier plugins finish (diagnose called 4 times). That file is not touched by this PR; it passed 50/50 on two separate single-file runs. I did not confirm the failure on a clean main baseline (the attempted baseline checkout had no built dist), so I can't say whether it is a pre-existing load-sensitive flake.
Manual: with Codex Desktop launched through the locally built codexhost from this branch (macOS arm64), Side Chat now opens on an External Harness session.
Not verified: that the Harness model actually follows the boundary text across several Side Chat turns; each Harness separately (the issue reproduces on DSH and Claude Code; I have not recorded which one was used for the manual check); Windows/Linux; the Case A path; behavior across a Host restart (the buffer is in-memory only).
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
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
Codex Desktop initializes Side Chat by sending
thread/inject_itemswith a boundary message ("inherited history is reference-only…"). For External Harness Threads this method was not in the External Thread allow-list, so Host answered-32076 External Thread does not support thread/inject_itemsand Desktop reportedError opening side chat(Case B in #550).External Harness sessions have no raw item-history mutation API, and dropping or fake-acknowledging the message would change Side Chat semantics. This PR takes option 2 from #550: Host buffers the boundary context and merges it into the first real Turn input, without creating a synthetic native Turn.
thread/inject_itemsis routed to External Threads. Only usermessageitems whose content parts are text (input_text/text) are accepted; anything else is rejected with-32602, so context that would be lost is never acknowledged.ExternalThread.pendingInjectedText(deduplicated) and combined with the nextturn/starttext (pending…\n\ntext). The buffer is cleared only after the nativeturn.startsucceeds, so a failed start keeps the context for the retry.external-thread-inject.tsto keepapp-server-host.tsfrom growing further.Related issues
Refs #550. This covers Case B (completed source Turn →
thread/inject_items). It does not address Case A (source Turn still running →-32080 External Fork Checkpoint is unavailable), so this PR should not close the issue.Test plan
Automated (run in this worktree, macOS arm64, based on
main1aa9f65):npm run typecheck— passednpm run lint(eslint +tools/check-boundaries.mjs) — passednpx prettier --checkon the 4 changed files — passednpx vitest run --config tests/vitest.config.js packages/host-runtime/test/app-server-host.projection-3.test.ts— 49 passed, including two new tests:thread/inject_items→ first Turn: the derived Session's Turn input isSide conversation boundary.\n\nsynthetic.input_image) →-32602.npx vitest run --config tests/vitest.config.js packages/host-runtime— 1048 passed, 1 failed on the full-package run:harness-plugin-loader.test.ts > gives later plugins a full timeout after earlier plugins finish(diagnosecalled 4 times). That file is not touched by this PR; it passed 50/50 on two separate single-file runs. I did not confirm the failure on a cleanmainbaseline (the attempted baseline checkout had no builtdist), so I can't say whether it is a pre-existing load-sensitive flake.Manual: with Codex Desktop launched through the locally built
codexhostfrom this branch (macOS arm64), Side Chat now opens on an External Harness session.Not verified: that the Harness model actually follows the boundary text across several Side Chat turns; each Harness separately (the issue reproduces on DSH and Claude Code; I have not recorded which one was used for the manual check); Windows/Linux; the Case A path; behavior across a Host restart (the buffer is in-memory only).