Skip to content

fix(sessions): exclude Hermes operational user rows - #2039

Merged
jeff-r2026 merged 2 commits into
Tencent:mainfrom
XY-code1:fix/hermes-human-prompts
Nov 27, 2026
Merged

jeff-r2026 merged 2 commits into
Tencent:mainfrom
XY-code1:fix/hermes-human-prompts

Conversation

@XY-code1

@XY-code1 XY-code1 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Hermes stores operational records and compressed conversation summaries with role = 'user'. Its session adapter currently treats every such row as human-authored input, so model switches and _compressed_summary rows enter the normalized transcript and can inflate prompt-derived scoring.

Hermes distinguishes these rows in the database:

  • ordinary prompts have an empty display_kind and _compressed_summary = 0
  • operational rows such as model switches have a non-empty display_kind
  • compressed summaries set _compressed_summary = 1

Change

  • read display_kind and _compressed_summary from Hermes' messages table
  • keep a role = 'user' row only when it has no display kind and is not a compressed summary
  • leave assistant messages and tool results unchanged

Verification

  • Regression test fails on main: expected message ids ['20', '23'], received ['20', '21', '22', '23']
  • node node_modules/vitest/vitest.mjs run packages/tool-hermes/src/session-adapter.test.ts --retry 0 — 5 passed
  • npm run typecheck
  • targeted type-aware oxlint on the two modified files
  • git diff --check

npm run verify:world cannot run on this Windows checkout: the verifier reports that a world requires a POSIX shell. This adapter boundary is covered with the existing SQLite-query mock, including one ordinary prompt, one model_switch, one compressed summary, and one assistant reply.

Scope

Hermes session parsing only. No session-store writes, CLI options, or other tool adapters change.

Refs #1989

Real CLI verification (native Windows)

PASS for the built TeamAI CLI at ca6afb9 (Node v24.18.0, SQLite CLI 3.51.1). Used an isolated HOME and local self-mode Git workspace with a synthetic four-row Hermes SQLite database, queried by the real SQLite CLI, without a query mock or model call.

npm run build
node dist/index.js session show 20261104_091523_a1b2c3d4 --source hermes --json
Exit 0. Transcript includes HUMAN_2039 (user) and ASSISTANT_2039 (assistant).
Transcript omits SWITCH_2039 (model_switch) and SUMMARY_2039 (compressed summary).
SQLite row count after the command: 4.

This verifies the built CLI's read/filter path on a real SQLite database, not a live Hermes session or a POSIX verify:world run. The POSIX world check remains outstanding: no usable Linux environment was available on this host.

@XY-code1

Copy link
Copy Markdown
Collaborator Author

Fixed the E2E failures in ca6afb9.

The failing fixtures use an older Hermes messages schema that predates display_kind and _compressed_summary; selecting the new columns made those sessions unreadable. The adapter now falls back to legacy-compatible aliases only when SQLite reports either classification column missing, while current stores still filter operational rows.

Validation:

  • npx vitest run packages/tool-hermes/src/session-adapter.test.ts --retry 0 — 6 passed
  • npm run typecheck — passed
  • npm run build — passed
  • targeted E2E on this Windows checkout — session-show passed; POSIX-only share-learnings suite skipped
  • targeted type-aware oxlint — passed
  • git diff --check — passed

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Missing required real-CLI verification. The PR changes runtime session parsing, but its description records only mocked unit tests and static checks; verify:world did not run. This violates the Code Review Rules requirement that runtime changes include an end-to-end / real-CLI verification record. Run one representative real-CLI scenario in a world on a POSIX-capable environment and record what passed; no full tool × provider matrix is required.

No other confident findings in the specified diff.

@XY-code1

Copy link
Copy Markdown
Collaborator Author

@jeff-r2026 I added a real-CLI verification record to the PR description. On native Windows, the built CLI at ca6afb9 read a synthetic Hermes database through the real SQLite CLI: it kept the human prompt and assistant reply, excluded the model-switch record and compressed summary, and left all four database rows intact.

I did not run the POSIX verify:world harness. Would the Windows real-CLI record be sufficient for this change, or should I follow up with a Linux world run before re-review? Thanks!

@jeff-r2026

Copy link
Copy Markdown
Collaborator

Yes, the Windows record is enough. AGENTS.md asks for one representative real-CLI run, and an isolated run of the built CLI is accepted where verify:world can't run, so a follow-up Linux world run isn't needed. I verified ca6afb95 on Linux (Node 20) stacked on current main with the other PRs merged in this pass: typecheck, build and lint pass, and packages/tool-hermes/src/session-adapter.test.ts passes. Approving and merging.

@jeff-r2026 jeff-r2026 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Node 20), stacked on main da482cb together with the other PRs merged in this pass: typecheck, build, lint, the targeted unit suites and the affected E2E files pass. The only failing CI jobs are the two fork-safe E2E jobs that fail on main itself (fixed in #2114).

@jeff-r2026
jeff-r2026 merged commit e3a1492 into Tencent:main Nov 27, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants