Skip to content

fix: validate tool_calls responses at provider boundary#23

Open
stackbilt-admin wants to merge 1 commit intomainfrom
fix/tool-call-validation
Open

fix: validate tool_calls responses at provider boundary#23
stackbilt-admin wants to merge 1 commit intomainfrom
fix/tool-call-validation

Conversation

@stackbilt-admin
Copy link
Copy Markdown
Member

Summary

  • Adds validateToolCalls() to BaseProvider that checks each tool call for required fields (id, type, function.name, function.arguments) and correct types
  • Applied in all five providers (OpenAI, Anthropic, Groq, Cerebras, Cloudflare) at the response formatting boundary
  • Malformed entries are dropped with a logger.warn rather than propagated to callers or throwing

Closes #22

Test plan

  • 12 new tests in tool-call-validation.test.ts covering all providers
  • Tests for: missing id, invalid type, empty function.name, non-string arguments, mixed valid/invalid arrays
  • All 146 tests pass (134 existing + 12 new)
  • TypeScript type check clean

🤖 Generated with Claude Code

Add validateToolCalls() to BaseProvider and apply it in all five providers
(OpenAI, Anthropic, Groq, Cerebras, Cloudflare). Malformed entries are
dropped with a warning rather than propagated to the caller.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

fix: validate tool_calls responses at provider boundary

1 participant