Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/docs/content/docs/cli/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8534,7 +8534,7 @@ sim workflows run <workflowId> [options]

Without --manual (or a flag that implies it) this runs the active deployment; a workflow never deployed has none. --manual runs the saved draft, as the source loop leaves it.

--dry runs the saved draft without its side effects: every tool call not declared read (sends, table writes, HTTP calls, custom and MCP tools) returns a placeholder and is listed in sideEffects.stubbed with the request it would have sent; check those payloads. Code (a Function block's, a Condition's expressions, a While or Do While loop's condition, or code an Agent's model writes) runs and is listed in sideEffects.unchecked. Child workflows run dry too; custom, Human in the loop and Wait blocks are answered whole, so the run never pauses. Agents read memory but write none, and the run raises no workspace event. --allow &lt;block&gt; sends that block's writes for real (use a test resource); allowing an Agent sends only its own tool calls, not a workflow or custom block it calls. --mock &lt;block&gt;=&lt;json&gt; answers a block with fixed output, to steer a branch; a locked block cannot be mocked, and a mock is data, so it cannot set a field the run's execution, trace or billing reads (such as cost, tokens, model or a field starting with _). A dry run is the --source-run only of another dry run, and is never resumed.
--dry runs the saved draft without its side effects: every tool call not declared read (sends, table writes, HTTP calls other than GET/HEAD/OPTIONS, custom and MCP tools) returns a placeholder and is listed in sideEffects.stubbed with the request it would have sent; check those payloads. Code (a Function block's, a Condition's expressions, a While or Do While loop's condition, or code an Agent's model writes) runs: its GET/HEAD/OPTIONS fetches are sent (an API that writes on a GET is not stubbed), and any other fetch, or one with a method-override header, gets an empty 200 and is listed in sideEffects.stubbed. Code in a remote sandbox (shell, Python, imports) is listed in sideEffects.unchecked, since its network cannot be seen. Child workflows run dry too; custom, Human in the loop and Wait blocks are answered whole, so the run never pauses. Agents read memory but write none, and the run raises no workspace event. --allow &lt;block&gt; sends that block's writes (a Function's fetches included) for real (use a test resource); allowing an Agent sends only its own tool calls, not a workflow or custom block it calls. --mock &lt;block&gt;=&lt;json&gt; answers a block with fixed output, to steer a branch; a locked block cannot be mocked, and a mock is data, so it cannot set a field the run's execution, trace or billing reads (such as cost, tokens, model or a field starting with _). A dry run is the --source-run only of another dry run, and is never resumed.

The result is the run: runId, status (completed, failed, paused or cancelled), error, output (the workflow's final output) and blockOutputs (what --select-output named). It has no success field: branch on status, or on the exit code. With --follow it is the stream's final frame instead: success and output.

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/cli/workflows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ sim workflows run <workflowId> [options]

Without --manual (or a flag that implies it) this runs the active deployment; a workflow never deployed has none. --manual runs the saved draft, as the source loop leaves it.

--dry runs the saved draft without its side effects: every tool call not declared read (sends, table writes, HTTP calls, custom and MCP tools) returns a placeholder and is listed in sideEffects.stubbed with the request it would have sent; check those payloads. Code (a Function block's, a Condition's expressions, a While or Do While loop's condition, or code an Agent's model writes) runs and is listed in sideEffects.unchecked. Child workflows run dry too; custom, Human in the loop and Wait blocks are answered whole, so the run never pauses. Agents read memory but write none, and the run raises no workspace event. --allow &lt;block&gt; sends that block's writes for real (use a test resource); allowing an Agent sends only its own tool calls, not a workflow or custom block it calls. --mock &lt;block&gt;=&lt;json&gt; answers a block with fixed output, to steer a branch; a locked block cannot be mocked, and a mock is data, so it cannot set a field the run's execution, trace or billing reads (such as cost, tokens, model or a field starting with _). A dry run is the --source-run only of another dry run, and is never resumed.
--dry runs the saved draft without its side effects: every tool call not declared read (sends, table writes, HTTP calls other than GET/HEAD/OPTIONS, custom and MCP tools) returns a placeholder and is listed in sideEffects.stubbed with the request it would have sent; check those payloads. Code (a Function block's, a Condition's expressions, a While or Do While loop's condition, or code an Agent's model writes) runs: its GET/HEAD/OPTIONS fetches are sent (an API that writes on a GET is not stubbed), and any other fetch, or one with a method-override header, gets an empty 200 and is listed in sideEffects.stubbed. Code in a remote sandbox (shell, Python, imports) is listed in sideEffects.unchecked, since its network cannot be seen. Child workflows run dry too; custom, Human in the loop and Wait blocks are answered whole, so the run never pauses. Agents read memory but write none, and the run raises no workspace event. --allow &lt;block&gt; sends that block's writes (a Function's fetches included) for real (use a test resource); allowing an Agent sends only its own tool calls, not a workflow or custom block it calls. --mock &lt;block&gt;=&lt;json&gt; answers a block with fixed output, to steer a branch; a locked block cannot be mocked, and a mock is data, so it cannot set a field the run's execution, trace or billing reads (such as cost, tokens, model or a field starting with _). A dry run is the --source-run only of another dry run, and is never resumed.

The result is the run: runId, status (completed, failed, paused or cancelled), error, output (the workflow's final output) and blockOutputs (what --select-output named). It has no success field: branch on status, or on the exit code. With --follow it is the stream's final frame instead: success and output.

Expand Down
6 changes: 3 additions & 3 deletions apps/docs/openapi-v2-workflows.json
Original file line number Diff line number Diff line change
Expand Up @@ -17265,7 +17265,7 @@
"type": "null"
}
],
"description": "What the call would have sent: an in-process operation's input, an HTTP call's `method`, `url` and `body` (never headers), or a custom or MCP tool's `arguments`. For a block answered whole, its logged inputs. Credentials, secrets, password fields and (when the workspace redacts it) PII are redacted; null when the run could not prove none remain, or could not build the request once they were masked (such as a URL that is wholly a secret)."
"description": "What the call would have sent: an in-process operation's input, an HTTP call's `method`, `url` and `body` (never header values; for code's `fetch`, header names, the URL capped with only query parameter names, the body capped, and the code's workspace and personal secrets masked, though a secret typed into the code itself is not), or a custom or MCP tool's `arguments`. For a block answered whole, its logged inputs. Credentials, secrets, password fields and (when the workspace redacts it) PII are redacted; null when the run could not prove none remain, or could not build the request once they were masked (such as a URL that is wholly a secret)."
},
"returned": {
"type": "object",
Expand Down Expand Up @@ -17370,7 +17370,7 @@
"required": ["workflowId", "blockId", "block", "reason"],
"additionalProperties": false
},
"description": "Blocks whose code ran for real, once per block: a Function block's code, a Condition's expressions, a While or Do While loop's condition, or code an Agent's model wrote, which may make network calls the run cannot see."
"description": "Blocks whose code ran for real in a remote sandbox (shell, Python, JavaScript with imports, a selected sandbox or files), once per block: a Function block's code, a Condition's expressions, or code an Agent's model wrote, whose network calls the run cannot see. Code run in the isolate is not listed: its network writes are stubbed."
},
"omitted": {
"type": "object",
Expand Down Expand Up @@ -17758,7 +17758,7 @@
"minLength": 1
},
"dry": {
"description": "Dry run: every tool call not declared `read` (sends, table writes, HTTP calls, custom and MCP tools) is not sent; it returns a correctly shaped placeholder (a table row insert, upsert or update echoes the data it would have written, secrets masked) and is listed in `sideEffects.stubbed` with the request it would have sent, credentials, secrets and (when the workspace redacts it) PII redacted. Reads, model calls and credential resolution run for real, and so does code (a Function block's, a Condition's expressions, a While or Do While loop's condition, or code an Agent's model writes), listed in `sideEffects.unchecked`. Child workflows inherit it. Custom, Mothership, Pi, Human in the loop and Wait blocks are answered whole with placeholders. Agents read their memory but write none, and nothing else beyond the run's own log is kept: it raises no workspace event and does not count as a run of the workflow. Logged under the `test` trigger. Synchronous only: cannot be combined with `stream` or `waitTimeoutSeconds`.",
"description": "Dry run: every tool call not declared `read` (sends, table writes, HTTP calls other than a GET, HEAD or OPTIONS without a method-override header, custom and MCP tools) is not sent; it returns a correctly shaped placeholder (a table row insert, upsert or update echoes the data it would have written, secrets masked) and is listed in `sideEffects.stubbed` with the request it would have sent, credentials, secrets and (when the workspace redacts it) PII redacted. Reads, model calls and credential resolution run for real, and so does code (a Function block's, a Condition's expressions, a While or Do While loop's condition, or code an Agent's model writes): JavaScript without imports sends its GET, HEAD and OPTIONS `fetch` calls (an API that writes on a GET is not stubbed), while any other request, or one carrying a method-override header, gets an empty 200 response (header `x-sim-dry-run: stubbed`) and is listed in `sideEffects.stubbed` as tool `function_execute`; code in a remote sandbox (shell, Python, JavaScript with imports, a selected sandbox or files) has network the run cannot see and is listed in `sideEffects.unchecked`. Child workflows inherit it. Custom, Mothership, Pi, Human in the loop and Wait blocks are answered whole with placeholders. Agents read their memory but write none, and nothing else beyond the run's own log is kept: it raises no workspace event and does not count as a run of the workflow. Logged under the `test` trigger. Synchronous only: cannot be combined with `stream` or `waitTimeoutSeconds`.",
"type": "boolean"
},
"allowBlocks": {
Expand Down
27 changes: 27 additions & 0 deletions apps/sim/blocks/access-effect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { getToolMetadata } from '@/tools/metadata'
import type { ToolEffect } from '@/tools/types'

/**
* The `tools.access` of a block that calls a model (Agent, Router, Evaluator): one id per model
* provider it may call, not a registered tool.
*/
export const MODEL_PROVIDER_ACCESS_IDS: readonly string[] = [
'openai_chat',
'anthropic_chat',
'google_chat',
'xai_chat',
'deepseek_chat',
'deepseek_reasoner',
]

const MODEL_PROVIDER_ACCESS_ID_SET: ReadonlySet<string> = new Set(MODEL_PROVIDER_ACCESS_IDS)

/**
* The effect of one `tools.access` id: a registered tool's declared effect; `read` for a model
* provider, since a model call changes nothing outside Sim and a dry run sends it; `write` for any
* other id, which declares nothing. A block that also runs tools its user chooses is a writer
* whatever its access ids say.
*/
export function accessIdEffect(id: string): ToolEffect {
return getToolMetadata(id)?.effect ?? (MODEL_PROVIDER_ACCESS_ID_SET.has(id) ? 'read' : 'write')
}
10 changes: 2 additions & 8 deletions apps/sim/blocks/blocks/agent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createLogger } from '@sim/logger'
import { AgentIcon } from '@/components/icons'
import { MODEL_PROVIDER_ACCESS_IDS } from '@/blocks/access-effect'
import { getModelFallbackSubBlock, MODEL_FALLBACK_INPUTS } from '@/blocks/model-fallbacks'
import type { BlockConfig } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
Expand Down Expand Up @@ -415,14 +416,7 @@ Return ONLY the JSON array.`,
},
],
tools: {
access: [
'openai_chat',
'anthropic_chat',
'google_chat',
'xai_chat',
'deepseek_chat',
'deepseek_reasoner',
],
access: [...MODEL_PROVIDER_ACCESS_IDS],
config: {
tool: (params: Record<string, any>) => {
return resolveModelProviderId(params.model)
Expand Down
10 changes: 2 additions & 8 deletions apps/sim/blocks/blocks/evaluator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createLogger } from '@sim/logger'
import { ChartBarIcon } from '@/components/icons'
import { MODEL_PROVIDER_ACCESS_IDS } from '@/blocks/access-effect'
import { getModelFallbackSubBlock, MODEL_FALLBACK_INPUTS } from '@/blocks/model-fallbacks'
import type { BlockConfig, ParamType } from '@/blocks/types'
import {
Expand Down Expand Up @@ -228,14 +229,7 @@ export const EvaluatorBlock: BlockConfig = {
},
],
tools: {
access: [
'openai_chat',
'anthropic_chat',
'google_chat',
'xai_chat',
'deepseek_chat',
'deepseek_reasoner',
],
access: [...MODEL_PROVIDER_ACCESS_IDS],
config: {
tool: (params: Record<string, any>) => resolveModelProviderId(params.model),
},
Expand Down
19 changes: 3 additions & 16 deletions apps/sim/blocks/blocks/router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConnectIcon } from '@/components/icons'
import { MODEL_PROVIDER_ACCESS_IDS } from '@/blocks/access-effect'
import { getModelFallbackSubBlock, MODEL_FALLBACK_INPUTS } from '@/blocks/model-fallbacks'
import { AuthMode, type BlockConfig } from '@/blocks/types'
import {
Expand Down Expand Up @@ -186,14 +187,7 @@ export const RouterBlock: BlockConfig = {
},
],
tools: {
access: [
'openai_chat',
'anthropic_chat',
'google_chat',
'xai_chat',
'deepseek_chat',
'deepseek_reasoner',
],
access: [...MODEL_PROVIDER_ACCESS_IDS],
config: {
tool: (params: Record<string, any>) => resolveModelProviderId(params.model),
},
Expand Down Expand Up @@ -261,14 +255,7 @@ export const RouterV2Block: BlockConfig = {
getModelFallbackSubBlock(),
],
tools: {
access: [
'openai_chat',
'anthropic_chat',
'google_chat',
'xai_chat',
'deepseek_chat',
'deepseek_reasoner',
],
access: [...MODEL_PROVIDER_ACCESS_IDS],
config: {
tool: (params: Record<string, any>) => resolveModelProviderId(params.model),
},
Expand Down
37 changes: 32 additions & 5 deletions apps/sim/executor/execution/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,32 @@ export interface AnsweredBlockCall extends SideEffectBlockSite {
input: () => Promise<Record<string, unknown> | null>
}

/** A network request code made in the isolate, decided before its host sends it. */
interface CodeNetworkRequest {
/** The method as `fetch` sends it (`normalizeFetchMethod`); GET when the code named none. */
method: string
/** The names of the headers it carries, never their values. */
headerNames: string[]
/**
* What the request would send (method, capped origin and path with query parameter names, header
* names, a capped body; never a header value), redacted like a stubbed write's request; null
* when that cannot be vouched for. Built only when the request is recorded as stubbed.
*/
describe: () => Promise<Record<string, unknown> | null>
}

/** How a run treats the network of one run of code, from {@link SideEffectPolicy.codeNetwork}. */
export interface CodeNetworkPolicy {
/**
* Told before the code runs in a remote sandbox (shell, Python, JavaScript with imports, a
* selected sandbox or file system), whose network the run cannot see. Code that runs in the
* isolate instead has each network request decided by {@link onRequest}.
*/
ranInRemoteSandbox(): void
/** Whether the request is sent, or answered with an empty stubbed response instead. */
onRequest(request: CodeNetworkRequest): Promise<'send' | 'stub'>
}

/**
* How a run treats work that may change state outside it: a dry run, or a workflow test's
* unmocked writes. Unlike {@link ExecutionTestHooks}, every child execution inherits it, including
Expand All @@ -374,15 +400,16 @@ export interface AnsweredBlockCall extends SideEffectBlockSite {
*/
export interface SideEffectPolicy {
/**
* Whether this write tool call is sent or answered with {@link stubWrite}. Records a sent call
* the run should report: an allowed block's write, or code that runs unchecked.
* Whether this write tool call is sent or answered with {@link stubWrite}. Records an allowed
* block's sent write.
*/
decideWrite(call: SideEffectSite & { toolId: string }): 'send' | 'stub'
/**
* Records code that ran for real, which can make network calls the run cannot see: code run
* through `function_execute`, or a While or Do While loop's condition.
* The network policy of code about to run at `site`: code run through `function_execute` (a
* Function block's, a Condition's expressions, or code an Agent's model wrote), or a While or Do
* While loop's condition.
*/
ranCode(site: SideEffectSite): void
codeNetwork(site: SideEffectSite): CodeNetworkPolicy
/** Records a write that was not sent and returns the placeholder output answering it. */
stubWrite(call: StubbedToolCall): Record<string, unknown>
/** Whether this block is answered with {@link answerBlock} instead of running its handler. */
Expand Down
16 changes: 6 additions & 10 deletions apps/sim/executor/orchestrators/loop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,9 @@ describe('LoopOrchestrator', () => {
expect(shouldExecute).toBe(false)
expect(scope.skippedAtStart).toBe(true)
expect(state.setBlockOutput).not.toHaveBeenCalled()
expect(mockExecuteInIsolatedVM).toHaveBeenCalledWith(
expect.objectContaining({
code: 'return Boolean(false)',
})
)
expect(mockExecuteInIsolatedVM.mock.calls[0]?.[0]).toMatchObject({
code: 'return Boolean(false)',
})
})

it('escapes resolved strings without exposing rendered while conditions to logs', async () => {
Expand Down Expand Up @@ -294,11 +292,9 @@ describe('LoopOrchestrator', () => {

await orchestrator.evaluateInitialCondition(ctx, 'loop-1')

expect(mockExecuteInIsolatedVM).toHaveBeenCalledWith(
expect.objectContaining({
code: `return Boolean(${JSON.stringify(resolvedSecret)})`,
})
)
expect(mockExecuteInIsolatedVM.mock.calls[0]?.[0]).toMatchObject({
code: `return Boolean(${JSON.stringify(resolvedSecret)})`,
})
const logged = JSON.stringify([
...mockLogger.debug.mock.calls,
...mockLogger.info.mock.calls,
Expand Down
Loading
Loading