Title: fix(executor): give the workflow agent tool the caller's env and PII policy by waleedlatif1 · Pull Request #6611 · simstudioai/sim · GitHub
Open Graph Title: fix(executor): give the workflow agent tool the caller's env and PII policy by waleedlatif1 · Pull Request #6611 · simstudioai/sim
X Title: fix(executor): give the workflow agent tool the caller's env and PII policy by waleedlatif1 · Pull Request #6611 · simstudioai/sim
Description: Summary
A workflow attached as an Agent tool (workflow_executor) ran its entire child execution with environmentVariables: {} and no block-output PII redaction policy. The Pi block reaches the identical path (sim-tools.ts calls executeTool with executionContext: ctx), so it was affected the same way.
The failure was silent, and it leaked. With an empty env map the child's resolver cannot resolve {{MY_API_KEY}}, so EnvResolver returns the raw reference and the literal string {{MY_API_KEY}} is transmitted to the third-party API. The vendor 401s, the user sees an opaque auth error, and the variable name has already been handed to the vendor in an Authorization header or request body. Nothing in Sim reports "environment variable missing".
Separately, tenants who had explicitly enabled block-output PII redaction had it silently not applied to any child block in these runs.
Mechanism
buildCustomBlockExecutionContext hardcoded environmentVariables: {} when building the synthetic top-level ExecutionContext. That was safe for the branch it was written for: WorkflowBlockHandler.executeCore re-derives the publisher's env from getCustomBlockAuthority inside if (isCustomBlock), so the {} is provably overwritten before it is read.
The workflow-as-agent-tool path's synthetic block carries metadata.id: 'workflow_input' — it is not a custom block. It takes the non-custom branch, which keeps ctx.environmentVariables as-is, so the hardcoded {} flowed straight into the sub-Executor. Both fields landed as unnoticed side effects of #5273; #6539 later patched a third dropped field on the same context without noticing these two.
Fix
Thread both values through the runner options bag. executeTool reads them off the trusted executionContext, never params._context — that bag spreads model-reachable contextParams._context first, so sourcing from it would let a model inject its own env map or disable redaction. A test pins that a smuggled _context.environmentVariables is ignored.
Design decisions — please review these deliberately
environmentVariables is required, not optional-with-a-default. This is the entire recurrence guarantee. An empty env map is a wrong identity, not an absent value, and silent omission is exactly how this shipped — twice. Making it optional shortens the diff and re-arms the footgun; a future caller that forgets it is now a compile error.
piiBlockOutputRedaction stays optional. Here undefined genuinely is the correct value — most tenants have no policy at all. The asymmetry is intentional and documented in the TSDoc precisely so a future reader does not "unify" it.
deployed_block_executor deliberately receives neither value. Custom blocks skip the same-workspace assert and run cross-workspace under the publisher's identity, so the consumer's env and redaction rules would be the wrong tenant's. A test pins this so a later refactor cannot silently unify the branches.
Identity semantics — an honest note
This is not main's behavior, and it is not a strict subset of it. On main this tool was an HTTP hop into execution-core, which derived env from the child workflow's owner. This forwards the parent caller's map, matching the long-standing canvas workflow block (workflow-handler.ts keeps ctx.environmentVariables on the non-custom branch). It is a different identity, not a narrower one — chosen because it matches the canvas block byte-for-byte, is bounded to one workspace by assertChildWorkflowInWorkspace, and is the only variant consistent with the parent resolvedSecretTraceRegistry this path already forwards.
The narrow case that worked on main and still will not: a same-workspace child owned by another workspace member that relied on THAT member's personal environment variables.
⚠️ Release-note-worthy behavior change
Re-enabling block-output masking inside child runs means redaction now runs there with onFailure: 'throw' (block-executor.ts aborts rather than feed unmasked data downstream). For tenants who enabled block-output PII redaction, a child agent-tool call that succeeds unmasked today can now fail closed. That restores main's intended semantic — the control was always supposed to apply — but affected users will feel it as new failures.
Known gap, deliberately out of scope
tools/index.ts coalesces executionContext?.environmentVariables ?? {} because executionContext is optional on the options bag. /api/providers builds a runtime context without one and accepts a caller-supplied tools array, so a workflow_executor_
Open Graph Description: Summary A workflow attached as an Agent tool (workflow_executor) ran its entire child execution with environmentVariables: {} and no block-output PII redaction policy. The Pi block reaches the iden...
X Description: Summary A workflow attached as an Agent tool (workflow_executor) ran its entire child execution with environmentVariables: {} and no block-output PII redaction policy. The Pi block reaches the iden...
Opengraph URL: https://github.com/simstudioai/sim/pull/6611
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:71ef97e8-4f5e-3848-13a3-8f66fbeaa016 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CDF0:327CBE:6D5660:9B3E15:6AFB47B5 |
| html-safe-nonce | 810d87c28f74e481d3ab5a96e811c38c5b1426a939aa63765338498ed26d9b66 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDREYwOjMyN0NCRTo2RDU2NjA6OUIzRTE1OjZBRkI0N0I1IiwidmlzaXRvcl9pZCI6IjczOTYwMTExNDUyNDIwMzYxNDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 441a344e82e8b441a23dc85280b3ea3adab4c9ca95f07c575fa60f225f8212b7 |
| hovercard-subject-tag | pull_request:4260562907 |
| 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/6611/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 A workflow attached as an Agent tool (workflow_executor) ran its entire child execution with environmentVariables: {} and no block-output PII redaction policy. The Pi block reaches the iden... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | acf7616d06cc051644705b379878c9bb13dc5e70ecf4ffd9b34140f8ac01d7e1 |
| 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 | 26504db649b58525278f77a52b80ba5f10d5f4de |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width