claude-code - 💡(How to fix) Fix [BUG] Workflow tool determinism guard false-positives on new Date(/Date.now(/Math.random( substrings inside prompt strings

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Actual: call fails immediately with the determinism error; no agent is spawned.

Error Messages/Logs

Fix Action

Fix / Workaround

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()".

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Workflow tool determinism guard false-positives on new Date(/Date.now(/Math.random( substrings inside prompt strings