Skip to content

bug/design: schedule vs agent timeout precedence is silent + SIGKILL error message is ambiguous #929

Closed

Description

@vybe

Summary

The agent execution timeout (agent_ownership.execution_timeout_seconds) and the per-schedule timeout (agent_schedules.timeout_seconds) are both 60–7200s configurable, both default to small values, and the effective ceiling is min(agent, schedule) enforced silently in task_execution_service. There is no surface — in UI, API, or error messages — that tells the operator which cap actually applied. When the smaller cap fires, the agent's Claude Code subprocess gets SIGKILLed and the error message lists three possible causes ("schedule/agent timeout exceeded, OOM kill, or operator cancel") with no indication of which one fired.

This is an ergonomic trap: an operator can configure a schedule with timeout_seconds=7200 (the max), see "7200" in the UI, and have it silently truncated to e.g. 3600 because the agent's execution_timeout_seconds is set lower. Discovery happens only by hitting the wall: a long-running scheduled task gets SIGKILLed at the agent cap with the ambiguous error message, and the operator then has to manually compare the two settings and reason about precedence.

This isn't a single-line bug — asking the team to think through the design and pick an approach. Three sketches in the Suggested Approaches section.

Component

Backend / Scheduling + Task Execution Service (services/task_execution_service.py, db/schedules.py, db/agents.py)

Priority

P2 — there's an operator workaround (set agent cap ≥ schedule cap, or just always set both to 7200), but the silent-truncation + ambiguous-error combo is a real trap anyone scheduling long-running work will hit. Worth a design pass.

Symptoms

  1. A schedule configured with timeout_seconds=7200 actually times out at agent.execution_timeout_seconds if the latter is lower
  2. The UI shows the configured schedule timeout (7200), not the effective timeout
  3. The DB row for the failed execution has error message:
    Execution terminated by SIGKILL after 0 tool calls / 0 turns (exit code -9).
    Likely cause: schedule/agent timeout exceeded, OOM kill, or operator cancel.
    Increase the schedule's timeout_seconds, raise agent memory, or split the
    skill into smaller steps.
    
    — but the operator already raised the schedule's timeout_seconds, and OOM is not the cause, so the message is actively misleading
  4. cleanup_service cycles show auto_terminated: 0 — the kill happens in the task execution path, not the watchdog path — but the operator has no way to know that without reading the source

Reproduction

  1. Create an agent with execution_timeout_seconds=3600 (default-ish)
  2. Create a schedule on it with timeout_seconds=7200
  3. Trigger work that takes >3600s but <7200s
  4. Observe SIGKILL at ~3600s with the ambiguous error message above
  5. Compare DB: schedule says 7200, agent says 3600, configured "120 min" effectively ran 60 min

Root Cause

task_execution_service computes effective_timeout = min(agent.execution_timeout_seconds, schedule.timeout_seconds) and enforces it. This is defensible — agent owners want a hard outer bound — but:

  1. The smaller value wins silently. No validation at config time (PUT /agents/{name}/schedules/{id} accepts a schedule timeout above the agent cap without warning).
  2. No surface exposes the effective timeout. The schedule detail endpoint returns timeout_seconds (configured), not effective_timeout_seconds (configured ∧ agent cap).
  3. The error message is ambiguous. SIGKILL with exit -9 lists three possible causes. The code knows which one fired (it just sent the signal), but doesn't tell the operator.
  4. No fleet audit. No endpoint or admin view to list "schedules where configured timeout > agent cap" — would surface the trap fleet-wide.

Suggested Approaches (pick one + the error-message fix)

A. Validate on write (most prescriptive)

PUT /api/agents/{name}/schedules/{id} returns 400 if body.timeout_seconds > agent.execution_timeout_seconds:

HTTP 400
{
  "error": "schedule_timeout_exceeds_agent_cap",
  "message": "Schedule timeout 7200s exceeds agent execution_timeout_seconds 3600s. Raise the agent cap first via PUT /api/agents/{name}/timeout."
}

Same on PUT /api/agents/{name}/timeout if lowering the cap below any active schedule's timeout.

Pro: problem surfaces at config time, not at execution time, ~3 hours of writing today's bug. Con: prescriptive; might be annoying for legitimate "advisory ceiling" semantics.

B. Effective-timeout endpoint + UI badge

Schedule detail responses include both values:

{
  "timeout_seconds_configured": 7200,
  "timeout_seconds_effective": 3600,
  "capped_by": "agent"
}

Agent detail endpoint includes a count of schedules whose configured timeout exceeds the agent cap. UI shows a small badge next to the truncated schedule timeout (e.g. "60min (capped from 120min)").

Pro: non-breaking; preserves existing semantics; surfaces the truth. Con: doesn't prevent the misconfiguration — only makes it visible.

C. Drop the agent cap; schedules own their timeout

Remove agent_ownership.execution_timeout_seconds as an enforcement field. Schedules set their own timeout (60–7200 range), and the agent cap becomes either advisory metadata or removed entirely.

Pro: simplest mental model. Con: removes a safety net some deployments may rely on; semantic change.

Orthogonal (do regardless of A/B/C): unambiguous SIGKILL error

# task_execution_service.py — wherever it sends SIGKILL
effective_cap = min(agent.execution_timeout_seconds, schedule.timeout_seconds)
cap_source = "agent" if agent.execution_timeout_seconds <= schedule.timeout_seconds else "schedule"
error_msg = (
    f"Execution terminated by SIGKILL after {duration_s}s (exit -9). "
    f"Cause: {cap_source} timeout ({cap_source}_cap={effective_cap}s) was reached. "
    f"To allow longer runs: raise the {cap_source} timeout via "
    f"{'PUT /api/agents/{name}/timeout' if cap_source == 'agent' else 'PUT /api/agents/{name}/schedules/{id}'}."
)

One-line code change at the kill site, eliminates an entire class of "wait, why did this die?" investigations.

Environment

  • Trinity version: 29818dc5 (dev branch, May 24)
  • Affected since: feature has existed since per-agent execution timeouts shipped (TIMEOUT-001)

Related

Activity

  1. added
    status-in-progress
    and removed on May 25, 2026
  2. self-assigned this
    on May 25, 2026
  3. added 2 commits that reference this issue on May 25, 2026
  4. added a commit that references this issue on May 25, 2026
  5. vybe commented on May 25, 2026

    @vybe
    ContributorAuthor

    Merged via #930 (Approach A + SIGKILL message fix). Schedule timeout now enforced as a hard ceiling at write time — 400 at config, not SIGKILL at runtime.

  6. removed
    status-in-progress
    on May 25, 2026
  7. added a commit that references this issue on May 25, 2026
  8. added 2 commits that reference this issue on May 27, 2026
  9. added a commit that references this issue on Jun 4, 2026
  10. added a commit that references this issue on Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority-p2type-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions