Title: fix(anthropic): keep enum and const as structured-output constraints by waleedlatif1 · Pull Request #7558 · simstudioai/sim · GitHub
Open Graph Title: fix(anthropic): keep enum and const as structured-output constraints by waleedlatif1 · Pull Request #7558 · simstudioai/sim
X Title: fix(anthropic): keep enum and const as structured-output constraints by waleedlatif1 · Pull Request #7558 · simstudioai/sim
Description: Summary transformJSONSchema from the Anthropic SDK has no branch for enum or const, so both were swept into the node's description as prose instead of staying real grammar constraints. Native structured outputs have been silently unenforced for them on every Anthropic and Azure Anthropic agent block. Lift enum/const out before the transform and re-attach them after, so all of the transform's sanitising (unknown string format, numeric bounds, minItems > 1, additionalProperties) is preserved verbatim. Only lift what the API grammar-checks: a non-empty enum of primitives all matching the node's declared type, and a primitive const. Everything else stays put and is demoted exactly as today — sending it would make the API reject the whole request, turning a working block into a hard 400. Type of Change Bug fix Testing Verified against the live Anthropic API on claude-sonnet-5: Enforcement: with a schema whose field is enum: [...] and a prompt explicitly instructing the model to emit an out-of-enum value, the old path returns the out-of-enum string and the new path returns a valid enum member. Same for number, integer, boolean and const. No regressions: 16 edge cases run through both the old and new code paths — object/array enum members, enum containing null, mixed-type enum, empty enum, enum disagreeing with the declared type, const with object/array values, plus the primitive shapes. All return 200 on both paths. Unit tests assert the wire payload's output_config.format.schema directly, and cover a property literally named enum, $defs, oneOf→anyOf, and both falsy const values (0, false). 1938/1938 tests in providers/ pass; verified the new tests fail when the fix is reverted. bun run lint, bun run check:audits (45 audits), docs-manifest:check and type-check all clean. 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)
Open Graph Description: Summary transformJSONSchema from the Anthropic SDK has no branch for enum or const, so both were swept into the node's description as prose instead of staying real grammar constraints. Native ...
X Description: Summary transformJSONSchema from the Anthropic SDK has no branch for enum or const, so both were swept into the node's description as prose instead of staying real grammar constraints. Nat...
Opengraph URL: https://github.com/simstudioai/sim/pull/7558
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:aa7337c7-3ae9-2bf6-ce29-a1c80faff37c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DEBA:AF687:B310EA:F62C4F:6AFB5170 |
| html-safe-nonce | e438550ece4c02cf4433bc6254b64018c27f10c93ed848f5fce8709d402a0123 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERUJBOkFGNjg3OkIzMTBFQTpGNjJDNEY6NkFGQjUxNzAiLCJ2aXNpdG9yX2lkIjoiMjc3MTQ0MzY5OTU1NTE5MzIwMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8dfc8763b5099491b1187811cf903c65de8a30ed45bb1b5f5f119bda262d57b9 |
| hovercard-subject-tag | pull_request:4455544158 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/7558/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary transformJSONSchema from the Anthropic SDK has no branch for enum or const, so both were swept into the node's description as prose instead of staying real grammar constraints. Native ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cbf66c024bb6d10e6955baa7413c54cf13a201bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width