Skip to content

fix(scheduler): task injection format is ambiguous — LLM cancels bash tasks instead of executing them #2073

@bug-ops

Description

@bug-ops

Description

When the scheduler fires a deferred task via the custom_task_tx injection path (agent/mod.rs:2100), the injected user message format is:

[Scheduled task] bash -c 'echo hello > /tmp/output.txt'

This is ambiguous — it reads as a description of what was scheduled, not a clear instruction to execute the task. With gpt-4o-mini, the LLM interprets this as informational and calls cancel_task instead of running the bash command.

Reproduction (CI-30, 2026-03-20)

Config: gpt-4o-mini, tick_interval_secs=5
Command: Schedule a deferred task for 5 seconds to run bash -c 'echo scheduler_ci30_ok > /tmp/ci30-sched-result.txt'

Expected: LLM calls bash with the command → file created
Actual: LLM calls cancel_task("ci30_task") → file not created

Log evidence: INFO scheduler: injecting custom task as agent turn fires correctly (scheduler mechanics OK), but LLM response is:

{"name": "cancel_task", "input": {"name": "ci30_task"}}

Root Cause

agent/mod.rs:2100:

let text = format!("[Scheduled task] {prompt}");

No explicit instruction to execute. The LLM applies its own judgment and cancels the bash task as potentially risky.

Previous Working State

Scheduler was verified working at v0.15.0 with a write task type using Claude Haiku. The write tool is less ambiguous than bash, and Claude Haiku is more likely to interpret the prefix as an execution request.

Proposed Fix

Make the injection format explicit about execution intent:

let text = format!(
    "A scheduled task '{}' has triggered and needs to be executed now. Please run: {}",
    task.name, prompt
);

Severity

MEDIUM — Scheduled bash/shell tasks silently fail (cancelled by LLM) with gpt-4o-mini. Scheduler mechanics all work correctly (creation ✅, tick ✅, injection ✅). Only the LLM response to the injection message is wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingllmzeph-llm crate (Ollama, Claude)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions