Fix providerOptions typing on message parts #6846

Closed
opened 2026-02-16 18:05:25 -05:00 by yindo · 1 comment
Owner

Originally created by @adolago on GitHub (Jan 19, 2026).

Originally assigned to: @thdxr on GitHub.

Problem

packages/agent-core/src/provider/transform.ts adds providerOptions to message parts, but part types from the AI SDK do not include that property. Typecheck fails even though the runtime behavior is intended.

Proposed fix

  • Introduce a local part type that includes optional providerOptions, or
  • Narrow to parts that support it and cast when mapping (as { providerOptions?: Record<string, unknown> }).
  • Keep the providerOptions remap logic intact.

Acceptance criteria

  • TS2339 is resolved at transform.ts:285.
  • Provider option remapping still applies to both message and part payloads.

Test plan

  • bun run typecheck
Originally created by @adolago on GitHub (Jan 19, 2026). Originally assigned to: @thdxr on GitHub. ## Problem `packages/agent-core/src/provider/transform.ts` adds `providerOptions` to message parts, but part types from the AI SDK do not include that property. Typecheck fails even though the runtime behavior is intended. ## Proposed fix - Introduce a local part type that includes optional `providerOptions`, or - Narrow to parts that support it and cast when mapping (`as { providerOptions?: Record<string, unknown> }`). - Keep the providerOptions remap logic intact. ## Acceptance criteria - TS2339 is resolved at `transform.ts:285`. - Provider option remapping still applies to both message and part payloads. ## Test plan - `bun run typecheck`
yindo closed this issue 2026-02-16 18:05:25 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 19, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #9480: Fix updatePart input narrowing for delta wrapper - Similar TypeScript type narrowing issues affecting message/part type definitions in the same codebase
  • #9364: Claude Extended Thinking: assistant message content order causes API error - Related message part transformation logic in transform.ts
  • #8903: Whitespace content causes API validation errors in provider transformations - Other provider transformation issues affecting transform.ts
  • #8184: Strict JSON Schema validation fail on backends like SGLang - Additional schema/part transformation concerns in transform.ts

Feel free to ignore if #9479 addresses your specific case.

@github-actions[bot] commented on GitHub (Jan 19, 2026): This issue might be a duplicate of existing issues. Please check: - #9480: Fix updatePart input narrowing for delta wrapper - Similar TypeScript type narrowing issues affecting message/part type definitions in the same codebase - #9364: Claude Extended Thinking: assistant message content order causes API error - Related message part transformation logic in transform.ts - #8903: Whitespace content causes API validation errors in provider transformations - Other provider transformation issues affecting transform.ts - #8184: Strict JSON Schema validation fail on backends like SGLang - Additional schema/part transformation concerns in transform.ts Feel free to ignore if #9479 addresses your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6846