1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//! Hook result types for the enhanced plugin system.
//!
//! These enums define the return types for plugin hooks, enabling
//! continue/short-circuit semantics in the plugin pipeline.
//!
//! # Overview
//!
//! Each hook type has a corresponding result enum:
//!
//! - [`BeforeToolCallResult`] — returned by `before_tool_call` hooks
//! - [`AfterToolCallResult`] — returned by `after_tool_call` hooks
//! - [`BeforeModelCallResult`] — returned by `before_model_call` hooks
//! - [`AfterModelCallResult`] — returned by `after_model_call` hooks
//!
//! "Before" hooks support short-circuiting (skipping the underlying operation),
//! while "after" hooks only support continuing with a (possibly modified) result.
use ;
/// Result from a `before_tool_call` hook invocation.
///
/// Determines whether tool execution continues with (possibly modified) arguments,
/// or is short-circuited with a synthetic result.
///
/// # Examples
///
/// ## Continuing with modified arguments
///
/// ```rust
/// use adk_plugin::BeforeToolCallResult;
/// use serde_json::json;
///
/// // Pass through arguments unchanged
/// let args = json!({"query": "hello"});
/// let result = BeforeToolCallResult::Continue(args);
///
/// // Or modify arguments before passing to the tool
/// let sanitized = json!({"query": "hello", "safe_mode": true});
/// let result = BeforeToolCallResult::Continue(sanitized);
/// ```
///
/// ## Short-circuiting tool execution
///
/// ```rust
/// use adk_plugin::BeforeToolCallResult;
/// use serde_json::json;
///
/// // Skip tool execution and return a cached result
/// let cached = json!({"data": "cached response"});
/// let result = BeforeToolCallResult::ShortCircuit(cached);
/// ```
/// Result from an `after_tool_call` hook invocation.
///
/// After-tool hooks can only continue with a (possibly modified) result.
/// Short-circuiting is not supported for after-hooks since the operation
/// has already completed.
///
/// # Examples
///
/// ```rust
/// use adk_plugin::AfterToolCallResult;
/// use serde_json::json;
///
/// // Pass through the tool result unchanged
/// let tool_output = json!({"status": "success", "data": [1, 2, 3]});
/// let result = AfterToolCallResult::Continue(tool_output);
///
/// // Or modify the result (e.g., add metadata)
/// let enriched = json!({"status": "success", "data": [1, 2, 3], "cached": false});
/// let result = AfterToolCallResult::Continue(enriched);
/// ```
/// Result from a `before_model_call` hook invocation.
///
/// Determines whether the model call continues with a (possibly modified) request,
/// or is short-circuited with a synthetic response.
///
/// # Examples
///
/// ## Continuing with a modified request
///
/// ```rust,ignore
/// use adk_plugin::BeforeModelCallResult;
/// use adk_core::LlmRequest;
///
/// // Modify the request (e.g., inject a system instruction)
/// let mut request = LlmRequest::default();
/// request.model = "gemini-2.5-flash".to_string();
/// let result = BeforeModelCallResult::Continue(request);
/// ```
///
/// ## Short-circuiting with a cached response
///
/// ```rust,ignore
/// use adk_plugin::BeforeModelCallResult;
/// use adk_core::LlmResponse;
///
/// // Return a cached response without calling the model
/// let cached_response = LlmResponse::default();
/// let result = BeforeModelCallResult::ShortCircuit(cached_response);
/// ```
/// Result from an `after_model_call` hook invocation.
///
/// After-model hooks can only continue with a (possibly modified) response.
/// Short-circuiting is not supported for after-hooks since the model call
/// has already completed.
///
/// # Examples
///
/// ```rust,ignore
/// use adk_plugin::AfterModelCallResult;
/// use adk_core::LlmResponse;
///
/// // Pass through the model response unchanged
/// let response = LlmResponse::default();
/// let result = AfterModelCallResult::Continue(response);
/// ```