pub struct CustomTaskHandler { /* private fields */ }Expand description
TaskHandler that injects a custom prompt into the agent loop.
When a TaskKind::Custom task is due, CustomTaskHandler
reads the "task" field from the task’s JSON config, sanitises it with
crate::sanitize_task_prompt_checked, and sends the resulting string on the
provided mpsc::Sender. The agent loop receives the prompt and processes it as a
new user message.
Sending is best-effort: if the channel is full or closed, the error is logged at
warn level and Ok(()) is returned so the scheduler continues running.
Injection pattern detection: if the prompt contains a known injection marker,
SchedulerError::PromptInjectionBlocked is returned and no message is sent.
§Examples
use tokio::sync::mpsc;
use zeph_scheduler::CustomTaskHandler;
let (tx, mut rx) = mpsc::channel(8);
let handler = CustomTaskHandler::new(tx);
use zeph_scheduler::TaskHandler;
handler
.execute(&serde_json::json!({"task": "Generate a daily report"}))
.await
.expect("handler should not fail");
let prompt = rx.recv().await.unwrap();
assert_eq!(prompt, "Generate a daily report");Implementations§
Source§impl CustomTaskHandler
impl CustomTaskHandler
Sourcepub fn new(tx: Sender<String>) -> Self
pub fn new(tx: Sender<String>) -> Self
Create a new handler that sends prompts on tx.
task_name is included in SchedulerError::PromptInjectionBlocked when
an injection pattern is detected, enabling structured log correlation.
Trait Implementations§
Source§impl TaskHandler for CustomTaskHandler
impl TaskHandler for CustomTaskHandler
Source§fn injects_agent_prompt(&self) -> bool
fn injects_agent_prompt(&self) -> bool
Always true: every execution sends the sanitised prompt on tx for the agent loop
to process as a new user message, so RTW-A Mechanism 4 must be able to suppress it.
Source§fn execute(
&self,
config: &Value,
) -> Pin<Box<dyn Future<Output = Result<(), SchedulerError>> + Send + '_>>
fn execute( &self, config: &Value, ) -> Pin<Box<dyn Future<Output = Result<(), SchedulerError>> + Send + '_>>
Source§fn reads_external_content(&self) -> bool
fn reads_external_content(&self) -> bool
true when execute reads content that originates
outside the scheduler’s own trusted config or in-process state — e.g. a network/HTTP
response, an MCP tool result, a file loaded from a plugin-marketplace skill directory,
or stored memory/graph facts that may themselves have been populated from such an
external source. Read moreAuto Trait Implementations§
impl Freeze for CustomTaskHandler
impl RefUnwindSafe for CustomTaskHandler
impl Send for CustomTaskHandler
impl Sync for CustomTaskHandler
impl Unpin for CustomTaskHandler
impl UnsafeUnpin for CustomTaskHandler
impl UnwindSafe for CustomTaskHandler
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
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 more