[BUG] Workflow tool determinism guard false-positives on new Date(/Date.now(/Math.random( substrings inside prompt strings
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The multi-agent Workflow tool rejects a script with
Workflow scripts must be deterministic: Date.now()/Math.random()/new Date() are unavailable (breaks resume). Stamp results after the workflow returns, or pass timestamps via args.
before any agent runs, even when the script's executable code contains no such call — the forbidden substring appears only inside a string literal passed as an agent() prompt. The guard appears to scan the raw script source text for the call-form substrings rather than parsing the AST, so it cannot distinguish a string/template literal (or comment) from an actual call expression.
Also trips on: pasting a code example like const today = () => new Date().toISOString() into a prompt blob, or instructing a subagent to avoid Date.now() — common when orchestrating code-editing/review subagents or enforcing a "no wall-clock" rule.
What Should Happen?
Expected: launches normally (executable code is fully deterministic; new Date( occurs only as string content).
Actual: call fails immediately with the determinism error; no agent is spawned.
Error Messages/Logs
Steps to Reproduce
export const meta = { name: 'repro', description: 'determinism false-positive', phases: [{ title: 'X' }] }
phase('X')
// No clock/random is CALLED anywhere below. The token is inert prompt text.
const r = await agent("When editing src/, do not call new Date() — pass timestamps in via args.", { label: 'x' })
return { r }
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.157 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
Impact: any Workflow whose agent prompts legitimately mention these APIs is blocked, forcing awkward rephrasing of prompt text. Hits multi-agent code-review/refactor workflows in particular.
Suggested fix: parse to AST (or strip string/template literals + comments before scanning) and flag only real CallExpression/NewExpression for Date.now/Math.random/new Date. Bare Date, toISOString, etc. should remain fine.
Workaround: rephrase so the literal call form never appears in the script — e.g. "no system-clock / current-time call" instead of "no new Date()".
Tool: Workflow (multi-agent orchestration). Model: Opus 4.8.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗