mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-21 07:55:08 +00:00
The dispatcher's circuit breaker only protected against spawn-side
failures (profile missing, workspace mount error, exec failure).
Workers that successfully spawned but then timed out or crashed
re-queued to ``ready`` with no counter increment, so the next tick
re-spawned them — loops forever until someone noticed. Reported
externally on Twitter (Forbidden Seeds) and confirmed by walking the
kernel: ``enforce_max_runtime`` flipped the task back to ready, emitted
a ``timed_out`` event, and never touched ``spawn_failures``; same for
``detect_crashed_workers``.
Fix: unify the counter across all non-success outcomes.
Schema
------
* ``tasks.spawn_failures`` → ``tasks.consecutive_failures``
* ``tasks.last_spawn_error`` → ``tasks.last_failure_error``
* Migration renames the columns in-place on existing DBs (``ALTER
TABLE RENAME COLUMN`` — SQLite >= 3.25) so historical counter
values are preserved. Row mappers fall through to the legacy names
if both column renames and a migration somehow got out of sync.
Counter lifecycle
-----------------
New helper ``_record_task_failure(conn, task_id, error, *, outcome,
release_claim, end_run, event_payload_extra)`` is the single point
every non-success outcome funnels through:
* ``spawn_failed`` → ``_record_spawn_failure`` (kept as alias)
calls it with ``release_claim=True, end_run=True`` — transitions
running→ready, clears claim, closes run.
* ``timed_out`` → ``enforce_max_runtime`` already does the status
transition + run close + event emission, then calls
``_record_task_failure`` with ``release_claim=False, end_run=False``
just to bump the counter (and trip the breaker if needed).
* ``crashed`` → ``detect_crashed_workers`` same pattern, but the
counter increment runs after the main write_txn closes (SQLite
doesn't nest write transactions).
If the counter hits the breaker threshold (``DEFAULT_FAILURE_LIMIT=5``,
same as before), the task transitions to ``blocked`` with a ``gave_up``
event on top of whatever outcome-specific event was already emitted.
Reset semantics changed: the counter now clears only on successful
``complete_task`` (and operator ``reclaim_task`` — an explicit "I've
looked at this, try again with a fresh budget"). Previously
``_clear_spawn_failures`` ran on every successful spawn, which would
have wiped the counter before a timeout could accumulate past threshold
— exactly the loop this fix prevents.
Diagnostics
-----------
* ``_rule_repeated_spawn_failures`` → ``_rule_repeated_failures``. Now
fires regardless of which outcome is at fault. Classifies the most
recent failure (spawn_failed / timed_out / crashed) from the run
history so the title ("Agent timeout x3", "Agent crash x4", "Agent
spawn x5") and suggested action (``doctor`` for spawn, ``log`` for
timeout/crash) stay outcome-specific without N duplicate rules.
* ``_rule_repeated_crashes`` kept as a narrower early-warning at
threshold 2 (vs 3 for the unified rule), but now suppresses itself
when the unified rule would also fire — avoids double-flagging.
* Diagnostic ``data`` payload now carries
``{consecutive_failures, most_recent_outcome, last_error}`` instead
of spawn-specific keys.
CLI
---
* ``Task.consecutive_failures`` / ``Task.last_failure_error`` are the
public fields now. Existing callers that referenced the old names
get migrated (tests updated in this commit).
* Backward-compat: ``DEFAULT_SPAWN_FAILURE_LIMIT``,
``_clear_spawn_failures``, ``_record_spawn_failure`` stay as aliases.
Tests
-----
* 6 new kernel tests: timeout increments counter, 3 consecutive
timeouts trip the breaker (was the reported gap), crash increments
counter, reclaim clears counter, completion clears counter, spawn
success does NOT clear counter.
* Diagnostic tests: updated ``repeated_spawn_failures`` cases to use
the new kind name and add a timeout-loop test.
* Dashboard API test: spawn_failures column update → consecutive_failures.
389/389 kanban-suite tests pass.
Live verification
-----------------
Seeded 4 tasks in an isolated HERMES_HOME: 3 timeouts, 4 crashes,
2-spawn-failed + 2-timed-out, and a task that had prior failures but
completed successfully. Board correctly shows "!! 3 tasks need
attention" (the successful one has no badge because the counter
reset). Drawer for the timeout-loop task renders "Agent timeout x3"
with most_recent_outcome=timed_out and the "Check logs" suggested
action (not the spawn-flavoured "Verify profile"). The successful
task has zero diagnostics.
Closes the Forbidden-Seeds-reported gap.
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| conftest.py | ||
| test_ai_gateway_models.py | ||
| test_anthropic_model_flow_stale_oauth.py | ||
| test_anthropic_oauth_flow.py | ||
| test_anthropic_provider_persistence.py | ||
| test_api_key_providers.py | ||
| test_apply_model_switch_result_context.py | ||
| test_arcee_provider.py | ||
| test_argparse_flag_propagation.py | ||
| test_at_context_completion_filter.py | ||
| test_atomic_json_write.py | ||
| test_atomic_yaml_write.py | ||
| test_auth_codex_provider.py | ||
| test_auth_commands.py | ||
| test_auth_nous_provider.py | ||
| test_auth_provider_gate.py | ||
| test_auth_qwen_provider.py | ||
| test_auth_ssl_macos.py | ||
| test_aux_config.py | ||
| test_azure_detect.py | ||
| test_backup.py | ||
| test_banner.py | ||
| test_banner_git_state.py | ||
| test_banner_skills.py | ||
| test_bedrock_model_picker.py | ||
| test_chat_skills_flag.py | ||
| test_claw.py | ||
| test_clear_stale_base_url.py | ||
| test_cmd_update.py | ||
| test_coalesce_session_args.py | ||
| test_codex_cli_model_picker.py | ||
| test_codex_models.py | ||
| test_commands.py | ||
| test_completion.py | ||
| test_config.py | ||
| test_config_drift.py | ||
| test_config_env_expansion.py | ||
| test_config_env_refs.py | ||
| test_config_validation.py | ||
| test_container_aware_cli.py | ||
| test_copilot_auth.py | ||
| test_copilot_catalog_oauth_fallback.py | ||
| test_copilot_context.py | ||
| test_copilot_in_model_list.py | ||
| test_copilot_token_exchange.py | ||
| test_cron.py | ||
| test_curator_archive_prune.py | ||
| test_curator_status.py | ||
| test_custom_provider_context_length.py | ||
| test_custom_provider_model_switch.py | ||
| test_dashboard_browser_safe_imports.py | ||
| test_dashboard_lifecycle_flags.py | ||
| test_dashboard_profiles_nav_label.py | ||
| test_debug.py | ||
| test_deprecated_cwd_warning.py | ||
| test_detect_api_mode_for_url.py | ||
| test_determine_api_mode_hostname.py | ||
| test_dingtalk_auth.py | ||
| test_discord_skill_clamp_warning.py | ||
| test_doctor.py | ||
| test_doctor_command_install.py | ||
| test_env_loader.py | ||
| test_env_sanitize_on_load.py | ||
| test_fallback_cmd.py | ||
| test_gateway.py | ||
| test_gateway_linger.py | ||
| test_gateway_runtime_health.py | ||
| test_gateway_service.py | ||
| test_gateway_wsl.py | ||
| test_gemini_free_tier_setup_block.py | ||
| test_gemini_provider.py | ||
| test_gmi_provider.py | ||
| test_goals.py | ||
| test_hooks_cli.py | ||
| test_ignore_user_config_flags.py | ||
| test_image_gen_picker.py | ||
| test_kanban_boards.py | ||
| test_kanban_cli.py | ||
| test_kanban_core_functionality.py | ||
| test_kanban_db.py | ||
| test_kanban_diagnostics.py | ||
| test_launcher.py | ||
| test_list_picker_providers.py | ||
| test_logs.py | ||
| test_managed_installs.py | ||
| test_mcp_config.py | ||
| test_mcp_reload_confirm_gate.py | ||
| test_mcp_tools_config.py | ||
| test_memory_reset.py | ||
| test_model_catalog.py | ||
| test_model_normalize.py | ||
| test_model_picker_viewport.py | ||
| test_model_provider_persistence.py | ||
| test_model_switch_context_display.py | ||
| test_model_switch_copilot_api_mode.py | ||
| test_model_switch_custom_providers.py | ||
| test_model_switch_opencode_anthropic.py | ||
| test_model_switch_variant_tags.py | ||
| test_model_validation.py | ||
| test_models.py | ||
| test_models_dev_preferred_merge.py | ||
| test_non_ascii_credential.py | ||
| test_nous_hermes_non_agentic.py | ||
| test_nous_subscription.py | ||
| test_ollama_cloud_auth.py | ||
| test_ollama_cloud_provider.py | ||
| test_openai_codex_model_validation_fallback.py | ||
| test_opencode_go_in_model_list.py | ||
| test_opencode_go_validation_fallback.py | ||
| test_overlay_slug_resolution.py | ||
| test_path_completion.py | ||
| test_pin_kanban_board_env.py | ||
| test_placeholder_usage.py | ||
| test_plugin_cli_registration.py | ||
| test_plugin_scanner_recursion.py | ||
| test_plugins.py | ||
| test_plugins_cmd.py | ||
| test_profile_export_credentials.py | ||
| test_profiles.py | ||
| test_prompt_api_key.py | ||
| test_provider_config_validation.py | ||
| test_pty_bridge.py | ||
| test_reasoning_effort_menu.py | ||
| test_redact_config_bridge.py | ||
| test_regression_16767.py | ||
| test_relaunch.py | ||
| test_resolve_last_session.py | ||
| test_runtime_provider_resolution.py | ||
| test_session_browse.py | ||
| test_sessions_delete.py | ||
| test_set_config_value.py | ||
| test_setup.py | ||
| test_setup_agent_settings.py | ||
| test_setup_hermes_script.py | ||
| test_setup_irc.py | ||
| test_setup_matrix_e2ee.py | ||
| test_setup_model_provider.py | ||
| test_setup_noninteractive.py | ||
| test_setup_ollama_cloud_force_refresh.py | ||
| test_setup_openclaw_migration.py | ||
| test_setup_prompt_menus.py | ||
| test_setup_reconfigure.py | ||
| test_skills_config.py | ||
| test_skills_hub.py | ||
| test_skills_install_flags.py | ||
| test_skills_skip_confirm.py | ||
| test_skills_subparser.py | ||
| test_skin_engine.py | ||
| test_spotify_auth.py | ||
| test_status.py | ||
| test_status_model_provider.py | ||
| test_subparser_routing_fallback.py | ||
| test_subprocess_timeouts.py | ||
| test_suppress_eio_on_interrupt.py | ||
| test_tencent_tokenhub_provider.py | ||
| test_terminal_menu_fallbacks.py | ||
| test_timeouts.py | ||
| test_tips.py | ||
| test_tool_token_estimation.py | ||
| test_tools_config.py | ||
| test_tools_disable_enable.py | ||
| test_tui_npm_install.py | ||
| test_tui_resume_flow.py | ||
| test_update_autostash.py | ||
| test_update_check.py | ||
| test_update_config_clears_custom_fields.py | ||
| test_update_gateway_restart.py | ||
| test_update_hangup_protection.py | ||
| test_update_stale_dashboard.py | ||
| test_update_yes_flag.py | ||
| test_user_providers_model_switch.py | ||
| test_voice_wrapper.py | ||
| test_web_server.py | ||
| test_web_server_host_header.py | ||
| test_web_ui_build.py | ||
| test_webhook_cli.py | ||
| test_xiaomi_provider.py | ||