hermes - 💡(How to fix) Fix [Bug/Enhancement] Hardcoded max_tokens and overly verbose prompt in vision_tools.py causes severe latency for reasoning models

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Code Example

# In tools/vision_tools.py
_vmax = _vision_cfg.get("max_tokens")
if _vmax is not None:
    vision_max_tokens = int(_vmax)
else:
    vision_max_tokens = 2000

call_kwargs = {
    "task": "vision",
    "messages": messages,
    "temperature": vision_temperature,
    "max_tokens": vision_max_tokens,  # <-- Use config value
    "timeout": vision_timeout,
}
RAW_BUFFERClick to expand / collapse

Describe the bug

In tools/vision_tools.py, when using the legacy auxiliary LLM path for vision analysis, the code forces a hardcoded max_tokens: 2000 and uses an overly explicit prompt ("Fully describe and explain everything about this image..."). When users configure reasoning models (like Kimi) or highly verbose models as their auxiliary.vision provider, this causes the model to output a massive amount of text, taking several minutes (e.g., 9+ mins for a simple screenshot) to complete the analysis.

To Reproduce

  1. Set auxiliary.vision.model to a reasoning model (like kimi-k2.6) in config.yaml.
  2. Send an image via any platform (e.g., Feishu, CLI).
  3. The gateway triggers vision_analyze and stalls for several minutes while the model generates a 2000-token thesis about the image.

Expected behavior

  1. The max_tokens argument in vision_tools.py should respect the auxiliary.vision.max_tokens value defined in config.yaml instead of being hardcoded to 2000.
  2. The default fallback prompt should ideally be shorter (e.g., "Briefly describe this image..."), or at least configurable via config.yaml.

Proposed Fix

# In tools/vision_tools.py
_vmax = _vision_cfg.get("max_tokens")
if _vmax is not None:
    vision_max_tokens = int(_vmax)
else:
    vision_max_tokens = 2000

call_kwargs = {
    "task": "vision",
    "messages": messages,
    "temperature": vision_temperature,
    "max_tokens": vision_max_tokens,  # <-- Use config value
    "timeout": vision_timeout,
}

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

  1. The max_tokens argument in vision_tools.py should respect the auxiliary.vision.max_tokens value defined in config.yaml instead of being hardcoded to 2000.
  2. The default fallback prompt should ideally be shorter (e.g., "Briefly describe this image..."), or at least configurable via config.yaml.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING