sdk, agent: review fixes (T18R)
- The serve loop ends the process after EOF or exit_after_response, also with background tasks or listeners. - One schema generator per direction for the whole document, so types with the same name get distinct names. - The agent gives the complete error (code, message, data) to the model, writes SKIP only after a successful request, caps tool output at 64 KiB, writes each history line in one write, and skips a damaged line. - Endpoints skip blank and non-RPC lines. client_rs does not panic. - #[must_use] on builders and the lock guard; #[schemars] attributes and duplicate hooks are compile errors; raw identifiers; -32000 for local SDK errors; x-sausage-params only for methods with params.
This commit is contained in:
@@ -5,3 +5,4 @@ edition = "2024"
|
||||
[workspace]
|
||||
[dependencies]
|
||||
sausage-plugin = { path = "../../.." }
|
||||
wstd = "0.6"
|
||||
|
||||
@@ -70,7 +70,11 @@ impl Probe {
|
||||
}
|
||||
/// Return a deliberate error.
|
||||
fn fail(&self) -> Result<String> {
|
||||
Err(sausage_plugin::Error::new(-32010, "deliberate"))
|
||||
Err(sausage_plugin::Error {
|
||||
code: -32010,
|
||||
message: "deliberate".into(),
|
||||
data: Some(json!({"diagnostic":"probe error details"})),
|
||||
})
|
||||
}
|
||||
/// Exercise calls, notifications, and advisory locks.
|
||||
async fn exercise(&self, ctx: &Ctx) -> Result<String> {
|
||||
@@ -119,6 +123,19 @@ impl Probe {
|
||||
});
|
||||
Ok("started".into())
|
||||
}
|
||||
/// Keep a pollable alive for one hour.
|
||||
fn sleepy(&self) -> Result<()> {
|
||||
sausage_plugin::background(async {
|
||||
wstd::task::sleep(wstd::time::Duration::from_secs(3600)).await;
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
/// Exit after the response despite a pending background pollable.
|
||||
fn sleepy_exit(&self, ctx: &Ctx) -> Result<()> {
|
||||
self.sleepy()?;
|
||||
ctx.exit_after_response();
|
||||
Ok(())
|
||||
}
|
||||
/// Save an EOF marker.
|
||||
#[sausage_plugin::on_stop]
|
||||
async fn stop(&self) {
|
||||
|
||||
Reference in New Issue
Block a user