Skip to content

hermes prompt-size over-counts tools by not respecting enabled/disabled toolsets #41445

Closed

Description

@busigui2023

Bug Description

hermes prompt-size --platform <platform> reports a tool count that is higher than the actual number of tools available in a real session for that platform.

Steps to Reproduce

  1. Configure toolsets via hermes tools for the feishu platform (e.g. disable some toolsets like web, tts, delegation)
  2. Run hermes prompt-size --platform feishu
  3. Compare the reported tool count with the actual tools visible in a feishu session

Expected Behavior

The tool count and tool-schema byte size should match what is actually sent to the model in a real gateway session for that platform.

Actual Behavior

prompt-size reports 37 tools (52.1 KB tool schemas), but the actual feishu session only has 31 tools — a discrepancy of 6 tools.

Root Cause

In hermes_cli/prompt_size.py, _build_inspection_agent() constructs an offline AIAgent with only platform=platform but does not pass enabled_toolsets or disabled_toolsets:

return AIAgent(
    model=model,
    api_key="inspect-only",
    base_url="https://openrouter.ai/api/v1",
    quiet_mode=True,
    save_trajectories=False,
    platform=platform,
    # Missing: enabled_toolsets / disabled_toolsets
)

In contrast, the actual gateway resolves toolsets via _get_platform_tools(user_config, platform_key) and passes both enabled_toolsets and disabled_toolsets to AIAgent.__init__().

Suggested Fix

_build_inspection_agent() should call _get_platform_tools() (and read disabled_toolsets from config) the same way the gateway does, so the diagnostic reflects the real tool surface.

Environment

  • hermes-agent version: 0.16.0
  • Platform: feishu
  • OS: Linux

Activity

  1. added
    type/bugSomething isn't working
    P3Low — cosmetic, nice to have
    comp/cliCLI entry point, hermes_cli/, setup wizard
    on Jun 7, 2026
  2. liuhao1024 commented on Jun 7, 2026

    @liuhao1024

    This is fixed by #41461 — it passes enabled_toolsets (from _get_platform_tools()) and disabled_toolsets (from agent.disabled_toolsets config) to the inspection agent, so the reported tool count matches what the gateway actually sends.

  3. 529349029 commented on Jun 25, 2026

    @529349029

    Root cause confirmed

    _build_inspection_agent() in hermes_cli/prompt_size.py reads agent.disabled_toolsets from config but does not call _get_platform_tools(cfg, platform) to resolve platform_toolsets filtering.

    This means enabled_toolsets=None is passed to AIAgent, which causes _compute_tool_definitions() (model_tools.py:386-390) to fall through to the "default: start with everything" branch — including ALL tools from ALL toolsets — and only subtract disabled_toolsets afterward.

    In contrast, the interactive CLI (cli_commands_mixin.py:463) and gateway (gateway/run.py) both call _get_platform_tools() first, getting a restricted toolset list that respects platform_toolsets configuration.

    Fix

    Add _get_platform_tools() resolution in _build_inspection_agent():

    from hermes_cli.tools_config import _get_platform_tools
    
    enabled_toolsets = sorted(_get_platform_tools(cfg, platform))
    
    return AIAgent(
        ...,
        enabled_toolsets=enabled_toolsets,
        disabled_toolsets=disabled_toolsets,
    )

    This mirrors the interactive CLI path so the diagnostic reflects the real tool surface.

    Note on "same output" for profiles

    When ~/.hermes/active_profile is set (e.g. to auditor), both hermes prompt-size and hermes -p auditor prompt-size load the same config, so outputs are identical — this is expected behavior, not a bug in profile resolution.

  4. added a commit that references this issue on Jul 6, 2026
    fe8d02c
  5. added a commit that references this issue on Jul 8, 2026
    68b8b85
  6. added a commit that references this issue on Jul 13, 2026
    d04d1b9
  7. added a commit that references this issue on Jul 21, 2026
    f7624d4
  8. added a commit that references this issue on Aug 7, 2026
    77b4a94
  9. added a commit that references this issue on Sep 3, 2026
    2925510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/cliCLI entry point, hermes_cli/, setup wizardtype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions