pub trait AgentCallback: Send + Sync {
Show 21 methods
// Required methods
fn on_assistant_message<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn on_token<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn request_approval<'life0, 'life1, 'async_trait>(
&'life0 self,
action: &'life1 ActionRequest,
) -> Pin<Box<dyn Future<Output = ApprovalDecision> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn on_tool_start<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn on_tool_result<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
output: &'life2 ToolOutput,
duration_ms: u64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn on_status_change<'life0, 'async_trait>(
&'life0 self,
status: AgentStatus,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_usage_update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
usage: &'life1 TokenUsage,
cost: &'life2 CostEstimate,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn on_decision_explanation<'life0, 'life1, 'async_trait>(
&'life0 self,
explanation: &'life1 DecisionExplanation,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn on_budget_warning<'life0, 'life1, 'async_trait>(
&'life0 self,
_message: &'life1 str,
_severity: BudgetSeverity,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_progress<'life0, 'life1, 'async_trait>(
&'life0 self,
_progress: &'life1 ProgressUpdate,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_clarification_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_question: &'life1 str,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_iteration_start<'life0, 'async_trait>(
&'life0 self,
_iteration: usize,
_max_iterations: usize,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_cost_prediction<'life0, 'async_trait>(
&'life0 self,
_estimated_tokens: usize,
_estimated_cost: f64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_context_health<'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 ContextHealthEvent,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_channel_digest<'life0, 'life1, 'async_trait>(
&'life0 self,
_digest: &'life1 Value,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_channel_alert<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_channel: &'life1 str,
_sender: &'life2 str,
_summary: &'life3 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn on_reminder<'life0, 'life1, 'async_trait>(
&'life0 self,
_reminder: &'life1 Value,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_plan_generating<'life0, 'life1, 'async_trait>(
&'life0 self,
_goal: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_plan_review<'life0, 'life1, 'async_trait>(
&'life0 self,
_plan: &'life1 ExecutionPlan,
) -> Pin<Box<dyn Future<Output = PlanDecision> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_plan_step_start<'life0, 'life1, 'async_trait>(
&'life0 self,
_step_index: usize,
_step: &'life1 PlanStep,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_plan_step_complete<'life0, 'life1, 'async_trait>(
&'life0 self,
_step_index: usize,
_step: &'life1 PlanStep,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Callback trait for user interaction (approval, display).
Required Methods§
Sourcefn on_assistant_message<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_assistant_message<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Display a message from the assistant to the user.
Sourcefn on_token<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_token<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Display a streaming token from the assistant.
Sourcefn request_approval<'life0, 'life1, 'async_trait>(
&'life0 self,
action: &'life1 ActionRequest,
) -> Pin<Box<dyn Future<Output = ApprovalDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn request_approval<'life0, 'life1, 'async_trait>(
&'life0 self,
action: &'life1 ActionRequest,
) -> Pin<Box<dyn Future<Output = ApprovalDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Request approval for an action. Returns the user’s decision.
Sourcefn on_tool_start<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_tool_start<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Notify about a tool execution.
Sourcefn on_tool_result<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
output: &'life2 ToolOutput,
duration_ms: u64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_tool_result<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
output: &'life2 ToolOutput,
duration_ms: u64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Notify about a tool result.
Sourcefn on_status_change<'life0, 'async_trait>(
&'life0 self,
status: AgentStatus,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_status_change<'life0, 'async_trait>(
&'life0 self,
status: AgentStatus,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Notify about agent status changes.
Sourcefn on_usage_update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
usage: &'life1 TokenUsage,
cost: &'life2 CostEstimate,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_usage_update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
usage: &'life1 TokenUsage,
cost: &'life2 CostEstimate,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Notify about token usage and cost after each LLM call.
Sourcefn on_decision_explanation<'life0, 'life1, 'async_trait>(
&'life0 self,
explanation: &'life1 DecisionExplanation,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_decision_explanation<'life0, 'life1, 'async_trait>(
&'life0 self,
explanation: &'life1 DecisionExplanation,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Notify about a decision explanation for a tool selection.
Provided Methods§
Sourcefn on_budget_warning<'life0, 'life1, 'async_trait>(
&'life0 self,
_message: &'life1 str,
_severity: BudgetSeverity,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_budget_warning<'life0, 'life1, 'async_trait>(
&'life0 self,
_message: &'life1 str,
_severity: BudgetSeverity,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Notify about a budget warning or exceeded condition. Default is a no-op for backward compatibility.
Sourcefn on_progress<'life0, 'life1, 'async_trait>(
&'life0 self,
_progress: &'life1 ProgressUpdate,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_progress<'life0, 'life1, 'async_trait>(
&'life0 self,
_progress: &'life1 ProgressUpdate,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Notify about progress during tool execution (streaming output, file operations, etc.). Default is a no-op for backward compatibility.
Sourcefn on_clarification_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_question: &'life1 str,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_clarification_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_question: &'life1 str,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Request clarification from the user. Returns the user’s answer. Called when the agent needs more information to proceed. Default returns empty string for backward compatibility.
Sourcefn on_iteration_start<'life0, 'async_trait>(
&'life0 self,
_iteration: usize,
_max_iterations: usize,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_iteration_start<'life0, 'async_trait>(
&'life0 self,
_iteration: usize,
_max_iterations: usize,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called at the start of each ReAct loop iteration with the current iteration number and the configured maximum. Used by the TUI sidebar to show live progress. Default is a no-op for backward compatibility.
Sourcefn on_cost_prediction<'life0, 'async_trait>(
&'life0 self,
_estimated_tokens: usize,
_estimated_cost: f64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_cost_prediction<'life0, 'async_trait>(
&'life0 self,
_estimated_tokens: usize,
_estimated_cost: f64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called before an LLM call with estimated token count and cost. Only called when estimated cost exceeds $0.05 to avoid noise. Default is a no-op for backward compatibility.
Sourcefn on_context_health<'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 ContextHealthEvent,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_context_health<'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 ContextHealthEvent,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Notify about context window health changes (warnings, compression events). Default is a no-op for backward compatibility.
Sourcefn on_channel_digest<'life0, 'life1, 'async_trait>(
&'life0 self,
_digest: &'life1 Value,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_channel_digest<'life0, 'life1, 'async_trait>(
&'life0 self,
_digest: &'life1 Value,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
A channel digest has been generated and is ready for review. Called when the digest system completes a summary for the configured period. Default is a no-op for backward compatibility.
Sourcefn on_channel_alert<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_channel: &'life1 str,
_sender: &'life2 str,
_summary: &'life3 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn on_channel_alert<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_channel: &'life1 str,
_sender: &'life2 str,
_summary: &'life3 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
A message on a channel needs immediate user attention (escalation).
Called when the intelligence layer classifies a message at or above the
escalation threshold. Uses &str parameters rather than ClassifiedMessage
to keep the callback trait decoupled from the classification system — callers
can format the alert data however they choose.
Default is a no-op for backward compatibility.
Sourcefn on_reminder<'life0, 'life1, 'async_trait>(
&'life0 self,
_reminder: &'life1 Value,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_reminder<'life0, 'life1, 'async_trait>(
&'life0 self,
_reminder: &'life1 Value,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
A scheduled follow-up reminder has been triggered. Called when a cron-scheduled reminder fires for a previously classified message that requires follow-up. Default is a no-op for backward compatibility.
Sourcefn on_plan_generating<'life0, 'life1, 'async_trait>(
&'life0 self,
_goal: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_plan_generating<'life0, 'life1, 'async_trait>(
&'life0 self,
_goal: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when plan generation starts. Default is a no-op for backward compatibility.
Sourcefn on_plan_review<'life0, 'life1, 'async_trait>(
&'life0 self,
_plan: &'life1 ExecutionPlan,
) -> Pin<Box<dyn Future<Output = PlanDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_plan_review<'life0, 'life1, 'async_trait>(
&'life0 self,
_plan: &'life1 ExecutionPlan,
) -> Pin<Box<dyn Future<Output = PlanDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a plan is ready for user review. Returns the user’s decision on the plan. Default auto-approves for backward compatibility.
Sourcefn on_plan_step_start<'life0, 'life1, 'async_trait>(
&'life0 self,
_step_index: usize,
_step: &'life1 PlanStep,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_plan_step_start<'life0, 'life1, 'async_trait>(
&'life0 self,
_step_index: usize,
_step: &'life1 PlanStep,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a plan step starts executing. Default is a no-op for backward compatibility.
Sourcefn on_plan_step_complete<'life0, 'life1, 'async_trait>(
&'life0 self,
_step_index: usize,
_step: &'life1 PlanStep,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_plan_step_complete<'life0, 'life1, 'async_trait>(
&'life0 self,
_step_index: usize,
_step: &'life1 PlanStep,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a plan step finishes (success or failure). Default is a no-op for backward compatibility.