// The whole agent is one module: the model, the router, a protected action, and the policy guarding it.
defmodule MyApp.SupportAgent do
use Spectre.Agent
model(MyApp.LLM, purpose: :smart)
router(via: [:regex, :embedding, :llm_classifier])
actions MyApp.SupportActions do
protect(:delete_account, with: :delete_account_confirmation)
end
policy :delete_account_confirmation do
request(:confirm_delete_account)
accept(:confirmed_delete, regex: ~r/^yes, delete it$/i)
reject(:cancel_delete, regex: ~r/^(no|cancel)$/i)
attempts(3, then: :cancel_pending)
end
interrupt :HELP, regex: ~r/^(help|menu)$/i do
reply(:help)
end
end