fix(oneshot): honor --ignore-rules / HERMES_IGNORE_RULES on -z path (#26633) - #26669
Closed
briandevans wants to merge 2 commits into
Closed
fix(oneshot): honor --ignore-rules / HERMES_IGNORE_RULES on -z path (#26633)#26669briandevans wants to merge 2 commits into
briandevans wants to merge 2 commits into
Conversation
Contributor
Author
|
CI audit — all 4 test failures are pre-existing baselines unrelated to this PR's touched code (
Same 4 failures show on PR #26622 and PR #26640 in the same window. Happy to re-run CI once these are addressed on main. |
3 tasks
briandevans
force-pushed
the
fix/oneshot-ignore-rules-26633
branch
3 times, most recently
from
May 25, 2026 01:19
38fcf77 to
50d2cb4
Compare
briandevans
force-pushed
the
fix/oneshot-ignore-rules-26633
branch
from
May 27, 2026 20:10
50d2cb4 to
ed7d30d
Compare
`hermes -z --ignore-rules` was a silent no-op: the top-level flag is parsed and the env var is set, but `hermes_cli.oneshot.run_oneshot()` never forwarded `ignore_rules` to `AIAgent`, so `skip_context_files` and `skip_memory` defaulted to False and AGENTS.md / SOUL.md / .cursorrules / persistent memory were still auto-injected. Wire `ignore_rules` end-to-end: - `run_oneshot()` accepts `ignore_rules: bool = False` and also honours `HERMES_IGNORE_RULES=1` (matching the chat path at `cli.py:2709`). - `_run_agent()` propagates the flag as `skip_context_files=` and `skip_memory=` on the `AIAgent(...)` call, the same pair `cli.py` uses for `--ignore-rules` on chat. - `hermes_cli/main.py` forwards `getattr(args, "ignore_rules", False)` on the `--oneshot` / `-z` dispatch. Fixes NousResearch#26633. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…atch Recent main commit 6c3fd97 ("perf(termux): fast-path cli version startup") added a second `run_oneshot(...)` call site in main.py inside `_try_termux_fast_cli_launch()` that bypasses the heavier parser path. The original fix in this PR only updated the second (post-parser) call site at line 13864, leaving the new fast-path site at line 10896 without `ignore_rules=` forwarding. On Termux (and anywhere the fast-path is reached) `hermes -z --ignore-rules` would still be a silent no-op. Mirror the forwarding to the fast-path site so both dispatch paths honour the flag. Also harden the regression test to iterate over every `run_oneshot(` call in main.py rather than just the first occurrence, so a future third dispatch site cannot silently re-introduce the gap.
briandevans
force-pushed
the
fix/oneshot-ignore-rules-26633
branch
from
May 28, 2026 23:11
ed7d30d to
d2dfb30
Compare
Contributor
Author
|
Closing this to keep the contribution queue manageable while it awaits maintainer review. The fix still applies cleanly and I'm happy to reopen if a maintainer wants to pick it up — just give it a nudge and I'll refresh it against main. |
This was referenced Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hermes -z --ignore-rulesis documented to skip auto-injection of AGENTS.md, SOUL.md,.cursorrules, and persistent memory. On thechatpath it does. On the oneshot (-z) path it was a silent no-op — the flag was parsed, the env var was set, buthermes_cli.oneshotnever propagated it toAIAgent.This wires
ignore_rulesend-to-end so-zmatcheschatsemantics for the flag.Fixes #26633.
The bug
The reporter's table (from the issue) shows the chat path correctly drops ~4.2k chars of injected context when
--ignore-rulesis set; the-zpath is unchanged:hermes chat -Q -q "say ok"hermes chat -Q --ignore-rules -q "say ok"hermes -z "say ok"hermes -z --ignore-rules "say ok"Root cause, three sites:
hermes_cli/main.pyparses--ignore-rulesand (at~:1410) setsHERMES_IGNORE_RULES=1. ✅hermes_cli/main.py-zdispatch callsrun_oneshot(args.oneshot, model=…, provider=…, toolsets=…)— never forwardsignore_rules. ❌hermes_cli/oneshot.run_oneshot()doesn't acceptignore_rulesand doesn't readHERMES_IGNORE_RULES._run_agent()buildsAIAgent(...)withoutskip_context_files=/skip_memory=, so both default toFalse. ❌The chat path's reference pattern is
cli.py:2709:then
AIAgent(skip_context_files=self.ignore_rules, skip_memory=self.ignore_rules, …)atcli.py:4477-4478.The fix
Mirror the chat path exactly:
run_oneshot(prompt, …, ignore_rules: bool = False)reads the env-var fallback (HERMES_IGNORE_RULES == "1") and passes the resolved bool into_run_agent()._run_agent()forwards it asskip_context_files=andskip_memory=on theAIAgent(...)call.hermes_cli/main.py-zdispatch now passesignore_rules=getattr(args, "ignore_rules", False).Diff is +16/-1 across two production files, plus a focused regression test file.
Test plan
tests/hermes_cli/test_oneshot_ignore_rules.py— 10 tests covering_run_agentforwards bothskip_context_filesandskip_memorywhenignore_rules=Truerun_oneshot→_run_agentHERMES_IGNORE_RULES=1env var propagates when the param isFalse"1"activates the gate (matches the chat path)Falsehermes_cli/main.pyincludesignore_rules=in itsrun_oneshot(...)calltests/hermes_cli/test_ignore_user_config_flags.py(chat-path coverage) andtests/hermes_cli/test_tui_resume_flow.py(updated to reflect the newrun_oneshotkwarg in the-zdispatch capture) — all 40 tests pass.Related