refactor(gateway): use get_custom_provider_context_length() helper + pass custom_providers to @context path - #18844
Conversation
|
Related to #15844 (merged), which introduced the helper this PR now uses in the remaining code paths. |
1 similar comment
|
Related to #15844 (merged), which introduced the helper this PR now uses in the remaining code paths. |
New commit:
|
f0918e8 to
b764842
Compare
Upstream 678a87c (May 3) replaced the entire __init__.py, losing: 1. Ebbinghaus decay + domain-aware half-life (volatile/normal/stable) 2. Contradiction detection (SUPERSEDE/EXTEND/ADD with keyword-first logic) 3. Freshness tags on search results (🔴/⚠️ /⏳ lifecycle states) 4. Self-hosted host detection (_is_self_hosted, added earlier this session) Restored from commit 128b3a820 (Ebbinghaus) + 55ace09b0 (contradiction). Added _enrich_results() for search freshness + contradiction warnings on conclude. 400 lines → 710 lines.
1549dba to
1c7ebc2
Compare
Rebased onto latest
|
| Path | Before | After |
|---|---|---|
Gateway footer context_pct |
Always blank (None) | Shows correct % |
| CLI status bar | Already correct | Unchanged |
/modelinfo command |
Already correct | Unchanged |
/model switch display |
Already correct | Unchanged |
This is the last remaining gap from the custom_providers context-length work (#15844 merged). Ready for merge whenever.
1c7ebc2 to
d4f02d1
Compare
Rebased onto v2026.6.5 (commit c94e93a)Adapted to the
Gateway footer |
…l memory Pattern 1: BM25 + Vector dual-path search (bm25_index.py) - Local BM25 index with CJK bigram tokenization - RRF fusion when both paths return results - Fallback to BM25-only when vector API fails - Persistent cache at ~/.hermes/state/mem0_bm25_cache.json Pattern 3: Supersession chains (supersession.py) - Version memories instead of overwrite - Auto-create chain on SUPERSEDE contradiction - Annotate search results with chain info - Persistent storage at ~/.hermes/state/mem0_s...ions/ Inspired by agentmemory BEAM analysis (rohitg00/agentmemory, 22.6K stars)
d4f02d1 to
97a77d4
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the missing footer metadata field. The underlying footer issue is still present on current main, but the PR needs to be narrowed and moved to the current architecture.
Problems
- The normal result dictionary moved to
agent/turn_finalizer.py:399-428; it still omitscontext_lengthafterlast_prompt_tokensat line 423. The PR edits the former location inagent/conversation_loop.py, so its one-line change does not apply to current main. - The claimed
@contextand hygiene changes are absent from this PR's changed-file list. Current@contextexpansion still omitscustom_providersatcli.py:12177-12181, and gateway hygiene still has its inline lookup atgateway/run.py:11062-11088. - The bundled Mem0 work is unrelated and predates the current
Mem0Backendarchitecture (plugins/memory/mem0/_backend.py:9-36), making it unsuitable for direct salvage.
Suggested changes
- Split the Mem0 commits and move the footer field to
agent/turn_finalizer.py, with a regression test throughgateway/run.py:11706-11713. - Submit the
@contextand hygiene changes as explicit, tested current-main edits if they remain intended.
Automated hermes-sweeper review.
| @@ -4528,6 +4528,7 @@ def _stop_spinner(): | |||
| "completion_tokens": agent.session_completion_tokens, | |||
There was a problem hiding this comment.
This result dictionary was extracted after the PR branch point. On current main the normal return is built in agent/turn_finalizer.py:399-428, so please place this field there and add a regression that verifies the gateway consumer at gateway/run.py:11706-11713 receives it.
Summary
Three targeted fixes for the
custom_providerscontext-length resolution chain:1. Bug fix:
@contextexpansion path ignorescustom_providersThe
@contextreference expansion path callsget_model_context_length()without passingcustom_providers. This skips step 0b (per-modelcontext_lengthfromcustom_providers), so users who configurecustom_providers[].models.<m>.context_lengthwithout a top-levelmodel.context_lengthget wrong injection limits.2. Refactor: replace inline parsing with
get_custom_provider_context_length()helperThe hygiene-run path has a 27-line inline
custom_providersparsing loop. PR #15844 introducedget_custom_provider_context_length()as the single source of truth. This replaces the inline loop with a helper call.3. Bug fix:
run_conversation()result dict missingcontext_lengthfield (NEW)The gateway runtime_footer reads
context_lengthfromagent_result, butrun_conversation()never included this field in its return dict. This caused the footer'scontext_pctdisplay to always be skipped (None).The CLI status bar works fine because
_get_status_bar_snapshot()readscontext_lengthdirectly fromcontext_compressor. But the gateway footer only sees the result dict — soagent_result.get("context_length")was always None.Fix: Add
"context_length"to the result dict returned byrun_conversation(), derived fromcontext_compressor.context_length, matching the same source the CLI uses.New commit:
fix/context-length-result-dictbranch (1 line change in run_agent.py).Related
get_custom_provider_context_length()and fixed the main/modelswitch paths)Test Plan
@contextwith large file: Before → hard limit 64K; After → hard limit 100K/modelinfo: Already correct (usescustom_providers=param from fix(context): honor custom_providers context_length on /model switch + bump probe tier to 256K #15844)/modelswitch: Already correct (usesresolve_display_context_lengthfrom fix(context): honor custom_providers context_length on /model switch + bump probe tier to 256K #15844)