Repository navigation
Description
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
- A schedule configured with
timeout_seconds=7200actually times out atagent.execution_timeout_secondsif the latter is lower - The UI shows the configured schedule timeout (7200), not the effective timeout
- The DB row for the failed execution has error message:
— but the operator already raised the schedule's
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.timeout_seconds, and OOM is not the cause, so the message is actively misleading cleanup_servicecycles showauto_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
- Create an agent with
execution_timeout_seconds=3600(default-ish) - Create a schedule on it with
timeout_seconds=7200 - Trigger work that takes >3600s but <7200s
- Observe SIGKILL at ~3600s with the ambiguous error message above
- 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:
- 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). - No surface exposes the effective timeout. The schedule detail endpoint returns
timeout_seconds(configured), noteffective_timeout_seconds(configured ∧ agent cap). - 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.
- 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
src/backend/services/task_execution_service.py— where the kill happens + error message livessrc/backend/db/agents.py—execution_timeout_secondscolumnsrc/backend/db/schedules.py—timeout_secondscolumn + write API- TIMEOUT-001 feature (per-agent execution timeout)
- Loosely related: bug: circuit breaker dormant state silently blocks scheduled tasks for hours with no auto-recovery or notification #921 / fix(#921): watchdog orphan race + CB dormant self-heal + admin reset #924 (recent CB self-heal + admin reset work)
Activity
test(#929): use _STUBBED_MODULE_NAMES + monkeypatch.setitem for sys.m…
review(#929): drop dead accessor, pin SIGKILL message in tests
feat(#929): agent cap enforces schedule ceiling + clearer SIGKILL msg (…
vybe commentedon May 25, 2026
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.
fix(#913): address Eugene's review — guard timeout-cap check on None
docs(user-docs): sync to platform state since 2026-04-23
fix(#913): scheduler honors per-agent execution_timeout_seconds (#922)
feat(#1068): deprecate per-task timeout_seconds override (task-shape …
feat(#1068): deprecate per-task timeout_seconds override (task-shape …
fix(webhooks): gate schedule/webhook creation on a live owning agent (#…
refactor(auth): INV-8 imperative auth-guard family — consolidate inli…
feat(reminders): agent self-reminders — one-shot deferred self-trigger (
fix(canary): stop three false-positive classes drowning the harness (…
fix(ui): stop the Schedules list unmounting on refetch so toggling ne…
feat(workspace): run and watch loops from chat (ent#458, folds ent#338)
feat(workspace): run and watch loops from chat (ent#458, folds ent#338)
feat(ui): one Settings home for the agent — rail, General, Guardrails…