pub trait ConfirmableActionTool: ChatbotToolDeclaration {
type Arguments;
type Facts;
// Required methods
fn parse_arguments(arguments: &str) -> ChatbotResult<Self::Arguments>;
fn call_requirements(
arguments: &Self::Arguments,
user_context: &ChatbotTurnContext,
) -> Vec<ToolRequirement>;
fn execute(
conn: &mut PgConnection,
app_config: &ApplicationConfiguration,
arguments: &Self::Arguments,
authorization: &ToolAuthorization<Self>,
) -> impl Future<Output = ChatbotResult<(ExecutedAction, Self::Facts)>> + Send
where Self: Sized;
fn output_description_instructions(
arguments: &Self::Arguments,
facts: Option<&Self::Facts>,
app_config: &ApplicationConfiguration,
) -> Option<String>;
// Provided method
fn declined_output(_arguments: &Self::Arguments) -> String { ... }
}Expand description
A client tool whose confirmed answer performs a privileged mutation on the server.
Suspends the turn like ClientChatbotTool; the
client answers with ConfirmAnswer. A declined answer produces Self::declined_output
without touching the database. A confirmed answer runs Self::execute inside the same
transaction as the audit insert and the recorded tool output, guarded by
lock_unanswered_for_execution so it can run at most once.
Required Associated Types§
type Arguments
Sourcetype Facts
type Facts
Extra facts Self::execute gathers while performing the mutation, used only to decide
what Self::output_description_instructions should mention for this particular call. ()
for a tool with nothing worth gating on.
Required Methods§
fn parse_arguments(arguments: &str) -> ChatbotResult<Self::Arguments>
Sourcefn call_requirements(
arguments: &Self::Arguments,
user_context: &ChatbotTurnContext,
) -> Vec<ToolRequirement>
fn call_requirements( arguments: &Self::Arguments, user_context: &ChatbotTurnContext, ) -> Vec<ToolRequirement>
What the caller must be allowed to do against what this call actually targets. Checked before the turn suspends on the call and again immediately before the mutation runs.
Sourcefn execute(
conn: &mut PgConnection,
app_config: &ApplicationConfiguration,
arguments: &Self::Arguments,
authorization: &ToolAuthorization<Self>,
) -> impl Future<Output = ChatbotResult<(ExecutedAction, Self::Facts)>> + Sendwhere
Self: Sized,
fn execute(
conn: &mut PgConnection,
app_config: &ApplicationConfiguration,
arguments: &Self::Arguments,
authorization: &ToolAuthorization<Self>,
) -> impl Future<Output = ChatbotResult<(ExecutedAction, Self::Facts)>> + Sendwhere
Self: Sized,
Performs the mutation. Must re-verify every model-supplied display field against the
database (case-insensitively for emails) and refuse with a descriptive error rather than
mutate on a mismatch, so a wrong or stale display can never mutate a row it doesn’t
describe. authorization both proves the confirming admin was checked against
this call’s own requirements and names them, so the mutation cannot run ahead of the
check and the audit row cannot credit anyone else.
Sourcefn output_description_instructions(
arguments: &Self::Arguments,
facts: Option<&Self::Facts>,
app_config: &ApplicationConfiguration,
) -> Option<String>
fn output_description_instructions( arguments: &Self::Arguments, facts: Option<&Self::Facts>, app_config: &ApplicationConfiguration, ) -> Option<String>
Just-in-time instructions for the LLM on how to describe the outcome. facts is None on
a declined answer (nothing executed) and Some after a successful Self::execute, so
instructions can be conditioned on what this call actually did instead of always
including everything that could ever be true. app_config is available on both branches
(unlike facts) so a verification link can be offered even on a decline.
Provided Methods§
fn declined_output(_arguments: &Self::Arguments) -> String
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.