Skip to content

fix(azure): add azure-anthropic support to router, evaluator, copilot, and tokenization#3158

Merged
waleedlatif1 merged 7 commits intostagingfrom
fix/azure-anthropic
Feb 6, 2026
Merged

fix(azure): add azure-anthropic support to router, evaluator, copilot, and tokenization#3158
waleedlatif1 merged 7 commits intostagingfrom
fix/azure-anthropic

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Add azure-anthropic to getProviderCredentialSubBlocks() so router and evaluator blocks show the Azure endpoint field
  • Forward azureEndpoint in router and evaluator handlers for azure-anthropic provider
  • Add azure-anthropic to copilot valid providers, types, and chat route
  • Add azure-anthropic to tokenization constants and estimator (uses Anthropic tokenizer)

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Feb 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 6, 2026 10:59pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 6, 2026

Greptile Overview

Greptile Summary

  • Extends Azure Anthropic support across blocks/tools by surfacing Azure endpoint/API version credential fields in block UIs and threading those credentials through router/evaluator/guardrails request paths.
  • Adds azure-anthropic to Copilot’s allowed provider set/types and wires env-based AZURE_ANTHROPIC_* config into the Copilot chat route.
  • Updates tokenization config/estimators so azure-anthropic uses Anthropic-style heuristics.
  • Adjusts the azure-anthropic provider to respect azureApiVersion for the anthropic-version header.

Confidence Score: 3/5

  • This PR is close to merge-ready but has at least one functional request-shape issue that can break Router/Evaluator provider calls in strict-validation paths.
  • Most changes are additive and consistent (env vars, types, tokenization, provider header). The main concern is the router/evaluator handlers now always including provider-specific credential fields regardless of provider, which can cause downstream validation or provider execution failures depending on the /api/providers schema and provider adapters.
  • apps/sim/executor/handlers/router/router-handler.ts; apps/sim/executor/handlers/evaluator/evaluator-handler.ts

Important Files Changed

Filename Overview
apps/sim/app/api/copilot/chat/route.ts Adds azure-anthropic env-based providerConfig wiring for copilot chat route.
apps/sim/app/api/guardrails/validate/route.ts Threads providerCredentials + workspaceId through guardrails validate endpoint into validateHallucination; no new obvious issues found in this file.
apps/sim/blocks/blocks/agent.ts Extends Azure endpoint/API version subblocks to include azure-anthropic models and updates placeholders/descriptions.
apps/sim/blocks/blocks/translate.ts Fixes bedrock credential mapping (adds missing bedrockAccessKeyId to tool params).
apps/sim/executor/handlers/evaluator/evaluator-handler.ts Now always includes azure/vertex/bedrock credential fields in providerRequest; may violate provider request schema if strict.
apps/sim/executor/handlers/router/router-handler.ts Now always includes azure/vertex/bedrock credential fields in providerRequest for both legacy and v2 router requests; likely breaks strict validation or downstream provider expectations.
apps/sim/lib/copilot/config.ts Adds azure-anthropic to VALID_PROVIDER_IDS for copilot config parsing.
apps/sim/lib/copilot/types.ts Adds CopilotProviderConfig variant for azure-anthropic with apiVersion/endpoint fields; resolves earlier missing apiVersion thread.
apps/sim/lib/core/config/env.ts Adds AZURE_ANTHROPIC_* env vars for endpoint/apiKey/apiVersion.
apps/sim/lib/guardrails/validate_hallucination.ts Adds providerCredentials/workspaceId support and resolves Vertex OAuth token inside scoring function before provider call; removes earlier getApiKey pre-check.
apps/sim/lib/tokenization/constants.ts Adds azure-anthropic to tokenization config constants.
apps/sim/lib/tokenization/estimators.ts Routes azure-anthropic token estimation through Anthropic estimator.
apps/sim/providers/azure-anthropic/index.ts Uses request.azureApiVersion as anthropic-version header (fallback 2023-06-01).
apps/sim/tools/guardrails/validate.ts Extends guardrails_validate tool to accept and forward azure/vertex/bedrock credential fields and context workspaceId/workflowId.
apps/sim/blocks/utils.ts Updates getProviderCredentialSubBlocks to include azure-anthropic models in azureEndpoint/azureApiVersion conditions and adjusts labels/placeholders.

Sequence Diagram

sequenceDiagram
  autonumber
  participant UI as Workflow UI/Executor
  participant RBH as RouterBlockHandler
  participant EBH as EvaluatorBlockHandler
  participant GR as /api/guardrails/validate
  participant VH as validateHallucination()
  participant PR as /api/providers
  participant AZA as azure-anthropic provider

  UI->>RBH: Execute Router block
  RBH->>PR: POST providerRequest (providerId + creds)
  PR-->>RBH: Provider response (route decision)

  UI->>EBH: Execute Evaluator block
  EBH->>PR: POST providerRequest (providerId + creds)
  PR-->>EBH: Provider response (scores)

  UI->>GR: POST guardrails_validate (input + model + providerCredentials)
  GR->>VH: validateHallucination(input)
  VH->>PR: executeProviderRequest(providerId, request)
  PR->>AZA: If providerId=azure-anthropic, call Azure Anthropic SDK
  AZA-->>PR: LLM response
  PR-->>VH: content/tokens
  VH-->>GR: score/reasoning
  GR-->>UI: validation result
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

8 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

15 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 6, 2026

Additional Comments (2)

apps/sim/lib/guardrails/validate_hallucination.ts
Spreading undefined credentials

scoreHallucinationWithLLM spreads ...providerCredentials into the provider request, but providerCredentials is optional and can be undefined (e.g., most callers won’t pass Azure/Vertex/Bedrock fields). Spreading undefined throws at runtime (TypeError: Cannot convert undefined or null to object), which will make hallucination validation fail for those requests.

This needs to guard the spread (e.g., ...(providerCredentials ?? {})) or otherwise ensure providerCredentials is always a defined object before spreading.


apps/sim/blocks/blocks/agent.ts
Wrong endpoint description

In inputs, azureEndpoint is still documented as 'Azure OpenAI endpoint URL', but this PR reuses the same field for both azure-openai and azure-anthropic (and the UI label was changed to “Azure Endpoint”). This mismatch will cause incorrect tool schema/help text and can confuse users configuring Azure Anthropic.

Update the description to a provider-agnostic Azure endpoint (matching the new shared usage).

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

15 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

- Pass all provider credentials unconditionally in router, evaluator (matching agent pattern)
- Remove conditional if-branching on providerId for credential fields
- Thread workspaceId through guardrails → hallucination validator for BYOK key resolution
- Remove getApiKey() from hallucination validator, let executeProviderRequest handle it
- Resolve vertex OAuth credentials in hallucination validator matching agent handler pattern

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

15 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 6, 2026

Additional Comments (1)

apps/sim/executor/handlers/router/router-handler.ts
Unconditional provider creds sent

providerRequest always includes azureEndpoint/azureApiVersion, vertexProject/vertexLocation, and bedrock* fields regardless of providerId (see providerRequest construction around this block). This can cause /api/providers to receive irrelevant credential fields (and even undefined values) for non-matching providers, which will break if the providers route validates payload shape strictly or forwards these into provider SDKs that reject unknown/empty fields.

Fix by only attaching the credential fields for the active provider (as the code did before this PR), or by ensuring the /api/providers request schema explicitly tolerates these extra fields across all providers.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1 waleedlatif1 merged commit 1edaf19 into staging Feb 6, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/azure-anthropic branch February 6, 2026 23:26
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.

1 participant