Skip to content

fix: preserve CLI session tool metadata#1778

Closed
Michaelyklam wants to merge 1 commit into
nesquena:masterfrom
Michaelyklam:fix/issue-1772-cli-tool-calls
Closed

fix: preserve CLI session tool metadata#1778
Michaelyklam wants to merge 1 commit into
nesquena:masterfrom
Michaelyklam:fix/issue-1772-cli-tool-calls

Conversation

@Michaelyklam
Copy link
Copy Markdown
Contributor

@Michaelyklam Michaelyklam commented May 7, 2026

Thinking Path

What Changed

  • Extended api.models.get_cli_session_messages() to read and pass through CLI tool metadata:
    • assistant tool_calls
    • tool-result tool_call_id, tool_name, and name
    • reasoning fields where present
  • Kept the loader defensive against older/partial state.db schemas by checking available columns before selecting optional fields.
  • Updated the existing CLI import refresh path so previously imported sessions with stripped metadata are rebuilt even when the refreshed transcript has the same number of rows.
  • Added regression tests with an isolated SQLite state.db fixture covering both fresh loads and same-length metadata refreshes.
  • Added API-level evidence JSON for the tool-call/result shape preserved for rendering.

Fixes #1772

Why It Matters

CLI sessions are often short and tool-heavy. Dropping tool-call metadata makes those transcripts look nearly empty in the WebUI, even though the underlying Hermes state has the full action/result history. This restores parity with WebUI-native tool rendering without changing the frontend rendering model.

Verification

  • python -m pytest tests/test_cli_session_tool_metadata.py -q initially failed before the fix with missing tool_calls / no same-length refresh.
  • /home/michael/.hermes/hermes-agent/venv/bin/python -m pytest tests/test_cli_session_tool_metadata.py tests/test_session_import_cli_fallback_model.py -q10 passed
  • /home/michael/.hermes/hermes-agent/venv/bin/python -m pytest tests/test_cli_session_tool_metadata.py tests/test_session_import_cli_fallback_model.py tests/test_cron_session_title.py -q15 passed
  • git diff --check → passed
  • env -u HERMES_CONFIG_PATH -u HERMES_WEBUI_HOST /home/michael/.hermes/hermes-agent/venv/bin/python -m pytest tests/ -q4689 passed, 4 skipped, 3 xpassed, 1 warning, 8 subtests passed in 378.92s
  • Raw evidence URL check → HTTP 200, 567 bytes
  • GitHub Actions on PR fix: preserve CLI session tool metadata #1778test (3.11), test (3.12), and test (3.13) all passed

Evidence / UI media

API-level evidence for the server payload that the existing WebUI tool-card renderer consumes:

https://raw.githubusercontent.com/Michaelyklam/hermes-webui/fix/issue-1772-cli-tool-calls/docs/pr-media/1772/cli-tool-metadata-api-evidence.json

This is a server/session-loader fix, not a visual layout change, so no before/after screenshot is included.

Risks / Follow-ups

  • The SQL query now probes messages columns before selecting optional metadata, so older state DBs should continue to degrade safely.
  • Existing imports with same-length stripped metadata are refreshed only when the fresh transcript adds CLI tool metadata and otherwise matches after stripping timing/tool metadata.
  • No live service restart was performed.

Model Used

  • Provider: OpenAI Codex
  • Model: gpt-5.5
  • AI-assisted implementation and verification using Hermes CLI tools, pytest, git, and GitHub CLI.

nesquena-hermes added a commit that referenced this pull request May 7, 2026
pull Bot pushed a commit to soitun/hermes-webui that referenced this pull request May 7, 2026
pull Bot pushed a commit to soitun/hermes-webui that referenced this pull request May 7, 2026
…1778, nesquena#1779)

Constituent PRs:
- nesquena#1768 (@franksong2702) serialize Anthropic env fallback reads. Closes nesquena#1736.
- nesquena#1778 (@Michaelyklam) preserve CLI session tool metadata. Closes nesquena#1772.
- nesquena#1779 (@Michaelyklam) reset model picker on session switch. Closes nesquena#1771.
  AUTO-FIX: Opus stage-310 caught a regression in the new !hasSessionModel
  branch — it dropped the deferModelCorrection guard that the parallel
  else-branch keeps. Fired spurious /api/session/update POSTs against
  imported/read-only CLI sessions whose model field reads 'unknown' (the
  exact surface nesquena#1778 introduces in this same release). Wrapped the new
  branch's _persistSessionModelCorrection call + state mutation in
  if(!deferModelCorrection). Added test_sync_topbar_does_not_persist_correction_while_model_resolution_deferred
  regression test covering both empty and 'unknown' fast-path interaction.

Tests: 4694 → 4702 collected (+8). 4695 passed, 4 skipped, 3 xpassed,
0 failed in 141.29s.

Pre-release verification:
- All 3 PRs CI-green individually.
- node -c clean on static/ui.js.
- 11/11 browser API endpoints PASS.
- Pre-stamp re-fetch: all PR heads match local rebases.
- Opus advisor: SHIP nesquena#1768 + nesquena#1778, nesquena#1779 SHOULD-FIX before merge — auto-fix
  applied at stage with regression test, re-verified clean.

Closes nesquena#1736, nesquena#1771, nesquena#1772.
@nesquena-hermes
Copy link
Copy Markdown
Collaborator

Thanks @Michaelyklam — this shipped in v0.51.16 (commit 697a7a1) as part of a 3-PR full-sweep batch. Stage rebased your branch onto current master, ran the full pre-release gate (4695 pytest, browser tests, Opus advisor verdict), and merged via release PR #1781.

GitHub didn't auto-close because the merge commit only references the squash-merged stage branch, not your fork's commit directly — closing manually for hygiene.

Live now on existing installs after git pull + restart.

Release notes: https://github.com/nesquena/hermes-webui/releases/tag/v0.51.16

Du7chManiac pushed a commit to TheCouchCoder-com/hermes-webui that referenced this pull request May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants