Invalid_checkpoint after moving posts to a different topic

AI-generated summary

RGJ reports a bug in the AI plugin where moving posts triggers an invalid_checkpoint error during subsequent processing. While the move_posts tool now executes successfully, the system fails with DiscourseAi: context_preparation reason=invalid_checkpoint. The provided backtrace indicates the error originates in lib/completions/history_snapshot.rb during the verify! method, specifically when attempting to retrieve metadata or source relations for the history snapshot.

The issue occurs when the post that triggered the AI agent automation is moved into a newly created topic. RGJ hypothesizes that the calling logic retains a reference to the original topic ID rather than updating to the new destination, causing a mismatch that fails validation. This follows a previous fix regarding optional tool parameters being seen as required.

Following up on Optional tool parameters are seen as required

The move posts tool call now works, but subsequent processing seems fails with DiscourseAi: context_preparation reason=invalid_checkpoint

The relevant backtrace entries are:

lib/completions/context_preparation.rb:21 — Error#initialize
lib/completions/history_snapshot.rb:250 — HistorySnapshot#source_relation
lib/completions/history_snapshot.rb:163 — HistorySnapshot#metadata_for
lib/completions/history_snapshot.rb:36 — HistorySnapshot#verify!
lib/agents/bot.rb:324 — Bot#reply

In both tests, the post that triggered the Triage posts using AI Agent automation was itself moved into a newly created topic.

My guess: But (obviously) the calling logic does not know that, and it still refers to the topic before the move.