Title: fix(custom-tools): skip title conflicts when persisting inline tools from a workflow save by waleedlatif1 · Pull Request #9198 · simstudioai/sim · GitHub
Open Graph Title: fix(custom-tools): skip title conflicts when persisting inline tools from a workflow save by waleedlatif1 · Pull Request #9198 · simstudioai/sim
X Title: fix(custom-tools): skip title conflicts when persisting inline tools from a workflow save by waleedlatif1 · Pull Request #9198 · simstudioai/sim
Description: Summary Inline custom tools on an agent block (imported graphs, legacy format) carry no toolId. The first save inserts a workspace row under a generated id that is never written back to the block, so every later save of the same workflow re-offers the tool with no id, hits the workspace title-uniqueness guard on the row that same flow created, and throws. upsertCustomTools runs the batch in one transaction, so every other tool in that save is rolled back too, and the save logs "Some custom tools failed to persist". Split the batch write in operations.ts into a shared loop with a title-conflict policy. upsertCustomTools keeps its signature and runs it with 'error'. The new upsertCustomToolsSkippingTakenTitles runs it with 'skip': the insert uses ON CONFLICT (workspace_id, title) DO NOTHING, so a title that already exists (including one a concurrent save just committed) is left untouched and the rest of the batch persists. It returns the skipped titles. persistCustomToolsToDatabase (the post-commit step of the shared workflow state replace and of workflow import) now calls the skipping variant, and saved counts only the tools actually written. Why skip instead of adopting a same-titled row: adopting is only safe when the row is provably the same tool, and then writing it again changes nothing but updatedAt. When it is not the same tool, it is an unrelated library tool that must not be overwritten. Both cases come down to leaving the row alone, so skip is the smaller change. The block still runs from its inline definition either way. Behaviour that stays the same: the explicit create/update paths (POST /api/tools/custom, the v2 create use case) still call upsertCustomTools, so a duplicate title still throws and the whole batch rolls back (500 on the internal route, 409 on v2, as before). Id-resolved updates and legacy-tool updates are untouched. The only persistence change is that a conflicting title no longer fails the batch. Type of Change Bug fix Testing New custom-tools-persistence.integration.ts against real Postgres: saving the same graph twice (inline tool without toolId) returns no errors on the second save, persists the new tool next to it, and reports only that tool as saved; two concurrent saves of the same new tool both succeed and leave one row; an existing workspace tool with the same title keeps its code; upsertCustomTools without the option still rejects a duplicate title and rolls back the rest of its batch. The first two cases fail on the pre-fix code (the second save returns the title error and the new tool is never written). Existing unit suites for persistence, operations, and the custom-tool use cases pass. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing (new tests pass the test-audit authoring gate) 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 Inline custom tools on an agent block (imported graphs, legacy format) carry no toolId. The first save inserts a workspace row under a generated id that is never written back to the block,...
X Description: Summary Inline custom tools on an agent block (imported graphs, legacy format) carry no toolId. The first save inserts a workspace row under a generated id that is never written back to the block,...
Opengraph URL: https://github.com/simstudioai/sim/pull/9198
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:14b827b3-4353-8895-90c6-8faaf27138fe |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E7DE:1ACD9:1AF803:25F727:6AFB793D |
| html-safe-nonce | c9ba470c49609b902a5b53d07944eb166c8f1b8412515fff7cb6dfba3e676334 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0RFOjFBQ0Q5OjFBRjgwMzoyNUY3Mjc6NkFGQjc5M0QiLCJ2aXNpdG9yX2lkIjoiMTk2MzEwNDU0MjQ1MjI2ODEzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c070507a565c714efc23464144d8b0db5729c8ec93891ee8864dcda4b79fa9dd |
| hovercard-subject-tag | pull_request:4912806277 |
| 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/9198/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 Inline custom tools on an agent block (imported graphs, legacy format) carry no toolId. The first save inserts a workspace row under a generated id that is never written back to the block,... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ef32892d4269fb87b55e81cc4ba8d86e0f16aa28446ffbf46cba8be5179ab188 |
| 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 | bc3703b4dcbe820d1284ef63c88b001c850be25e |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width