pub enum BeforeModelCallResult {
Continue(LlmRequest),
ShortCircuit(LlmResponse),
}Available on crate feature
plugin only.Expand description
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
ⓘ
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
ⓘ
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);Variants§
Continue(LlmRequest)
Continue execution with (possibly modified) LLM request.
The contained request will be passed to the next plugin in the chain, and ultimately to the LLM provider if this is the last plugin.
ShortCircuit(LlmResponse)
Short-circuit: skip the model call and use this synthetic response.
When returned, no further plugins in the chain are invoked, the LLM is not called, and this response is used as the model output.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BeforeModelCallResult
impl RefUnwindSafe for BeforeModelCallResult
impl Send for BeforeModelCallResult
impl Sync for BeforeModelCallResult
impl Unpin for BeforeModelCallResult
impl UnsafeUnpin for BeforeModelCallResult
impl UnwindSafe for BeforeModelCallResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more