Skip to content

fix(vision): read max_tokens from auxiliary.vision config instead of hardcoded 2000 - #74939

Closed
adikpb wants to merge 1 commit into
NousResearch:mainfrom
adikpb:fix/vision-max-tokens-config
Closed

adikpb wants to merge 1 commit into
NousResearch:mainfrom
adikpb:fix/vision-max-tokens-config

Conversation

@adikpb

@adikpb adikpb commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Problem

vision_analyze and browser_vision both return truncated responses when analyzing complex images. The auxiliary vision model is called with a hardcoded max_tokens: 2000 cap, so descriptions of complex screenshots get cut off mid-sentence at exactly 2000 tokens.

Root cause — two files, same pattern

File Line Before
tools/vision_tools.py 1249 "max_tokens": 2000
tools/browser_tool.py 4328 "max_tokens": 2000

Both correctly read timeout and temperature from auxiliary.vision config, but skip max_tokens entirely — so there is no way to raise it without editing source.

Fix

In both files, add config reading for max_tokens right after the temperature block (which already reads timeout and temp from config), and use the configured value with a fallback to 2000:

_vmt = _vision_cfg.get("max_tokens")
if _vmt is not None:
    vision_max_tokens = int(_vmt)
else:
    vision_max_tokens = 2000

Then replace "max_tokens": 2000"max_tokens": vision_max_tokens.

Users can now configure it in config.yaml:

auxiliary:
  vision:
    max_tokens: 8000

Related issues/PRs

Verification

All 139 vision-related tests pass:

tests/tools/test_vision_tools.py ............. 89 passed
tests/tools/test_vision_native_fast_path.py .. 10 passed
tests/run_agent/test_vision_aware_preprocessing.py ... 12 passed
tests/agent/test_vision_routing_31179.py .... 12 passed
tests/agent/test_vision_resolved_args.py .... 1 passed
Total: 139 passed

@alt-glitch alt-glitch added type/bug Something isn't working tool/vision Vision analysis and image generation tool/browser Browser automation (CDP, Playwright) area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists labels Jul 30, 2026
@adikpb

adikpb commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by updated PR from current main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists tool/browser Browser automation (CDP, Playwright) tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants