Report `clai2` sessions to Herdr with a resume command
There is no GitHub issue; David (maintainer) requested this change directly.
Why we make these changes
CLAI2 reported through a source ID reserved for Herdr's own integrations and did not supply a resume command, so Herdr could not reopen its conversation after a server restart. Review-lite also confirmed a stale context percentage from an earlier turn; David asked to include its narrow fix.
New public surface
PluginHost.settings_database: the actual settings database path (Nonefor a detached host), used to avoid reconstructing an incorrect--databaseargument.
User-visible behavior
Before: Herdr receives source herdr:clai2 and a session ID without a resume command.
After: Herdr receives source clai2 and clai2 --session-id ID before the first save or clai2 --resume ID afterward, with the exact non-default settings database path. Unsafe paths send no resume command. Unknown context usage now sends JSON null so Herdr clears the previous percentage. The plugin remains opt-in.
Verification
- Proving Herdr tests: test_session_titles_metadata, test_resume_argv_database, test_context_percentage, test_loader_enable_disable, test_socket_delivery_and_release (30 in file passed).
- 64 plugin-loader tests: passed.
- Pyright on five touched Python files: 0 errors; Ruff check/format: clean.
- Saved and unsaved restoration observed in a throwaway Herdr v0.9.5 named session; test session deleted afterward. Arbitrary settings database filenames are covered by targeted tests.
What changes for existing users
Only opt-in Herdr panes change: they report under a different source, send a resume command, and clear stale context metadata at the next turn. CLI behavior outside Herdr is unchanged.
PR decisions
2026-10-23 · Unsaved conversations resume with --session-id · iter -
- Decision: Report clai2 --session-id ID before the first save and clai2 --resume ID after, rather than skipping resume_argv while unsaved
- Why: Verified in a throwaway herdr 0.9.5 session: a report without resume_argv (or with null) keeps the last accepted command, so after /new a restart reopened the previous conversation; --session-id refuses a saved ID, so one command cannot cover both
- Source: https://raw.githubusercontent.com/herdrdev/herdr/v0.9.5/docs/next/website/src/content/docs/socket-api.mdx
2026-10-23 · pre-push review 1 of 3 at d275c772b1cb54fd7d90ae78ab37e7778f8e0f89 · iter -
- Decision: dispatched (reserved)
- Why: tree e174c942ccaa4772871a69b9885da221397ba8df; full branch 7c5f7a2eeb..d275c772b1; first review
- Source: https://github.com/pydantic/pydantic-ai/tree/clai2-herdr-plugin-fixes
2026-10-23 · pre-push review 1 of 3 at d275c772b1cb54fd7d90ae78ab37e7778f8e0f89 · iter -
- Decision: 1 finding: --database is rebuilt as sessions.db sibling config.db, wrong when the user's --database file is not named config.db; escalated to manager (needs PluginHost settings-path call)
- Why: tree e174c942ccaa4772871a69b9885da221397ba8df; full branch 7c5f7a2eeb..d275c772b1
- Source: https://github.com/pydantic/pydantic-ai/tree/clai2-herdr-plugin-fixes
2026-10-26 · Expose exact settings database to Herdr plugin · iter -
- Decision: David selected read-only PluginHost.settings_database; omit resume_argv when that path is unavailable rather than guessing its basename
- Why: The pre-push review reproduced a mismatch for arbitrary --database filenames; SessionPlugins has the exact ProcessPlugins.store.path to pass through
- Source: https://github.com/pydantic/pydantic-ai/tree/clai2-herdr-plugin-fixes
2026-10-26 · pre-push review 2 of 3 at 0753f0389e96969f9602d4908413d6ba55f63362 · iter -
- Decision: dispatched (reserved)
- Why: tree 0cb479167445d4425d5b4460388bd124a4cde4a2; follow-up d275c772b1..0753f0389; prior issue: arbitrary settings database filename
- Source: https://github.com/pydantic/pydantic-ai/tree/clai2-herdr-plugin-fixes
2026-10-26 · pre-push review 2 of 3 at 0753f0389e96969f9602d4908413d6ba55f63362 · iter -
- Decision: no findings; prior --database filename bug fixed
- Why: tree 0cb479167445d4425d5b4460388bd124a4cde4a2; follow-up d275c772b1..0753f0389
- Source: https://github.com/pydantic/pydantic-ai/tree/clai2-herdr-plugin-fixes
2026-10-26 · Do not reset Herdr source on unsafe paths · iter -
- Decision: David chose to keep the reviewed PR unchanged; no release/reclaim on a purported safe-to-unsafe path transition
- Why: The settings database is fixed per CLAI2 process before the loader starts and built-in conversation IDs are UUIDs; the hypothesized transition is not reachable in normal use
- Source: https://github.com/pydantic/pydantic-ai/pull/11439
2026-10-26 · pre-push review 3 of 3 at cc86b1bd08135f03e263eb21e1b5ae744edffb4f · iter -
- Decision: dispatched (reserved)
- Why: tree 5847d0a65c79f857a21ea9b9df2574d6724c5ad1; follow-up 0753f0389..cc86b1bd0; documentation and test expectation change
- Source: https://github.com/pydantic/pydantic-ai/pull/11439
2026-10-26 · pre-push review 3 of 3 at cc86b1bd08135f03e263eb21e1b5ae744edffb4f · iter -
- Decision: no findings; the two valid douwebot items addressed by docs and table-driven test
- Why: tree 5847d0a65c79f857a21ea9b9df2574d6724c5ad1; follow-up 0753f0389..cc86b1bd0
- Source: https://github.com/pydantic/pydantic-ai/pull/11439
2026-10-27 · Fold stale Herdr context token into PR · iter -
- Decision: David explicitly expanded PR #11439 to fix the pre-existing context metadata patch omission raised by review-lite
- Why: Herdr token maps are patches: omitting context retains its prior percentage; the existing reporter omits the key at TurnStart when context becomes unknown
- Source: https://github.com/pydantic/pydantic-ai/pull/11439#issuecomment-6430036722
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver. (Not applicable.)
- PR title is fit for the release changelog.