Skip to content

bug(skill /add-pipeline): scaffolded pre-check overrides message for every schedule on the agent, hijacks unrelated work #955

Closed

Description

@vybe

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

  1. 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.).
  2. Install an agent pre-check at ~/.trinity/pre-check that returns a non-empty message under some condition (e.g. the pre-check scaffolded by the /add-pipeline skill, which emits pipeline-tick: <state-file>: idle for ${AGE}s when a pipeline's last_completed_cycle_at is older than 24h).
  3. Let the pipeline state cross that threshold (cycle completes, then sits idle waiting for a long-horizon blocker like measure_7d_pending).
  4. Wait for both schedules to fire.
  5. Observe the message column in schedule_executions for both: both have been overwritten to the pre-check's pipeline-tick message. Both response columns 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-check

The 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:

  1. Pass schedule identity to the pre-check. Change the endpoint to POST /api/internal/agents/{name}/pre-check/{schedule_id} (or pass schedule_id / schedule_name in 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-pipeline pre-check pattern with a small edit to the script.

  2. Honor the pipeline.yaml heartbeat.pre_check scoping. When parsing ~/.trinity/pipelines/*.yaml, register the pre_check path as attached to the specific heartbeat.schedule_name only. 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.

  3. Allow per-schedule pre-check declarations in agent_schedules. Add a pre_check_script column (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
fi

Related

Activity

  1. vybe commented on May 27, 2026

    @vybe
    ContributorAuthor

    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:

    • One agent-scoped hook at ~/.trinity/pre-check
    • Any non-empty stdout becomes the new message
    • Called before every cron-triggered execution

    The scheduler is doing what the spec says. The bug is in the /add-pipeline skill (the agent-dev:add-pipeline skill / 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:

    if [ -n "$NEEDS_TICK" ]; then
      echo "pipeline-tick: $NEEDS_TICK"    # <-- overreach: rewrites EVERY schedule's message
    else
      echo "fire"
    fi

    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:

    if [ -n "$NEEDS_TICK" ]; then
      echo "fire"            # let the heartbeat schedule's own message invoke pipeline-tick
    else
      echo "skip"            # or echo "" to fail-open
    fi

    The pipeline-columns-heartbeat schedule already has the right message field in agent_schedules to invoke pipeline-tick. State-file context can be read from ~/.trinity/pipeline-state/*.json inside the skill rather than pushed via the override.

    The platform-side enhancement listed as "Suggested Fix" (passing TRINITY_SCHEDULE_NAME to 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-pipeline skill's repo. I'm leaving it open here in case there's appetite for the enhancement too. Title edited to reflect the actual cause.

  2. changed the title [-]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[/+] on May 27, 2026
  3. vybe commented on May 27, 2026

    @vybe
    ContributorAuthor

    Fixed on the skill side in Abilityai/abilities@9dac92a (agent-dev v1.3.2).

    The scaffolded ~/.trinity/pre-check is now v3:

    echo "fire"

    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/*.json itself.

    Migration on re-run of /add-pipeline auto-rewrites both v1 (silenced schedules with empty stdout) and v2 (hijacked them with the pipeline-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.

  4. added a commit that references this issue on Aug 15, 2026
    9dac92a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-p1type-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions