You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e34fbba
Browse filesBrowse the repository at this point in the historyBrowse files
fix(workflow-code): agent-facing semantics copy for guardrails failures, loop results, and params --full (#10543)
* fix(workflow-code): agent-facing semantics copy for guardrails failures, loop results, and params --full
- guardrails block, docs and previews: a failed check leaves through the error port, so handle it there (onError in workflow code), not with a Condition on passed
- loop/parallel results typed Json[][] with the per-iteration wording in core.d.ts, cookbook, primer and json-fields
- source params JSON brief names the --full lookup as next
* fix(sim-cli): keep the typed workspace and options in the params --full next step
The **Guardrails block** checks content and returns a result. Each block runs one validation type; chain blocks for multiple checks. Validation alone does not choose the next path—connect a Condition to act on it.
9
+
The **Guardrails block** checks content. Each block runs one validation type; chain blocks for multiple checks. A passing check continues along the normal output. A failed check leaves through the block's **error port**, so connect the error port to handle it.
10
+
11
+
<Callouttype="warn">
12
+
Do not branch on `<guardrails.passed>` with a Condition. A failed check never reaches the Condition, and with nothing on the error port the run completes without output. In workflow code, wire the failure with `onError`: `check.onError(reject)`.
Select **Valid JSON**, check `<agent.content>`, and branch on `<guardrails.passed>` before parsing it in Function. This checks JSON syntax, not a schema's required fields or types.
21
+
Select **Valid JSON** and check `<agent.content>`. Valid JSON continues to the Function that parses it; invalid JSON takes the error port to **Reject**, which reads the parse error as `<guardrails.error>`. This checks JSON syntax, not a schema's required fields or types.
18
22
19
23
## Configuration
20
24
21
25
Set **Content to Validate** to text or an earlier output, then select **Validation Type**.
22
26
23
27
### Valid JSON
24
28
25
-
Passes when the content parses as JSON. Invalid content returns `passed: false` and a parse error. Use a Function after this check if you also need schema validation.
29
+
Passes when the content parses as JSON. Invalid content fails the check with a parse error in `error`. Use a Function after this check if you also need schema validation.
26
30
27
31
### Regex match
28
32
@@ -32,7 +36,7 @@ Enter **Regex Pattern**, for example an email pattern:
32
36
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
33
37
```
34
38
35
-
Patterns use RE2's linear-time engine. Lookahead, lookbehind, and backreferences are unsupported and fail validation. To require that content does not contain a pattern, match the pattern and invert `passed` in a Condition.
39
+
Patterns use RE2's linear-time engine. Lookahead, lookbehind, and backreferences are unsupported and fail validation. To require that content does not contain a pattern, use a Condition or Function instead: a Regex Match that fails always takes the error port.
36
40
37
41
### Hallucination check
38
42
@@ -71,8 +75,8 @@ The picker groups these regional identifiers. Availability depends on the select
71
75
72
76
| Action | Result when PII is found |
73
77
| --- | --- |
74
-
|**Block Request** (default) |`passed: false`, detected entities, and an error summary |
75
-
|**Mask PII**|Replaced text in `maskedText`; `passed: true` when masking succeeds|
78
+
|**Block Request** (default) |Fails the check through the error port, with the detected entities and an error summary |
79
+
|**Mask PII**|Passes, with replaced text in `maskedText`|
76
80
77
81
With no PII found, Mask returns the original text. Read `detectedEntities` to distinguish no detection from successful masking.
78
82
@@ -84,10 +88,10 @@ Use `<guardrails.maskedText>` downstream in Mask mode. The original content is s
84
88
85
89
| Reference | Value |
86
90
| --- | --- |
87
-
|`<guardrails.passed>`|Validation outcome; for Mask, whether masking succeeded|
91
+
|`<guardrails.passed>`|`true` after a passing check; a failed check takes the error port instead|
88
92
|`<guardrails.validationType>`| Check that ran |
89
93
|`<guardrails.input>`| Original checked content |
90
-
|`<guardrails.error>`|Failure message, when present|
94
+
|`<guardrails.error>`|Why the check failed, for the block on the error port|
91
95
|`<guardrails.score>` / `<guardrails.reasoning>`| Grounding score and explanation for Hallucination Check |
92
96
|`<guardrails.detectedEntities>`| PII entities with type, location, detected text, and confidence |
93
97
|`<guardrails.maskedText>`| Masked text in Mask mode |
@@ -96,16 +100,17 @@ Use `<guardrails.maskedText>` downstream in Mask mode. The original content is s
Use `passed` for the configured threshold, or `score` for an explicit downstream comparison. Hallucination checks run synchronously; choose the model and chunk count according to the latency your workflow allows.
103
+
A score below **Confidence** fails the check through the error port, where `<guardrails.score>` and `<guardrails.error>` say why. A grounded answer continues along the normal output. Hallucination checks run synchronously; choose the model and chunk count according to the latency your workflow allows.
Branch on `passed` to process clean input or reject detected PII. Selecting only the types relevant to your task keeps the check focused.
109
+
Clean input continues along the normal output; detected PII takes the error port to **Reject**. Selecting only the types relevant to your task keeps the check focused.
106
110
107
111
## Related docs
108
112
113
+
-[Connections and error paths](/workflows/connections)
109
114
-[Condition](/workflows/blocks/condition)
110
115
-[Function](/workflows/blocks/function)
111
116
-[Credentials and execution-log protection](/platform/credentials)
- Use regex validation for format checking (emails, phone numbers, URLs, etc.)
32
32
- Use hallucination check to validate LLM outputs against knowledge base content
33
33
- Use PII detection to block or mask sensitive personal information
34
-
- Access validation result with <guardrails.passed> (true/false)
34
+
- A failed check leaves through the error port, not the normal output: connect the error port to handle it (in workflow code, check.onError(handler)); the handler reads why as <guardrails.error>
35
+
- Do not branch on <guardrails.passed> with a Condition: on a failed check the Condition never runs, and the run ends with no output
35
36
- For hallucination check, access <guardrails.score> (0-10 confidence) and <guardrails.reasoning>
36
37
- For PII detection, access <guardrails.detectedEntities> and <guardrails.maskedText>
37
-
- Chain with Condition block to handle validation failures
- **References**: \`${SOURCE_ENTRY_FILE}\` reads \`x.content\`, text as \`\` t\`…\` \`\`, env as \`env.NAME\`. A function file (\`codeFile('./functions/x.js')\`) reads \`$ref.<key>.<path>\` (key: display name lowercased, no spaces or dots), \`$ref.loop.currentItem\` / \`.index\` in a body (\`parallel\` too), \`$env.NAME\`; \`.py\`/\`.sh\` files \`<key.path>\`, \`{{NAME}}\`. A block that never ran reads \`null\` (\`''\` in text).
62
62
${PATTERNS_HEADING} (\`.sim/examples/\`, indexed atop \`cookbook.ts\`; any builder: \`${PARAMS_COMMAND} <builder>\`):
63
63
- Condition: keys test in order, first true wins, \`else: true\` last; wire \`route.high.to(alert)\`.
64
-
- Loop: \`const each = loop.forEach('Each Order', { collection: recent.rows }, (p) => {\`; inside, \`p.currentItem.data.orderId\` and \`p.index\`; after, \`each.results\`.
64
+
- Loop: \`const each = loop.forEach('Each Order', { collection: recent.rows }, (p) => {\`; inside \`p.currentItem.data.orderId\`, \`p.index\`; after \`each.results[i][0]\`.
65
65
- Failure: \`lookup.onError(failed)\`; \`failed\` reads its message as \`lookup.error\` (any block; a Function's adds the line: \`.errorMessage\` doesn't).
66
66
- Retry: an \`api\` block resends with \`retries: 3\`, \`retryDelayMs: 500\`; any block's Retry on fail: 3rd argument, \`{ retry: { enabled: true, maxTries: 3, waitBetweenTriesMs: 2000 } }\`.
0 commit comments