Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

fix: unify mixed-format tool block handling across task + condense - #11417

Closed
daniel-lxs wants to merge 2 commits into
mainfrom
codex/mixed-tool-block-format-handling
Closed

fix: unify mixed-format tool block handling across task + condense#11417
daniel-lxs wants to merge 2 commits into
mainfrom
codex/mixed-tool-block-format-handling

Conversation

@daniel-lxs

@daniel-lxsdaniel-lxs commented Feb 11, 2026

Copy link
Copy Markdown
Member

Summary

  • add shared tool block format helpers for legacy (tool_use/tool_result) and AI SDK (tool-call/tool-result) shapes
  • refactor Task, condense, and validateToolResultIds to use shared helpers instead of duplicated local type guards/mappers
  • preserve mixed-format behavior in resume, condense orphan filtering, synthetic tool result injection, and tool-result ID reconciliation
  • add mixed-format regression tests for condense and tool-result validation

Why

Message history is currently a mix of legacy Anthropic and AI SDK shapes during migration. Prior logic handled these formats inconsistently across code paths, which risked orphan filtering mistakes and resume/protocol mismatches.

Testing

  • pnpm --dir src exec tsc --noEmit --pretty false
  • pnpm --dir src exec vitest run core/condense/__tests__/index.spec.ts core/task/__tests__/validateToolResultIds.spec.ts core/task/__tests__/Task.persistence.spec.ts core/task/__tests__/flushPendingToolResultsToHistory.spec.ts
  • push hook suite (repo check-types + full tests) passed during git push

@dosubotdosubotBot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 11, 2026
@ghost

ghost commented Feb 11, 2026

Copy link
Copy Markdown

RooviewerClockSee task

Re-reviewed after merge commit c1ab9ad. The merge with main adopted the rooMessage.ts dual-format helper approach from #11409, fully superseding this PR's toolBlockFormat.ts approach. The branch tree is now identical to main -- zero net changes. Previous format mismatch issue is resolved. No new issues.

  • injectSyntheticToolResults always emits legacy tool_result format for AI SDK orphans, unlike validateToolResultIds which matches the format via prefersAiSdkToolResultFormat
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@dosubotdosubotBot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Feb 11, 2026
Comment threadsrc/core/condense/index.ts Outdated
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size:XSThis PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@daniel-lxs