feat(cli): --safe-mode troubleshooting flag (Claude Code v2.1.169-inspired) - #45300
Merged
Conversation
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`
✅ Fixed issues (2):
| Rule | Count |
|---|---|
unresolved-attribute |
2 |
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
run_agent.py:2891: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
Unchanged: 5707 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
teknium1
force-pushed
the
claude-code-inspired/safe-mode
branch
from
June 13, 2026 13:52
401297d to
8393e7a
Compare
Contributor
Author
|
Refreshed against current Important: the safe-mode feature itself already landed on main via #45488. This branch is now just cleanup/reduction on top of that implementation. Cleanup:
Validation:
|
Since safe mode already landed on main via #45488, reduce this branch to cleanup: centralize env setup, remove duplicated comments, and tighten tests.
--safe-mode promised to disable ALL customizations, but shell hooks declared in config.yaml's hooks: block registered anyway — register_from_config() runs independently of plugin discovery and load_config() does not honor HERMES_IGNORE_USER_CONFIG. Gate it on HERMES_SAFE_MODE at the single chokepoint so troubleshooting runs fire zero user-configured code (plugins, MCP, and hooks). Docs (en + zh) updated; positive + negative tests added.
teknium1
force-pushed
the
claude-code-inspired/safe-mode
branch
from
July 7, 2026 09:22
8393e7a to
132b4fe
Compare
3 tasks
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
Refactor + completeness pass on
--safe-mode(feature already on main): centralizes the env-gate wiring in_apply_safe_mode(args), extends safe mode to all agent entrypoints via_prepare_agent_startup, and closes the last customization gap — config-declared shell hooks now also skip registration under safe mode.Changes
hermes_cli/main.py:_apply_safe_mode(args)chokepoint, called fromcmd_chatAND_prepare_agent_startup— so--safe-modenow takes effect on every agent subcommand/oneshot path, not justhermes chatagent/shell_hooks.py:register_from_config()no-ops underHERMES_SAFE_MODE— hooks are user customizations too, and they previously registered regardless (they bypass plugin discovery, andload_config()does not honorHERMES_IGNORE_USER_CONFIG)hermes_cli/plugins.py,tools/mcp_tool.py: drop duplicated prose comments at the gatestests/hermes_cli/test_safe_mode.py: rewritten from logic-mirroring classes to direct behavior tests (real parser → realcmd_chat/_prepare_agent_startup); + shell-hook skip/register paircli-commands.md+environment-variables.md(en + zh)Validation
tests/hermes_cli/test_safe_mode.pytests/agent/test_shell_hooks.pytests/hermes_cli/test_plugins.py+test_startup_plugin_gating.pyHERMES_HOME, real user plugin + MCP server + config hook)Left alone on purpose: oneshot
skip_context_files/skip_memoryplumbing — that's the territory of open contributor PRs #59402 / #51797.Infographic