anthropics / anthropics/claude-code
Manually re-triggering a scheduled task replays a stale/cached result instead of a fresh run
- Dominant language
- Python
- Stars
- 145k
- Forks
- 23.1k
- PR merge metrics
- PR metrics pending
Description
## Description
Manually re-triggering a scheduled task (`.claude/scheduled-tasks//SKILL.md`) from the Routines UI repeatedly produces near-identical output to the previous run — including a stale date label and specific numbers/phrasing — rather than a fresh agent execution. Editing the task's own instructions to explicitly guard against this had no effect on the next manual run.
## Setup
- A cron-scheduled task (`cronExpression: "0 9 * * 1-5"`, with `jitterSeconds: 558`) posts a small analytics report to a Google Chat webhook once per weekday morning.
- The task's SKILL.md instructs the agent to: call two specific data-fetching MCP tools before composing the report, derive "today" from the session's own live date context, and only then write a payload file and run one approved `curl` command.
## What happened
On 2026-09-09 (a Wednesday), the automatic 09:09 Madrid trigger produced a report labeled with the *wrong day* — "Tuesday (yesterday vs Sunday)", a full day behind the actual current date — and posted it to the destination webhook.
To investigate, I manually re-triggered the same task from the Routines UI a couple of times to see if a fresh run would pick up the correct (Wednesday) date. Each manual re-trigger:
- Skipped straight from reading the task prompt to calling `Bash` (the final `curl` POST) in essentially one step — no visible calls to the two required data-fetching tools beforehand, contrary to the instructions.
- Posted a report with the same wrong day label and with numbers/phrasing nearly identical to the original run (e.g. the same "~11% → ~6%" and "-5.1pp WoW" language recurring verbatim across separately-triggered sessions).
After noticing this, we added an explicit guard to the top of the SKILL.md requiring the agent to (a) re-derive today's date from the live session context every run, never from a missed/prior trigger, and (b) verify it had actually called the required data-fetching tools *this run* before posting, and to skip posting if a duplicate had already gone out. I then manually re-triggered the task again.
That run **still** exhibited the same pattern: the injected prompt confirmed the new guard text was present, but the transcript again showed only `(called Bash)` with no data-fetching tool calls, and the posted summary text was virtually identical (same specific percentages and phrasing) to the earlier posts.
This suggests something below the prompt/instruction layer for this task — each manual re-trigger appears to replay/return a cached result rather than executing a genuinely fresh agent turn, since a fresh completion should not reproduce identical wording nor ignore newly-added top-of-prompt instructions.
## Impact
- Repeated manual re-triggers of a scheduled task do not produce independent fresh runs, making it impossible to recover from a bad automatic run by simply re-running it.
- Reports are silently wrong (mislabeled date, stale/reused figures) with no indication that fresh data wasn't actually fetched.
- Editing the task's own instructions had no effect, since the bug appears to be in the triggering/execution layer, not something addressable from the skill content.
## What we'd expect
- Manually re-triggering a scheduled task from the Routines UI should start an independent, fresh agent execution that actually executes the tool calls described in its own instructions, not replay a prior run's result.
Happy to provide more detail (session transcripts, exact task config) if useful — let me know what's most helpful to attach.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing with a cron-scheduled task under .claude/scheduled-tasks//SKILL.md and manual re-triggering it from the Routines UI. Trace the scheduled-task trigger/execution path and any caching or replay behavior around prior runs. Done means a manual re-trigger starts a fresh agent execution, calls the required tools for that run, and no longer reuses the stale date or report text.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100