hermes-agent/website/docs/developer-guide
spfcraze 8f91e249e4 perf(state): add messages(session_id, id) index for window/ordering queries
Every ORDER BY id query on the messages table sorted or scanned the
whole session: get_messages_around's window seek, latest_message_row_id
(LIMIT 1), and get_messages' full-load ordering all paid O(session
history) per call — hot mid-turn via session_search and reactions.
messages.id is an original column (INTEGER PRIMARY KEY AUTOINCREMENT),
so the index lives in SCHEMA_SQL next to idx_messages_session — no
legacy-column migration hazard (the kanban lesson from #28776 does not
apply).

Measured (real schema, one 20k-message session, median of 30):
get_messages_around 7.08 -> 0.22 ms (32x), latest_message_row_id
3.37 -> 0.011 ms (307x), get_messages full load 111.6 -> 98.6 ms
(1.13x — remaining cost is row deserialization, not the sort).
Window results byte-identical at probe points across the session.

Tests: VM-step pin (get_messages_around bounded work, calibrated
~12 vs ~855 handler calls, threshold 300 — fails without the index)
and window parity with/without the index. No EXPLAIN/plan text
(behavior contracts, AGENTS.md).
2026-08-02 21:16:17 +05:30
..
plugins docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
_category_.json
acp-internals.md
adding-platform-adapters.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
adding-providers.md docs: purge stale xdist/_enforce_test_timeout test-runner references repo-wide 2026-07-29 23:16:18 -07:00
adding-tools.md
agent-loop.md
architecture.md Revert "remove Vercel AI Gateway and Vercel Sandbox (#33067)" 2026-07-29 19:48:37 -07:00
browser-provider-plugin.md
browser-supervisor.md
context-compression-and-caching.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
context-engine-plugin.md
contributing.md feat(runtime)!: require Node 26 across all installers, heal, and upgrade paths 2026-08-01 21:17:51 -04:00
creating-skills.md
cron-internals.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
desktop-plugin-sdk.md
egress-internals.md
extending-the-cli.md
gateway-internals.md docs: sync overnight sweep with registry, gateway, curator, cron 2026-07-29 09:45:11 -07:00
image-gen-provider-plugin.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
memory-provider-plugin.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
model-provider-plugin.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
plugin-llm-access.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
programmatic-integration.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
prompt-assembly.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
provider-runtime.md Revert "remove Vercel AI Gateway and Vercel Sandbox (#33067)" 2026-07-29 19:48:37 -07:00
secret-source-plugin.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
session-storage.md perf(state): add messages(session_id, id) index for window/ordering queries 2026-08-02 21:16:17 +05:30
subagent-lifecycle-api.md
tools-runtime.md Revert "remove Vercel AI Gateway and Vercel Sandbox (#33067)" 2026-07-29 19:48:37 -07:00
trajectory-format.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
video-gen-provider-plugin.md docs: accuracy sweep + coverage for 2 months of shipped features 2026-07-29 08:48:05 -07:00
web-search-provider-plugin.md
worktree-ui-dev.md