Agent-first startup disables dynamic skill paths, triggering whole-turn profile lock stalls (integration blocker for #7876)

Author: snoybergCreated Sep 28, 2026Updated Oct 1, 2026
Labelsbuginvestigationprioritymaintainer-review

Summary / attribution

Importing the real Agent before WebUI selects a named profile can turn context-local skill modules into the static fallback. The fallback then holds _SKILL_HOME_MODULE_PATCH_LOCK for an entire streaming turn, blocking other turns and model-catalog requests. A turn waiting on the blocking acquire cannot promptly observe cancellation.

The observed deployment regression was triggered by our local managed-runtime startup compatibility change, not a newly introduced upstream change. That change imports run_agent before WebUI API/config imports and is proposed in #7876. Current upstream master c296673ebfaf98750fe38438bc71f0cbb1f75777 does not have that early-import hook. Please treat this as an integration blocker for the startup approach in #7876, and a report of the existing profile/legacy-fallback interaction it exposes.

Environment and onset

  • Linux; real Hermes Agent source fdec926ef54391edcf6caad5f7f6761fdcccdaa2.
  • Server launched with HERMES_HOME at the base home; active_profile selects a named profile.
  • Locally carried startup change enabled Agent-first import on September 25. First retained lock-wait diagnostic: approximately two minutes after deployment. Similar multi-minute catalog stalls occurred September 25 and 27 before becoming especially disruptive September 28.
  • In retained September 18–24 access logs, /api/models/live completed below 2.5 seconds; after the startup change, requests sometimes took several minutes and completed in groups.
  • Exact reason for the later increase in user-visible severity remains unknown. This is not evidence of a new September 28 regression or changed user behavior.

Root mechanism

  1. Early import run_agent imports tools.skills_tool and tools.skill_manager_tool under the launch/base home.
  2. WebUI config initializes the selected profile. api.profiles._set_hermes_home() unconditionally calls patch_skill_home_modules(home).
  3. This changes SKILLS_DIR but not _SKILLS_DIR_AT_IMPORT in already-imported Agent modules.
  4. The Agent's _skills_dir() deliberately treats SKILLS_DIR != _SKILLS_DIR_AT_IMPORT as an explicit override, so it no longer follows the context-local home.
  5. WebUI's _skill_modules_support_profile_home() also rejects that mismatch. _run_agent_streaming() selects the static fallback and acquires _SKILL_HOME_MODULE_PATCH_LOCK until run cleanup.
  6. Cleanup restores the already-mismatched startup snapshot, so subsequent turns remain in fallback.

Relevant upstream code at c296673e:

  • api/profiles.py: _set_hermes_home, patch_skill_home_modules, _skill_modules_support_profile_home, profile_env_for_background_worker.
  • api/streaming.py: _run_agent_streaming, _acquired_streaming_skill_home_patch_lock.
  • Whole-turn static fallback predates this incident (commit 48b40d93, #6379).

Differential reproduction / evidence

Two fresh isolated processes, same real Agent and WebUI modules, disposable base home and selected named profile:

Import order Skill import baseline SKILLS_DIR after profile selection Dynamic capability
run_agent then api.config base-home skills selected-profile skills false
api.config then run_agent selected-profile skills selected-profile skills true

The essential inspection, after executing either ordering in a fresh process, is:

python
from pathlib import Path
import os
import hermes_constants as hc
from api import profiles
import tools.skills_tool as skills
import tools.skill_manager_tool as manager

home = Path(os.environ['HERMES_HOME'])
token = hc.set_hermes_home_override(home)
try:
    print(skills._SKILLS_DIR_AT_IMPORT, skills.SKILLS_DIR)
    print(manager._SKILLS_DIR_AT_IMPORT, manager.SKILLS_DIR)
    print(profiles._skill_modules_support_profile_home(home))
finally:
    hc.reset_hermes_home_override(token)

Prerequisites: use a dependency-ready interpreter, put both source roots on the import path, set HOME, HERMES_HOME, HERMES_BASE_HOME, and WebUI state to disposable locations, create <base>/profiles/alpha/config.yaml containing {}, and <base>/active_profile containing alpha. Do not run these probes against real profile state. The Agent-first ordering is the deliberate trigger, not stock upstream server startup.

The differential was independently repeated. The historical investigation also repeated it with the pre-repair WebUI config/profile sources: newer upstream profile changes were unnecessary. Safety boundaries of the probes: no Agent instantiated or server started; networking blocked; managed bootstrap/recovery and dotenv loading disabled to avoid installs or credentials. Thus this establishes real import-order behavior, not a fresh-install or complete HTTP end-to-end acceptance test.

Separate focused regression tests using real skill modules failed for all three pre-import cases: skills module only, manager module only, and both. They fail specifically with startup disabled dynamic skill resolution.

Observed runtime impact

Sanitized thread-stack summary from the affected live deployment:

  • One _run_agent_streaming worker is inside provider streaming or retry/backoff while retaining the fallback lock.
  • Later _run_agent_streaming worker(s) stop at _SKILL_HOME_MODULE_PATCH_LOCK.acquire() before provider activity.
  • models-catalog-rebuild and /api/models/live request threads stop at the same acquire in profile_env_for_background_worker.
  • Session reads requesting model resolution can consequently wait for the catalog rebuild.
  • Cancelling a parked run leaves it in cancelling; a retry can receive the existing active-stream 409 guard. This cancellation symptom was observed live; an automated cancellation regression is not yet implemented.
  • /health can still report status: ok during the stall.

Expected behavior / repair constraints

  • Dependency activation must not silently disable context-local profile resolution.
  • Dynamic-capable runs should not acquire whole-turn static exclusion solely because startup patched their globals.
  • Any retained legacy wait should be cancellable and settle the run cleanly.
  • Do not simply remove or shorten the lock while tools still read process-global patched paths. Preserve profile and credential isolation.

No fix is claimed here. The bootstrap startup tests in #7876 use shims and did not cover this real-Agent/profile interaction. Related but distinct: #6857 and #6912 address process-environment home mirroring; this report focuses on skill-module baseline poisoning, whole-turn serialization, and cancellation.

— Rocky, AI collaborator for the reporter. Investigation used local Git history, retained service diagnostics, isolated real-module probes, and pytest; no live service restart or state mutation was performed during this investigation.