openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

`scheduler` component enters permanent ERROR state after single cron job timeout — no auto-recovery, container permanently unhealthy

Open paulomac1000 opened this issue 6 months ago • 1 comments

Summary

After ~6.5h of uptime on a headless Docker deployment with custom DeepSeek provider, the scheduler component entered a permanent ERROR state triggered by a single cron job timeout. The component never self-recovered — 924 consecutive health check failures accumulated over 7h43m until a manual restart.

Version: 0.57.11 (Docker, ghcr.io/tinyhumansai/openhuman-core:latest) Setup: Custom DeepSeek provider via Ollama-compatible Flask proxy. 9 dynamically-installed MCP servers (mix of http_remote and stdio bridges). No Composio connections. embedding_provider = "cloud" (default).


Timeline

00:27  Boot: all 9 MCP servers connected, scheduler OK, health 200
   ↓   MCP servers silently drop connections over ~6 hours (no disconnect log lines)
07:00  Cloud API session expires → embedding errors (401 "Invalid token") every 2 min
07:02  Cron orchestrator agent job starts: 0 MCP tools, 0 integrations, only 10 sub-agent delegation tools
07:04  Embedding fails → "no memory context found" → raw DeepSeek query with 15140-char system prompt
07:06  DeepSeek API timeout after 120s → `ERR: cron.agent_job failed: error decoding response body`
       → `WRN: Component 'scheduler' error`
       → Health endpoint: 200 → 503
       → Docker health check: starts failing
14:49  Manual Docker restart → scheduler recovers to OK, MCP reconnected
       → 924 failed health checks (7h43m of continuous unhealthy state)

Root cause chain

  1. MCP connections silently drop (no reconnect mechanism). By hour 6, the agent has 0 MCP tools and 0 integrations. The orchestrator's tool catalog drops from 213 total to 25 visible tools, none of which can do real work.

  2. Cloud embedding provider fails permanently. embedding_provider = "cloud" uses api.tinyhumans.ai which requires a valid session token. After session expiry (~6h into a long-running Docker container), every embedding call returns 401. There is no automatic fallback to local embeddings.

  3. Single cron job timeout permanently bricks the scheduler. A cron agent job times out on the DeepSeek API (120s). The error cron.agent_job failed is logged at ERR level and sets the scheduler component to ERROR state. The component never attempts recovery — it stays in ERROR permanently.

  4. Health check ties container liveness to component status. Docker health check monitors scheduler.status. When scheduler is ERROR, every health probe returns 503, Docker marks the container unhealthy, and the failure count accumulates indefinitely.

Evidence

Cron job that triggered the crash:

07:04:14 orchestrator_tools: assembled 10 delegation tool(s) (0 integrations connected)
07:04:14 tool spec filter: total=213 visible=25
07:04:16 agent: no memory context found — using raw user message
07:04:16 provider:deepseek outbound chat/completions -> api.deepseek.com/v1/chat/completions
[120s timeout]
07:06:16 ERR: cron.agent_job failed: error decoding response body
07:06:16 WRN: Component 'scheduler' error
07:06:20 GET /health -> 503 (was 200 at 07:05:50)

Embedding failures (9 before crash, every 2 min cycle):

07:00:07 embeddings.openai_embed skipped: Embedding API error (401): Invalid token

Post-crash health (924 failures):

924 × GET /health -> 503
Container: unhealthy (FailingStreak: 869 before restart)

Impact

A single transient network timeout on a cron job renders the entire OpenHuman Docker deployment permanently unhealthy until a manual restart. The container continues running (API responds, Flask proxy works) but:

  • Scheduler component never recovers
  • All cron/task/agent jobs stop
  • MCP servers stay disconnected
  • Docker orchestration tools see the deployment as degraded

Requested fixes

  1. Auto-reconnect MCP servers — connections that drop should be re-established automatically, not only at boot-time.
  2. Fallback cloud→local embeddings — when embedding_provider = "cloud" and the session is expired, automatically fall back to local embeddings if preloaded.
  3. Scheduler auto-recovery — a transient cron job failure should not permanently brick the scheduler. Implement exponential backoff + automatic recovery.
  4. More granular health checks — a single degraded component shouldn't make the entire container unhealthy.

Workaround

# Use local embeddings to avoid cloud session dependency
openhuman-core call --method openhuman.embeddings_update_settings \
  --params '{"provider":"local","model":"bge-m3","dimensions":1024}'

# Compensate for missing MCP auto-reconnect via host cron
*/30 * * * * for s in server1 server2 ...; do docker exec openhuman_pablo \
  openhuman-core call --method openhuman.mcp_clients_connect \
  --params '{"server_id":"$s"}'; done

paulomac1000 avatar Jun 03 '26 15:06 paulomac1000

Status / parity check — partially fixed (1 of 4)

The core "permanent brick" symptom is resolved on main. #3329 refactored the scheduler poll loop into a testable tick_once that emits a transition-only HealthChanged { healthy: true } recovery signal on every successful poll. After a job times out and the queue drains, the scheduler now self-clears its error state instead of staying wedged — covered by a regression test (scheduler_tick_once_publishes_health_recovery_signal_on_empty_queue).

What's still open — the other three robustness fixes from the report, none of which has a follow-up PR or tracking issue yet:

  1. MCP auto-reconnect — silent MCP transport drops aren't re-established; a dropped connection stays dropped until restart.
  2. Embedding fallback on 401 — when the cloud session expires mid-run, there's no cloud→local embedding fallback, so indexing fails hard.
  3. Granular per-component health — one degraded component still 503s the whole container; health should be per-component.

#3329's body noted these as "tracked separately," but I couldn't find that tracking — flagging so it isn't lost. Keeping open until 1–3 land.

oxoxDev avatar Jun 05 '26 12:06 oxoxDev