Fixes #6048 - Ticket changes from AI-Agents are not triggering the configured triggers.

This commit is contained in:
Dominik Klein 2026-03-26 19:57:27 +01:00
parent a45c2414d2
commit b8ab2ee5dd
2 changed files with 11 additions and 0 deletions

View file

@ -38,6 +38,7 @@ class Service::AI::Agent::Run < Service::Base
ticket.perform_changes(ai_agent_perform_template, 'ai_agent', {
article_id: article&.id
})
TransactionDispatcher.commit
end
rescue => e
Rails.logger.error "AI Agent '#{ai_agent.name}' with ID #{ai_agent.id} perform_changes failed for ticket #{ticket.id}."

View file

@ -74,6 +74,16 @@ RSpec.describe Service::AI::Agent::Run do
.and change { ticket.reload.state.name }.to('open')
end
it 'dispatches triggers after applying changes' do
create(:trigger,
condition: { 'ticket.priority_id' => { 'operator' => 'is', 'value' => Ticket::Priority.lookup(name: '3 high').id.to_s } },
perform: { 'ticket.tags' => { 'operator' => 'add', 'value' => 'ai-trigger-fired' } })
service.execute
expect(ticket.reload.tag_list).to include('ai-trigger-fired')
end
context 'when AI result content does not match result structure' do
let(:ai_result_content) { 'unexpected string content' }