Skip to content

Commit 42767f3

Browse files
anticomputerCopilot
andcommitted
fix(docs,test): correct if/undefined semantics doc and drop redundant del
The task-level `if:` condition treats an undefined name as falsy and skips the task (the runner catches UndefinedError), so correct GRAMMAR.md which claimed it raises; also clarify that in-prompt templating still raises on undefined, unlike `if`. Remove an unnecessary `del` in a stream test helper flagged by code scanning. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ebb8ccc commit 42767f3

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

doc/GRAMMAR.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ Notes:
223223
- The expression may be written bare (`globals.mode == 'deep'`) or wrapped in
224224
`{{ ... }}`. Standard truthiness applies (empty list/string/`0`/`false` are
225225
falsy).
226-
- The condition is evaluated with `StrictUndefined`, so referencing a name that
227-
does not exist raises rather than silently skipping. Guard optional data with
226+
- Referencing a name that does not exist (for example an output from a task that
227+
has not run) is treated as falsy, so the task is skipped rather than failing,
228+
matching GitHub Actions semantics. To be explicit you can still guard with
228229
`is defined`, e.g. `if: "outputs.audit is defined and outputs.audit.findings"`.
229230
- `if` composes with everything else: a skipped task does not run its agents,
230231
fan out over `models`, or capture outputs.
@@ -248,8 +249,10 @@ directly inside a `user_prompt`:
248249
{% endfor %}
249250
```
250251

251-
As with `if`, undefined variables raise (to catch typos). Use `is defined` or
252-
the `default` filter for optional data: `{{ globals.note | default('') }}`.
252+
Unlike the task-level `if` condition (which treats undefined names as falsy and
253+
skips the task), undefined variables inside a prompt raise, to catch typos. Use
254+
`is defined` or the `default` filter for optional data:
255+
`{{ globals.note | default('') }}`.
253256

254257
### Running templated tasks in a loop
255258

tests/test_stream.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ async def _fake_render(text: str, **_kw: Any) -> None:
115115

116116

117117
def test_drive_forwards_token_usage(monkeypatch):
118-
async def _fake_render(text: str, **_kw: Any) -> None:
119-
del text
118+
async def _fake_render(*_a: Any, **_kw: Any) -> None:
119+
return None
120120

121121
monkeypatch.setattr("seclab_taskflow_agent._stream.render_model_output", _fake_render)
122122

0 commit comments

Comments
 (0)