hermes-agent/agent
teknium1 585f8528b2 fix: deep review — prefix matching, tool_calls extraction, query perf, serialization
Issues found and fixed during deep code path review:

1. CRITICAL: Prefix matching returned wrong prices for dated model names
   - 'gpt-4o-mini-2024-07-18' matched gpt-4o ($2.50) instead of gpt-4o-mini ($0.15)
   - Same for o3-mini→o3 (9x), gpt-4.1-mini→gpt-4.1 (5x), gpt-4.1-nano→gpt-4.1 (20x)
   - Fix: use longest-match-wins strategy instead of first-match
   - Removed dangerous key.startswith(bare) reverse matching

2. CRITICAL: Top Tools section was empty for CLI sessions
   - run_agent.py doesn't set tool_name on tool response messages (pre-existing)
   - Insights now also extracts tool names from tool_calls JSON on assistant
     messages, which IS populated for all sessions
   - Uses max() merge strategy to avoid double-counting between sources

3. SELECT * replaced with explicit column list
   - Skips system_prompt and model_config blobs (can be thousands of chars)
   - Reduces memory and I/O for large session counts

4. Sets in overview dict converted to sorted lists
   - models_with_pricing / models_without_pricing were Python sets
   - Sets aren't JSON-serializable — would crash json.dumps()

5. Negative duration guard
   - end > start check prevents negative durations from clock drift

6. Model breakdown sort fallback
   - When all tokens are 0, now sorts by session count instead of arbitrary order

7. Removed unused timedelta import

Added 6 new tests: dated model pricing (4), tool_calls JSON extraction,
JSON serialization safety. Total: 69 tests.
2026-03-06 14:50:57 -08:00
..
__init__.py Refactor Terminal and AIAgent cleanup 2026-02-21 22:31:43 -08:00
auxiliary_client.py fix: handle None message content across codebase (fixes #276) 2026-03-02 02:23:53 -08:00
context_compressor.py feat: smart context length probing with persistent caching + banner display 2026-03-05 16:09:57 -08:00
display.py feat: show detailed tool call args in gateway based on config 2026-03-02 05:23:15 -08:00
insights.py fix: deep review — prefix matching, tool_calls extraction, query perf, serialization 2026-03-06 14:50:57 -08:00
model_metadata.py test: comprehensive tests for model metadata + firecrawl config 2026-03-05 18:22:39 -08:00
prompt_builder.py Merge PR #292: feat(whatsapp): native media attachments for images, videos and documents 2026-03-05 08:35:13 -08:00
prompt_caching.py Refactor Terminal and AIAgent cleanup 2026-02-21 22:31:43 -08:00
redact.py refactor(cli, auth): Add Codex/OpenAI OAuth Support - finalized 2026-02-28 21:56:27 -08:00
skill_commands.py fix: use Path.parts for hidden directory filter in skill listing 2026-03-04 18:34:16 +03:00
trajectory.py Refactor Terminal and AIAgent cleanup 2026-02-21 22:31:43 -08:00