hermes-agent/agent
Teknium 5c2ecdec49
fix: use ceiling division for token estimation, deduplicate inline formula
Switch estimate_tokens_rough(), estimate_messages_tokens_rough(), and
estimate_request_tokens_rough() from floor division (len // 4) to
ceiling division ((len + 3) // 4). Short texts (1-3 chars) previously
estimated as 0 tokens, causing the compressor and pre-flight checks to
systematically undercount when many short tool results are present.

Also replaced the inline duplicate formula in run_conversation()
(total_chars // 4) with a call to the shared
estimate_messages_tokens_rough() function.

Updated 4 tests that hardcoded floor-division expected values.

Related: issue #6217, PR #6629
2026-04-11 16:33:40 -07:00
..
__init__.py
anthropic_adapter.py
auxiliary_client.py
context_compressor.py fix: prevent agent from stopping mid-task — compression floor, budget overhaul, activity tracking 2026-04-11 16:18:57 -07:00
context_engine.py
context_references.py
copilot_acp_client.py
credential_pool.py
display.py
error_classifier.py
insights.py
manual_compression_feedback.py
memory_manager.py
memory_provider.py
model_metadata.py fix: use ceiling division for token estimation, deduplicate inline formula 2026-04-11 16:33:40 -07:00
models_dev.py
prompt_builder.py
prompt_caching.py
rate_limit_tracker.py
redact.py
retry_utils.py
skill_commands.py
skill_utils.py
smart_model_routing.py
subdirectory_hints.py
title_generator.py
trajectory.py
usage_pricing.py