pub struct PromptRequest { /* private fields */ }Expand description
Supplies one foreground prompt and its optional portable overrides.
use agents_kit::{
model::ReasoningEffort,
prompt::PromptRequest,
};
let request = PromptRequest::new("Summarize the current task")?
.with_reasoning_effort(ReasoningEffort::medium());
assert_eq!(request.text(), "Summarize the current task");Implementations§
Source§impl PromptRequest
impl PromptRequest
Sourcepub fn new(text: impl Into<String>) -> Result<Self, KitError>
pub fn new(text: impl Into<String>) -> Result<Self, KitError>
Validates and constructs a request with no overrides.
Prompt text is retained exactly, including whitespace.
§Errors
An empty prompt returns InvalidInput.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.text(), "Hello");
assert!(PromptRequest::new("").is_err());Sourcepub fn with_cwd(self, cwd: PathBuf) -> Result<Self, KitError>
pub fn with_cwd(self, cwd: PathBuf) -> Result<Self, KitError>
Sets a validated path relative to the active workspace context.
This path is relative to the active workspace, not the caller process.
§Errors
Absolute paths, parent traversal, and invalid portable components return InvalidInput.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
let request = request.with_cwd("src".into())?;
assert_eq!(request.cwd(), Some(std::path::Path::new("src")));Sourcepub fn with_model(self, model: ModelSelector) -> Self
pub fn with_model(self, model: ModelSelector) -> Self
Sets the model selector for this prompt.
Availability is validated by the selected backend when submitting the prompt.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
let request = request.with_model(agents_kit::model::ModelSelector::new("model-id")?);
assert_eq!(request.model().unwrap().as_str(), "model-id");Sourcepub fn with_reasoning_effort(self, reasoning_effort: ReasoningEffort) -> Self
pub fn with_reasoning_effort(self, reasoning_effort: ReasoningEffort) -> Self
Sets the reasoning effort for this prompt.
The value must be supported by the selected backend and model; setting it does not validate availability. See the backend restrictions.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
let request = request.with_reasoning_effort(agents_kit::model::ReasoningEffort::low());
assert_eq!(request.reasoning_effort(), Some(&agents_kit::model::ReasoningEffort::low()));Sourcepub fn with_personality(self, personality: PersonalitySelector) -> Self
pub fn with_personality(self, personality: PersonalitySelector) -> Self
Sets the personality selector for this prompt.
This retains the caller value without validating backend support. The supplied
Codex, OpenCode and Custom implementations currently reject explicit personality
selection; caller backends may advertise and support it. See crate::model.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
let request = request.with_personality(agents_kit::model::PersonalitySelector::new("concise")?);
assert_eq!(request.personality().unwrap().as_str(), "concise");Sourcepub fn with_instructions(
self,
instructions: impl Into<String>,
) -> Result<Self, KitError>
pub fn with_instructions( self, instructions: impl Into<String>, ) -> Result<Self, KitError>
Sets nonempty prompt-level instructions.
Text is preserved without trimming.
§Errors
Empty instructions return InvalidInput.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
let request = request.with_instructions("Be concise.")?;
assert_eq!(request.instructions(), Some("Be concise."));Sourcepub fn with_knowledge_policy(
self,
policy: KnowledgePolicy,
) -> Result<Self, KitError>
pub fn with_knowledge_policy( self, policy: KnowledgePolicy, ) -> Result<Self, KitError>
Sets the effective managed-knowledge policy for this prompt.
This configures private retrieval; it does not install a model-visible tool.
§Errors
An Only policy with no scopes or duplicate scopes returns InvalidInput.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
let request = request.with_knowledge_policy(agents_kit::knowledge::KnowledgePolicy::Disabled)?;
assert_eq!(request.knowledge_policy(), Some(&agents_kit::knowledge::KnowledgePolicy::Disabled));Sourcepub fn with_timeout(self, timeout: Duration) -> Result<Self, KitError>
pub fn with_timeout(self, timeout: Duration) -> Result<Self, KitError>
Sets a nonzero foreground prompt timeout that starts after admission.
The timeout bounds execution after admission; it does not renew lifecycle deadlines.
§Errors
A zero timeout returns InvalidInput.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
let request = request.with_timeout(std::time::Duration::from_secs(20))?;
assert_eq!(request.timeout(), Some(std::time::Duration::from_secs(20)));Sourcepub fn with_structured_output(
self,
structured_output: StructuredOutputRequest,
) -> Self
pub fn with_structured_output( self, structured_output: StructuredOutputRequest, ) -> Self
Requests strict output matching the supplied schema.
Selected backends may reject unsupported structured-output execution.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
let schema = agents_kit::prompt::StructuredOutputRequest::new(serde_json::json!({"type":"string"}))?;
let request = request.with_structured_output(schema);
assert!(request.structured_output().is_some());Sourcepub fn with_tool_selection(
self,
selection: ToolSelection,
) -> Result<Self, KitError>
pub fn with_tool_selection( self, selection: ToolSelection, ) -> Result<Self, KitError>
Sets the portable tool-selection override.
A restricted catalog is distinct from requiring a call.
§Errors
Empty named selections, duplicate names, or invalid portable names return InvalidInput.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
let request = request.with_tool_selection(agents_kit::tool::ToolSelection::None)?;
assert_eq!(request.tool_selection(), Some(&agents_kit::tool::ToolSelection::None));Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
Returns the required prompt text.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.text(), "Hello");Sourcepub fn cwd(&self) -> Option<&Path>
pub fn cwd(&self) -> Option<&Path>
Returns the optional workspace-relative cwd override.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.cwd(), None);Sourcepub fn model(&self) -> Option<&ModelSelector>
pub fn model(&self) -> Option<&ModelSelector>
Returns the optional model override.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.model(), None);Sourcepub fn reasoning_effort(&self) -> Option<&ReasoningEffort>
pub fn reasoning_effort(&self) -> Option<&ReasoningEffort>
Returns the optional reasoning-effort override.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.reasoning_effort(), None);Sourcepub fn personality(&self) -> Option<&PersonalitySelector>
pub fn personality(&self) -> Option<&PersonalitySelector>
Returns the optional personality override.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.personality(), None);Sourcepub fn instructions(&self) -> Option<&str>
pub fn instructions(&self) -> Option<&str>
Returns the optional prompt-level instructions.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.instructions(), None);Sourcepub fn knowledge_policy(&self) -> Option<&KnowledgePolicy>
pub fn knowledge_policy(&self) -> Option<&KnowledgePolicy>
Returns the optional managed-knowledge policy override.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.knowledge_policy(), None);Sourcepub fn timeout(&self) -> Option<Duration>
pub fn timeout(&self) -> Option<Duration>
Returns the optional foreground prompt timeout.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.timeout(), None);Sourcepub fn structured_output(&self) -> Option<&StructuredOutputRequest>
pub fn structured_output(&self) -> Option<&StructuredOutputRequest>
Returns the optional strict structured-output request.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.structured_output(), None);Sourcepub fn tool_selection(&self) -> Option<&ToolSelection>
pub fn tool_selection(&self) -> Option<&ToolSelection>
Returns the optional portable tool-selection override.
use agents_kit::prompt::PromptRequest;
let request = PromptRequest::new("Hello")?;
assert_eq!(request.tool_selection(), None);Trait Implementations§
Source§impl Clone for PromptRequest
impl Clone for PromptRequest
Auto Trait Implementations§
impl Freeze for PromptRequest
impl RefUnwindSafe for PromptRequest
impl Send for PromptRequest
impl Sync for PromptRequest
impl Unpin for PromptRequest
impl UnsafeUnpin for PromptRequest
impl UnwindSafe for PromptRequest
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.