Deprecate `on_spend`, `on_usage`, `on_fire`, and `PlanEventEmitter` toward capability event subscriptions
Summary
The ad-hoc constructor callbacks are deprecated toward capability event subscriptions — one typed stream instead of four bespoke callback shapes. Each event is always emitted; each legacy callback keeps working and warns with HarnessDeprecationWarning at construction:
| Deprecated | Replacement event | Kind |
|---|---|---|
SpendLimits.on_spend | SpendRecordedEvent (flat response fields + serializable SpendBudgetStatus entries) | spend.recorded |
ReportContextUsage.on_usage (now optional) | ContextUsageEvent (used_tokens, window_tokens, resolved, fraction) | context_usage.measured |
SystemReminders.on_fire | ReminderFiredEvent (rendered text, committed only once the reminder is actually appended) | system_reminders.fired |
PlanEventEmitter / EventCallback / stores' emitter wiring | PlanCreatedEvent, PlanUpdatedEvent, PlanStatusChangedEvent, PlanCompletedEvent, PlanDeletedEvent, derived from before/after store snapshots on the Planning tool paths | plan.created … |
Plan events are emitted where a RunContext exists (the planning tools); direct store mutations from application code have no run and emit no run events — documented, and the deprecated emitter still covers that path for those who need it.
Docs and READMEs for spend, context usage, system reminders, and planning now show subscriptions as the primary API with a short migration note each.
Requires an unreleased pydantic-ai (pydantic/pydantic-ai#6258); don't merge before a core release carries it.
Linked Issue
Closes #711 (the filesystem and compaction items land via #712 and #713).
Checklist
- Linked issue exists and is referenced above
- Tests added/updated for new behavior
-
make lint && make typecheck && make testpasses locally (against pydantic-aiemit-custom-events) -
pyproject.tomlanduv.lockare unchanged, or a maintainer addeddependencies:approvedto the current head - Docstrings use single backticks (not RST double backticks)
Unblocked. pydantic-ai 2.38.0 carries the event API (#6258), so this no longer needs an unreleased core.
The floor bump itself is #780, which is green. Until it merges this branch carries its commit so CI here can run; once #780 lands, merging main in is a no-op on those two files.
Verified against the released pydantic-ai-slim==2.38.0 from PyPI (not a local checkout): 5,602 passed, 63 skipped, plus ruff lint, ruff format (333 files) and pyright at 0 errors / 0 warnings.