pub trait LiveSource:
Send
+ Sync
+ 'static {
const TAG: &'static str;
// Required methods
fn render(&self) -> impl Future<Output = Option<String>> + Send;
fn announce(&self, change: &LiveChange<'_>) -> Block;
}Expand description
Supplies live content: context that lives in the cacheable prefix of every request, after the system prompt and before the handoff, and changes while the session runs.
While nothing has carried the prefix — the start of a session, or right
after a reassembly or compaction — the rendered block is written into it.
Once a request has, a change is staged instead: the prefix stays
byte-identical, the alert announce writes for the
change is appended to the conversation once, and the next reassembly or
compaction folds the new block in and drops every such alert. A render
that matches what the model knows announces nothing, so a source is
rendered before every request at no cost to the cache.
The agent keeps the version the model has seen, so a source needs no commit step.
§Example
use aither_agent::{Block, LiveChange, LiveSource};
struct LinkedIssues(String);
impl LiveSource for LinkedIssues {
const TAG: &'static str = "linked_issues";
async fn render(&self) -> Option<String> {
Some(self.0.clone())
}
fn announce(&self, change: &LiveChange<'_>) -> Block {
Block::new("linked_issues_changed", change.diff())
}
}Required Associated Constants§
Required Methods§
Sourcefn render(&self) -> impl Future<Output = Option<String>> + Send
fn render(&self) -> impl Future<Output = Option<String>> + Send
Renders the block’s current content; None removes the block.
Polled at every request boundary, so it may read files or query registries; it must not block.
Sourcefn announce(&self, change: &LiveChange<'_>) -> Block
fn announce(&self, change: &LiveChange<'_>) -> Block
The durable alert telling the model of change, appended to the
conversation once while the prefix keeps the earlier version.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".