Skip to content

fix(session): keep the text of a Codex tool output given as a list - #1202

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
jayhemnani9910:fix/codex-tool-output-list
Oct 19, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
jayhemnani9910:fix/codex-tool-output-list

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

Summary

Codex writes a tool output either as a string or as a list of content items (FunctionCallOutputBody = string | Array<FunctionCallOutputContentItem> in its protocol types). The list form shows up for tools that return images and for the JS REPL (exec): [{"type":"input_text","text":"..."},{"type":"input_image","image_url":"data:..."}]. The Codex reader does String(payload.output ?? '') (src/session-flow/adapters/codex.ts:559), so every list output becomes [object Object],[object Object] after migration or archiving.

This PR joins the input_text parts with \n, the same way the Claude Code reader flattens a tool_result array. String outputs are unchanged.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Test Plan

  • npx tsc --noEmit passes
  • npm run lint passes
  • npx vitest run passes (10796 pass; the same 6 tests fail on main here: two submodule-checkout cases that need git >= 2.54 (local 2.53), one hooks-reconcile-scope real-shell case, and three Cursor tests that need a sqlite3 CLI this machine does not have)
  • Added/updated tests for the change

New test in session-cmd.test.ts: a Codex rollout whose function_call_output is a list of two input_text items and one input_image must read back as Output:\ndone. On main it reads back as [object Object],[object Object],[object Object].

Real CLI with a throwaway HOME, migrating one of my Codex sessions (codex-cli 0.163.0, 52 tool outputs, all lists) with teamai session migrate <id> -s codex -t claude-code -y:

0.28.0-beta.5:  52 of 52 tool results are "[object Object],[object Object]"
this branch:     0 of 52

Related Issues

Follow-up to #593.

Notes for Reviewers

Images in a list output are dropped, as the Claude Code reader drops them from tool_result arrays. An image-only output (view_image) reads back as an empty string. If you would rather keep a marker such as [image] for each input_image, I can add it.

Copilot AI balanced review requested due to automatic review settings October 18, 2026 07:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

No findings in the specified diff.

The change preserves string outputs and joins text items from list outputs, with a regression test covering mixed text/image content.

The PR description includes sufficient testing: a representative real-CLI migration reports 0 of 52 corrupted tool results on this branch, versus 52 of 52 previously.

Review was read-only; I did not run, build, or install PR code.

@jeff-r2026
jeff-r2026 merged commit 5fc76d7 into Tencent:main Oct 19, 2026
14 checks passed
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.

3 participants