Skip to content

Conversation

@batanus
Copy link
Contributor

@batanus batanus commented Jul 9, 2025

What

  • Make id parameter optional in ToolCallParam
  • Fallback to .function type during ToolCallParam decoding

Why

Some API providers for some AI models (such as openrouter.ai for Qwen model, mistral.ai for their models, and maybe others) don't return id and type parameters for ToolCallParam.

Affected Areas

ToolCallParam.id parameter

@batanus batanus force-pushed the fix/tool-call-param-optional-id branch from 52b1a39 to 966d743 Compare July 9, 2025 15:00
@nezhyborets
Copy link
Collaborator

nezhyborets commented Jul 9, 2025

Just for unification with other places, could we leave id non-optional and use parsingOptions?

let container = try decoder.container(keyedBy: CodingKeys.self)
let parsingOptions = decoder.userInfo[.parsingOptions] as? ParsingOptions ?? []
// Some API providers for some AI models (e.g. openrouter.ai for Qwen model, mistral.ai for their models) don't return id and type parameters for ToolCallParam.
// See https://github.com/MacPaw/OpenAI/pull/366
self.id = try container.decodeString(forKey: .id, parsingOptions: parsingOptions)

Copy link
Collaborator

@nezhyborets nezhyborets left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@nezhyborets nezhyborets merged commit aa1e629 into MacPaw:main Jul 9, 2025
3 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.

2 participants