fix(web): return effective enabled state from toolset toggle endpoint - #37649
fix(web): return effective enabled state from toolset toggle endpoint#37649AhmetArif0 wants to merge 1 commit into
Conversation
PUT /api/tools/toolsets/{name} always responded with enabled=body.enabled
even when _save_platform_tools() silently dropped the write because the
toolset is restricted to a different platform (e.g. discord_admin is
restricted to platform='discord', so cli writes are filtered out by
_toolset_allowed_for_platform). The optimistic response caused the desktop
Skills & Tools toggle to flash enabled briefly then revert on the next GET.
After saving, re-read the config and return name in effective so the
response always reflects what was actually persisted.
Fixes NousResearch#37609.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the false-success path; current main still returns body.enabled after _save_platform_tools() at hermes_cli/web_server.py:13446-13447, while that save helper filters platform-restricted toolsets at hermes_cli/tools_config.py:1941-1947.
Problems
- The proposed re-read is outside
with _profile_scope(body.profile or profile)._profile_scoperesets the named-profile Hermes-home override when it exits (hermes_cli/web_server.py:13201-13209), so a request for a named profile can read and return the dashboard profile's state instead.
Suggested changes
- Keep the effective-state
load_config()/_get_platform_tools()read within the existing profile scope, and add a named-profile regression test alongside the restricted-toolset test.
This is an automated hermes-sweeper review.
| enabled.discard(name) | ||
| _save_platform_tools(config, "cli", enabled) | ||
| return {"ok": True, "name": name, "enabled": body.enabled} | ||
| config_after = load_config() |
There was a problem hiding this comment.
This read is after the with _profile_scope(body.profile or profile) block. For a named profile, _profile_scope has already restored the prior Hermes-home override, so this can report the dashboard profile’s effective state rather than the profile just updated. Please perform the read inside the existing scope and add a named-profile regression test.
|
Thanks for catching this one — you were the first to flag the false-success on platform-restricted toolset toggles (#37609). We've now merged PR #65361, which takes the complementary approach: instead of reporting the honest |
Problem
PUT /api/tools/toolsets/{name}always responds withenabled: body.enabledregardless of whether the write was actually applied.
_save_platform_tools()silently drops toolsets restricted to other platforms (e.g.
discord_adminisrestricted to
platform='discord'; the endpoint hardcodesplatform='cli').Result: the desktop Skills & Tools toggle flashes
onand then reverts tooffon the next navigation — with no error surfaced to the user.
Reported in #37609.
Root cause trace
Fix
After saving, re-read the config and return whether the toolset is actually
present in the effective set — so the API response always reflects reality:
_get_platform_toolsis already imported in the same block.Test plan
test_toggle_toolset_platform_restricted_returns_actual_state— togglingdiscord_adminon returnsenabled: false; GET listing confirms it stayed offtest_toggle_toolset_enable_disable— normal (unrestricted) toggles still work and return the correct statetest_toggle_toolset_unknown_returns_400— regression guard