nesquena-hermes
880350312a
fix(streaming): fallback to model_metadata for context_length when compressor missing ( #1318 follow-up) ( #1348 )
...
* fix(streaming): fallback to model_metadata for context_length when compressor missing (#1318 follow-up)
PR #1318 (shipped in v0.50.246 via PR #1341 + commit a5c10d5 ) persisted
context_length on the session so the context-ring indicator survives
page reloads. But the writer only fired when agent.context_compressor
was present and reported a non-zero value. Fresh agents, interrupted
streams, or compressors without the attribute would still leave
s.context_length=0 — and the indicator would still show 0% on reload.
This follow-up adds a fallback that calls
agent.model_metadata.get_model_context_length(model, base_url) when the
compressor didn't populate the value. The function returns a sensible
static context window for any known model (with a 256K default for
unknown models). Wrapped in a broad try/except because older
hermes-agent builds may not expose the helper.
Sourced from PR #1344 (@jasonjcwu) — extracted into this focused
follow-up after #1344 was closed as superseded by #1341 .
Adds 6 structural tests covering: import + call presence, falsy-gate,
agent.model/base_url passing, exception swallowing, save() ordering,
result assignment.
Closes the data-flow gap in #1318 for the compressor-missing case.
* test: relax pr1341 block-size assertion to accommodate the new fallback
---------
Co-authored-by: nesquena-hermes <nesquena-hermes@users.noreply.github.com >
2026-04-30 10:27:56 -07:00
..
2026-03-30 20:40:19 -07:00
2026-04-21 02:25:14 +00:00
2026-04-26 21:04:38 -07:00
2026-04-29 21:34:27 -07:00
2026-04-25 23:08:59 -07:00
2026-04-25 21:06:31 -07:00
2026-04-23 12:15:56 -07:00
2026-04-29 19:54:07 -07:00
2026-04-29 21:34:27 -07:00
2026-04-25 15:47:44 -07:00
2026-04-25 15:47:44 -07:00
2026-04-25 17:50:58 -07:00
2026-04-25 17:50:58 -07:00
2026-04-29 04:31:55 +00:00
2026-04-30 17:13:59 +00:00
2026-04-30 16:18:02 +00:00
2026-04-27 11:43:32 -07:00
2026-04-29 04:37:31 +00:00
2026-04-15 19:16:14 +00:00
2026-04-14 19:04:48 +00:00
2026-04-25 17:50:58 -07:00
2026-04-09 18:05:23 -07:00
2026-04-27 13:34:59 -07:00
2026-04-24 01:32:47 +00:00
2026-04-29 19:54:07 -07:00
2026-04-25 23:08:59 -07:00
2026-04-20 20:55:53 -07:00
2026-04-25 14:33:41 -07:00
2026-04-23 09:58:15 -07:00
2026-04-29 19:54:07 -07:00
2026-04-20 23:54:40 +00:00
2026-04-30 15:24:31 +00:00
2026-04-29 04:32:40 +00:00
2026-04-21 22:55:09 -07:00
2026-04-25 21:35:51 -07:00
2026-04-19 05:37:44 +00:00
2026-04-22 20:18:02 +00:00
2026-04-26 21:04:38 -07:00
2026-04-24 09:05:25 -07:00
2026-04-30 15:24:30 +00:00
2026-04-25 15:47:44 -07:00
2026-04-29 17:42:32 -07:00
2026-04-21 17:41:05 -07:00
2026-04-29 04:31:16 +00:00
2026-04-26 21:04:38 -07:00
2026-04-29 16:45:26 +08:00
2026-04-27 16:44:07 -07:00
2026-04-29 17:42:32 -07:00
2026-04-21 23:39:39 -07:00
2026-04-29 19:54:07 -07:00
2026-04-15 23:21:56 +08:00
2026-04-18 06:37:09 +00:00
2026-04-29 04:39:50 +00:00
2026-04-30 16:18:01 +00:00
2026-04-20 21:03:41 -07:00
2026-04-24 11:41:17 -07:00
2026-04-27 22:56:12 -07:00
2026-04-14 21:14:00 +00:00
2026-04-14 21:14:33 +00:00
2026-04-29 04:33:25 +00:00
2026-04-29 04:34:26 +00:00
2026-04-14 21:52:34 +00:00
2026-04-16 00:00:22 +00:00
2026-04-29 04:33:24 +00:00
2026-04-29 04:34:55 +00:00
2026-04-20 19:43:40 +00:00
2026-04-16 20:16:07 -07:00
2026-04-25 15:47:44 -07:00
2026-04-25 14:33:41 -07:00
2026-04-29 15:50:32 +08:00
2026-04-18 06:45:39 +00:00
2026-04-16 18:09:16 -07:00
2026-04-24 09:05:25 -07:00
2026-04-21 15:26:52 -07:00
2026-04-25 13:07:35 -07:00
2026-04-25 14:33:41 -07:00
2026-04-18 06:46:43 +00:00
2026-04-20 23:04:09 +00:00
2026-04-20 19:43:40 +00:00
2026-04-18 17:09:59 +00:00
2026-04-20 22:48:19 +00:00
2026-04-19 23:11:49 -07:00
2026-04-30 16:20:05 +00:00
2026-04-21 00:58:02 +00:00
2026-04-27 16:27:03 -07:00
2026-04-23 09:05:57 -07:00
2026-04-22 16:27:01 +00:00
2026-04-21 23:08:24 -07:00
2026-04-22 20:21:42 +00:00
2026-04-23 09:58:15 -07:00
2026-04-29 04:31:14 +00:00
2026-04-29 04:31:14 +00:00
2026-04-29 04:31:13 +00:00
2026-04-23 09:05:57 -07:00
2026-04-23 11:16:59 -07:00
2026-04-23 10:44:10 -07:00
2026-04-26 18:47:38 -07:00
2026-04-25 13:07:35 -07:00
2026-04-26 14:24:20 -07:00
2026-04-29 17:42:32 -07:00
2026-04-30 15:24:32 +00:00
2026-04-26 15:29:02 -07:00
2026-04-26 14:24:20 -07:00
2026-04-26 14:24:20 -07:00
2026-04-26 10:36:59 -07:00
2026-04-26 10:36:59 -07:00
2026-04-26 15:29:02 -07:00
2026-04-26 15:29:02 -07:00
2026-04-26 15:29:02 -07:00
2026-04-29 19:54:07 -07:00
2026-04-27 13:34:59 -07:00
2026-04-29 04:31:36 +00:00
2026-04-27 17:43:36 -07:00
2026-04-27 15:28:19 -07:00
2026-04-27 18:40:13 -07:00
2026-04-27 18:40:13 -07:00
2026-04-27 22:56:12 -07:00
2026-04-29 16:37:08 +08:00
2026-04-30 15:24:35 +00:00
2026-04-30 16:28:20 +00:00
2026-04-27 17:43:36 -07:00
2026-04-20 22:48:19 +00:00
2026-04-26 21:04:38 -07:00
2026-04-23 14:41:06 -07:00
2026-04-27 13:34:59 -07:00
2026-04-14 17:14:01 +00:00
2026-04-19 06:47:24 +00:00
2026-04-29 19:54:07 -07:00
2026-04-29 15:50:32 +08:00
2026-04-30 15:24:36 +00:00
2026-04-29 19:54:07 -07:00
2026-04-30 15:24:35 +00:00
2026-04-29 15:50:32 +08:00
2026-04-29 04:33:29 +00:00
2026-04-29 17:01:01 +08:00
2026-04-22 22:56:21 -07:00
2026-04-22 20:18:02 +00:00
2026-04-26 21:04:38 -07:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-30 16:18:01 +00:00
2026-04-29 17:42:32 -07:00
2026-04-15 16:57:31 +00:00
2026-04-29 04:30:55 +00:00
2026-04-29 17:42:32 -07:00
2026-04-30 10:27:56 -07:00
2026-04-30 16:20:05 +00:00
2026-04-30 10:27:56 -07:00
2026-04-21 19:14:31 -07:00
2026-04-23 02:09:37 +00:00
2026-04-23 02:09:37 +00:00
2026-04-27 21:39:30 -07:00
2026-04-27 22:56:12 -07:00
2026-04-29 17:42:32 -07:00
2026-04-25 23:28:29 -07:00
2026-04-23 02:09:37 +00:00
2026-04-29 15:18:43 +00:00
2026-04-24 10:44:46 -07:00
2026-04-30 16:18:01 +00:00
2026-04-26 21:04:38 -07:00
2026-04-21 16:26:51 +00:00
2026-04-25 19:21:00 -07:00
2026-04-25 21:06:31 -07:00
2026-04-25 21:06:31 -07:00
2026-04-21 15:26:52 -07:00
2026-04-29 17:42:32 -07:00
2026-04-25 21:06:31 -07:00
2026-04-30 16:18:01 +00:00
2026-04-25 17:50:58 -07:00
2026-04-14 19:04:48 +00:00
2026-04-30 16:18:01 +00:00
2026-04-29 17:42:32 -07:00
2026-04-25 13:07:35 -07:00
2026-04-25 13:07:35 -07:00
2026-04-27 13:34:59 -07:00
2026-04-27 13:34:59 -07:00
2026-04-21 22:11:32 -07:00
2026-04-25 17:50:58 -07:00
2026-04-29 04:31:37 +00:00
2026-04-14 19:04:48 +00:00
2026-04-24 09:05:25 -07:00
2026-04-29 21:34:27 -07:00
2026-04-29 17:42:32 -07:00
2026-04-29 17:42:32 -07:00
2026-04-11 20:06:37 -07:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-27 21:39:30 -07:00
2026-04-14 19:04:48 +00:00
2026-04-23 02:35:58 +00:00
2026-04-24 09:05:25 -07:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-30 16:18:01 +00:00
2026-04-29 21:06:30 -07:00
2026-04-18 06:46:43 +00:00
2026-04-23 10:44:10 -07:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-18 06:37:09 +00:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-29 04:31:54 +00:00
2026-04-29 04:31:54 +00:00
2026-04-14 19:04:48 +00:00
2026-04-18 06:37:09 +00:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-29 04:32:52 +00:00
2026-04-29 04:31:12 +00:00
2026-04-22 20:49:28 +00:00
2026-04-11 12:19:12 -07:00
2026-04-24 09:05:25 -07:00
2026-04-12 10:51:48 -07:00
2026-04-29 04:31:55 +00:00
2026-04-27 16:27:03 -07:00
2026-04-18 06:45:39 +00:00
2026-04-16 10:19:10 -07:00
2026-04-22 16:27:01 +00:00
2026-04-12 14:28:16 -07:00
2026-04-23 14:25:43 -07:00
2026-04-29 16:46:32 +08:00
2026-04-13 11:11:56 -07:00
2026-04-13 23:25:26 -07:00
2026-04-14 19:04:48 +00:00
2026-04-19 04:29:07 +00:00
2026-04-19 05:37:44 +00:00
2026-04-24 11:04:16 -07:00
2026-04-29 17:42:32 -07:00
2026-04-19 23:17:00 -07:00
2026-04-20 23:54:40 +00:00
2026-04-29 21:34:27 -07:00
2026-04-24 11:04:32 -07:00
2026-04-21 18:47:40 -07:00
2026-04-30 15:24:33 +00:00
2026-04-29 19:54:07 -07:00
2026-04-27 13:34:59 -07:00
2026-04-29 04:31:36 +00:00
2026-04-23 09:45:34 -07:00
2026-04-09 18:08:29 -07:00
2026-04-16 14:04:42 -07:00
2026-04-21 00:33:03 +00:00
2026-04-29 17:42:32 -07:00
2026-04-29 19:59:26 -07:00
2026-04-25 14:33:41 -07:00
2026-04-10 10:02:28 -07:00
2026-04-12 00:19:33 -07:00
2026-04-20 20:36:53 -07:00
2026-04-13 22:11:45 -07:00
2026-04-24 11:03:42 -07:00
2026-04-27 17:43:36 -07:00
2026-04-27 21:39:30 -07:00
2026-04-27 18:40:13 -07:00
2026-04-27 17:43:36 -07:00
2026-04-26 10:36:59 -07:00