Repository navigation
Description
Summary
The agent pre-check hook (SCHED-COND-001, #454) is scoped per-agent but its message override applies to every cron-triggered schedule on that agent. When the pre-check emits a non-empty stdout for one schedule's logic (e.g. a pipeline heartbeat that needs ticking), that message silently replaces the original message for all other schedules firing on the same agent. The agent's intended scheduled workloads stop running and are replaced with whatever the pre-check chose to inject.
Impact: agents that own both a pipeline heartbeat schedule AND independent scheduled work (dailies, hourlies, etc.) lose all their independent work as soon as the pipeline state crosses any threshold the pre-check responds to. The platform reports these executions as success because the injected work (often a pipeline-tick wait) completes quickly — making the failure invisible in metrics. The actual scheduled work is never executed for as long as the pre-check condition persists.
Component
Scheduler / pre-check hook (POST /api/internal/agents/{name}/pre-check)
Priority
P1 — agents silently lose all scheduled work while the platform reports green; no operator-visible signal except inspection of the message column or execution response. No workaround without rewriting the pre-check script itself.
Reproduction
- Configure an agent with two unrelated schedules — e.g. one heartbeat schedule meant for pipeline-tick, and one independent schedule meant to do some other work (Moltbook Heartbeat, Project Work, daily synthesis, etc.).
- Install an agent pre-check at
~/.trinity/pre-checkthat returns a non-emptymessageunder some condition (e.g. the pre-check scaffolded by the/add-pipelineskill, which emitspipeline-tick: <state-file>: idle for ${AGE}swhen a pipeline'slast_completed_cycle_atis older than 24h). - Let the pipeline state cross that threshold (cycle completes, then sits idle waiting for a long-horizon blocker like
measure_7d_pending). - Wait for both schedules to fire.
- Observe the
messagecolumn inschedule_executionsfor both: both have been overwritten to the pre-check's pipeline-tick message. Bothresponsecolumns show pipeline-tick output, not the schedules' intended work.
Evidence
message field for ten consecutive cron-triggered executions on the same agent (one agent, four distinct schedules — all overwritten with the same pre-check output):
pipeline-columns-heartbeat → "pipeline-tick: <state-file>: idle for 153523s"
Project Work → "pipeline-tick: <state-file>: idle for 153163s"
pipeline-columns-heartbeat → "pipeline-tick: <state-file>: idle for 152623s"
Meme Tracker → "pipeline-tick: <state-file>: idle for 151003s"
pipeline-columns-heartbeat → "pipeline-tick: <state-file>: idle for 149923s"
Moltbook Heartbeat → "pipeline-tick: <state-file>: idle for 149563s"
pipeline-columns-heartbeat → "pipeline-tick: <state-file>: idle for 149023s"
Project Work → "pipeline-tick: <state-file>: idle for 145963s"
...
response for the most recent Moltbook Heartbeat run begins:
**Evaluation: columns / moltbook-eco**
- Status: idle, current_stage: null - cycle 1 already completed
- Blocker present: measure_7d_pending - 7d window eligible at 2026-06-01...
i.e. the agent ran pipeline-tick decision logic, not the Moltbook Heartbeat workload.
Root Cause
The pre-check endpoint (POST /api/internal/agents/{name}/pre-check) is invoked once per cron-triggered execution but receives no schedule identification. The hook has no way to scope its output to the schedule that triggered it. Per the SCHED-COND-001 spec, any non-empty stdout from the hook overrides the message — and because it's invoked for every schedule, that override applies uniformly.
This is a design-level mismatch with how pipelines author their state. The pipeline.yaml format produced by /add-pipeline nests the pre-check declaration inside the heartbeat block:
heartbeat:
schedule_name: "pipeline-columns-heartbeat"
cron: "*/15 * * * *"
skill: pipeline-tick
pre_check: ~/.trinity/pre-checkThe author's intent — that this pre-check applies only to the named heartbeat schedule — is dropped at the platform boundary. The scheduler treats the hook as agent-global.
Suggested Fix
Three options, roughly in increasing order of work:
-
Pass schedule identity to the pre-check. Change the endpoint to
POST /api/internal/agents/{name}/pre-check/{schedule_id}(or passschedule_id/schedule_namein the request body). Set them as env vars (e.g.TRINITY_SCHEDULE_NAME,TRINITY_SCHEDULE_ID) when the script is invoked, so authors can branch on which schedule called them. This unblocks the existing/add-pipelinepre-check pattern with a small edit to the script. -
Honor the pipeline.yaml
heartbeat.pre_checkscoping. When parsing~/.trinity/pipelines/*.yaml, register thepre_checkpath as attached to the specificheartbeat.schedule_nameonly. The scheduler invokes the hook only for that schedule; all other schedules on the agent bypass it. This keeps the hook's contract simple but requires the scheduler to know about pipeline manifests. -
Allow per-schedule pre-check declarations in
agent_schedules. Add apre_check_scriptcolumn (or similar) so each schedule can independently declare a hook. Pre-check is opt-in per schedule. Most general, most invasive.
Option (1) is the smallest fix and the most backwards-compatible. The existing /add-pipeline pre-check would only need an early-return guard like:
if [ -n "$TRINITY_SCHEDULE_NAME" ] && [ "$TRINITY_SCHEDULE_NAME" != "pipeline-columns-heartbeat" ]; then
echo "fire" # don't override message for non-heartbeat schedules
exit 0
fiRelated
- feat(scheduler): agent-owned pre-check hook — let agents veto scheduled invocations deterministically #454 — original feature:
feat(scheduler): agent-owned pre-check hook - The
/add-pipelineskill in.claude/skills/agent-dev/add-pipelineships the pre-check that triggers this bug in practice.
Activity
vybe commentedon May 27, 2026
EDIT — rescoping this issue. On re-reading SCHED-COND-001 with the user, the platform contract is exactly as documented and is not the bug:
~/.trinity/pre-checkThe scheduler is doing what the spec says. The bug is in the
/add-pipelineskill (theagent-dev:add-pipelineskill / its scaffolded~/.trinity/pre-check), which uses the message-override mechanism in a way that only makes sense if the agent has no other schedules.Specifically, the scaffolded script does:
The intent was to pass which state file triggered the fire as context to the pipeline-tick skill. But because the hook is per-agent and Trinity (correctly, per spec) applies the override to whatever schedule called it, this clobbers the messages of unrelated schedules.
Correct skill-side fix — never emit a message override; just emit fire/skip:
The pipeline-columns-heartbeat schedule already has the right
messagefield inagent_schedulesto invoke pipeline-tick. State-file context can be read from~/.trinity/pipeline-state/*.jsoninside the skill rather than pushed via the override.The platform-side enhancement listed as "Suggested Fix" (passing
TRINITY_SCHEDULE_NAMEto the hook) is still a nice-to-have — it would let future per-schedule hook logic exist — but it is not required to fix this regression. The skill-side fix is one line and works under the current platform contract.If the maintainer prefers, this issue can be closed and re-filed against the
/add-pipelineskill's repo. I'm leaving it open here in case there's appetite for the enhancement too. Title edited to reflect the actual cause.[-]bug(scheduler): pre-check hook message override applies to ALL schedules on agent, silently hijacks unrelated schedules[/-][+]bug(skill /add-pipeline): scaffolded pre-check overrides message for every schedule on the agent, hijacks unrelated work[/+]vybe commentedon May 27, 2026
Fixed on the skill side in Abilityai/abilities@9dac92a (
agent-devv1.3.2).The scaffolded
~/.trinity/pre-checkis now v3:That's the whole block. All the state-file scanning was dead weight — it always fired anyway, the only thing it did was choose whether to emit the message override that caused this bug. Work-detection now lives entirely inside
pipeline-tick, which can read~/.trinity/pipeline-state/*.jsonitself.Migration on re-run of
/add-pipelineauto-rewrites both v1 (silenced schedules with empty stdout) and v2 (hijacked them with thepipeline-tick:override) blocks to v3.Closing — the platform contract is fine as spec'd. Leaving the per-schedule pre-check identity enhancement (Suggested Fix option 1) as a separate question for the maintainer to file if there's appetite.
agent-dev: pre-check block v3 — always fire, never override (v1.3.2)
fix(scheduler): the pre-check hook is told which schedule is firing (#…