Report `clai2` sessions to Herdr with a resume command

Merged
DS
1mo ago
+176-34

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 (None for a detached host), used to avoid reconstructing an incorrect --database argument.

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

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 -

2026-10-23 · pre-push review 1 of 3 at d275c772b1cb54fd7d90ae78ab37e7778f8e0f89 · iter -

2026-10-23 · pre-push review 1 of 3 at d275c772b1cb54fd7d90ae78ab37e7778f8e0f89 · iter -

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 -

2026-10-26 · pre-push review 2 of 3 at 0753f0389e96969f9602d4908413d6ba55f63362 · iter -

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 -

2026-10-26 · pre-push review 3 of 3 at cc86b1bd08135f03e263eb21e1b5ae744edffb4f · iter -

2026-10-27 · Fold stale Herdr context token into PR · iter -

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.