Preserve `tool_kind` in Vercel AI and AG-UI message round-trips

Merged
AD
5mo ago
+1400-69

Closes #5846

Typed tool parts (LoadCapabilityCallPart/ReturnPart, NativeToolSearchCallPart/ReturnPart) lost their tool_kind discriminator through UI adapter round-trips, so a resuming agent forgot its loaded capabilities and discovered tools.

  • Vercel AI: tool_kind rides in the pydantic_ai provider_metadata on dump and in streamed chunks; load feeds it to narrow_type, which is now best-effort and degrades to the plain part on validation failure instead of raising.
  • AG-UI: tool_kind rides in ToolCall/ToolMessage encrypted_value and is streamed via ReasoningEncryptedValueEvent(subtype='tool-call'), gated on ag-ui-protocol >= 0.1.13 (skipped on older versions). Returns fall back to the paired call's claim since streamed results have no metadata slot; error results stay untyped.

Checklist

  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • No breaking changes in accordance with the version policy.
  • PR title is fit for the release changelog.