mirror of
https://github.com/ranxianglei/billion-context.git
synced 2026-11-23 10:28:04 +08:00
The hermes native plugin stamped model/max-output but never the context window, so custom-alias models (absent from every registry) sized sessions at the 200K default even when the host knew the real window. Now the plugin reads HERMES_HOME/context_length_cache.yaml (the host's own per-model window cache, keyed <model>@<base_url>) best-effort and reports it on both #955/#956 channels: x-bili-plugin-context-window header in the llm_request middleware and contextWindow in the runtime-info body (dedup key extended so a changed window re-reports). Base URL resolution: hook/request-supplied fields first, then the provider entry in config.yaml; matching is exact-URL then origin-granularity (cache keeps /v1, configs often omit it); conflicting per-upstream windows are never guessed (fail-open to the proxy's normal chain, like every other miss). Adjacent fix in the same call path: on_pre_api_request read 'table' unconditionally while binding it only inside the max_tokens-present branch — a hook fire without max_tokens raised NameError into the swallowing except and silently skipped the whole runtime-info report. Hoisted the binding.