Skip to content

fix(agent): preserve global SOUL identity across isolated runs - #28061

Open
nuriygold wants to merge 1 commit into
NousResearch:mainfrom
nuriygold:fix/global-soul-enforcement
Open

fix(agent): preserve global SOUL identity across isolated runs#28061
nuriygold wants to merge 1 commit into
NousResearch:mainfrom
nuriygold:fix/global-soul-enforcement

Conversation

@nuriygold

Copy link
Copy Markdown

Summary

  • default load_soul_identity to on so isolated agent forks still keep the global operator identity
  • explicitly keep SOUL loaded for CLI/TUI/delegate/curator/Feishu/API server pathways while documenting the batch-eval sterile exception
  • update regression tests and docs for --ignore-rules / HERMES_IGNORE_RULES

Test Plan

  • uv run --extra dev --extra messaging pytest -q tests/run_agent/test_run_agent.py::TestBuildSystemPrompt::test_auto_loads_soul_identity_even_when_context_files_are_skipped tests/run_agent/test_run_agent.py::TestBuildSystemPrompt::test_can_disable_soul_identity_for_documented_sterile_runs tests/tools/test_delegate.py::TestDelegateTask::test_child_forces_soul_identity_when_context_files_are_skipped tests/gateway/test_api_server.py::TestAdapterInit::test_create_agent_forwards_config_reasoning_effort tests/tui_gateway/test_make_agent_provider.py::test_make_agent_honors_tui_launch_env_flags tests/hermes_cli/test_ignore_user_config_flags.py::TestIgnoreRulesEnvGate -n 0

@nuriygold nuriygold closed this May 18, 2026
@nuriygold nuriygold reopened this May 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #26596 and #6731 (gateway ignores SOUL.md). Competing fix with #26789 which also addresses SOUL.md loading in gateway sessions. Cron-specific variant already merged in #17509.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists labels May 18, 2026
@nuriygold

Copy link
Copy Markdown
Author

Reviewer note:

  • Root cause: several agent construction paths were running with stripped context / ignore-rules (skip_context_files=True, sometimes with skip_memory=True) but did not force load_soul_identity=True, so the global SOUL.md operator profile was silently bypassed.
  • Fix: default load_soul_identity on across those isolated pathways and thread it through the affected constructors (CLI ignore-rules path, delegate child agents, curator, Feishu comment worker, API server, and TUI startup agent).
  • Exception: documented sterile runs can still opt out explicitly via load_soul_identity=False for eval/batch-style cases where a persona layer would be undesirable.
  • Coverage: targeted tests now cover auto-loading under stripped-context conditions, the explicit sterile opt-out, delegate propagation, API adapter forwarding, TUI launch env handling, and the --ignore-rules / HERMES_IGNORE_RULES path.
  • Why this matters: without this, operator-profile behavior diverges across surfaces — a normal CLI session gets the global persona, but isolated gateway/delegate/ignore-rules paths can lose it. This patch restores consistent global operator identity across runtime entry points while preserving the sterile-run escape hatch.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for chasing this. The underlying bug class is real on current main: agent/system_prompt.py:92 only loads SOUL when load_soul_identity is true or skip_context_files is false, and call sites such as tools/delegate_tool.py:1187, gateway/platforms/feishu_comment.py:1082, and hermes_cli/cli_agent_setup_mixin.py:384 still set skip_context_files=True without forcing SOUL.

Problems

  • Current main added --safe-mode as a fully sterile troubleshooting mode (hermes_cli/main.py:2238-2248). This PR’s global default flip would make that path keep SOUL unless safe-mode explicitly passes load_soul_identity=False.
  • The CLI hunk is stale: current main constructs the CLI agent in hermes_cli/cli_agent_setup_mixin.py:343-385, while this PR patches the old cli.py site. GitHub reports mergeStateStatus=DIRTY.
  • The default flip affects every direct AIAgent(skip_context_files=True) caller, not only the intended runtime surfaces; sterile paths such as batch_runner.py:344 need explicit opt-out, and the current tree should be audited for siblings.

Suggested changes

  • Keep --ignore-rules and --safe-mode separate: preserve SOUL for the former if desired, but force load_soul_identity=False for safe-mode.
  • Apply the CLI wiring in hermes_cli/cli_agent_setup_mixin.py and explicitly annotate each current skip-context caller as identity-preserving or sterile.

Automated hermes-sweeper review.

Comment thread agent/agent_init.py
@@ -125,7 +125,7 @@ def init_agent(
thread_id: str = None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This global default flip also affects sterile troubleshooting/eval paths. On current main, --safe-mode is documented as disabling all customizations while setting HERMES_IGNORE_RULES, so salvage needs either an explicit load_soul_identity=False safe-mode path or narrower opt-in at the intended runtime constructors.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit labels Jul 13, 2026
@tachyon-r

Copy link
Copy Markdown
Contributor

Independent reproduction on current main confirms the delegate-specific bug: _build_child_agent() constructs children with skip_context_files=True and does not pass load_soul_identity=True; prompt assembly then falls back to DEFAULT_AGENT_IDENTITY rather than ~/.hermes/SOUL.md. This can make delegated work operate under a weaker identity/authority/completion contract than its parent.

The child-specific hunk plus regression test directly fixes that defect. Scope suggestion: consider splitting that narrow bug fix from the broader default change to init_agent(load_soul_identity) and the changed --ignore-rules semantics. Those broader changes affect intentionally sterile/evaluation callers and may slow review of the independently valid delegate fix. A focused invariant would be: delegated children skip cwd/project context and memory, but retain the parent installation's global SOUL identity.

@alt-glitch alt-glitch added tool/delegate Subagent delegation platform/feishu Feishu / Lark adapter needs-decision Awaiting maintainer decision before any implementation labels Aug 4, 2026
@tachyon-r

tachyon-r commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

I opened #79052 as a narrow, current-main replacement for the delegate-specific part of this PR. It preserves skip_context_files=True and skip_memory=True, adds only load_soul_identity=True to delegated-child construction, and includes a focused regression test. The commit retains @nuriygold as co-author. This avoids changing safe mode, --ignore-rules, batch/eval callers, or the global constructor default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) needs-decision Awaiting maintainer decision before any implementation P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants