Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions agent-client-protocol-schema/src/v2/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2778,8 +2778,8 @@ impl SetSessionConfigOptionRequest {
#[non_exhaustive]
pub struct SetSessionConfigOptionResponse {
/// The full set of configuration options and their current values.
#[serde_as(deserialize_as = "DefaultOnError<VecSkipError<_>>")]
#[cfg_attr(feature = "schemars", schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true)))]
#[serde_as(deserialize_as = "VecSkipError<_>")]
#[cfg_attr(feature = "schemars", schemars(extend("x-deserialize-skip-invalid-items" = true)))]
pub config_options: Vec<SessionConfigOption>,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Omitted and `null` are equivalent and mean no metadata.
Expand Down
45 changes: 41 additions & 4 deletions agent-client-protocol-schema/src/v2/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,8 @@ fn other_session_update_schema(schema: &mut Schema) {
#[non_exhaustive]
pub struct ConfigOptionUpdate {
/// The full set of configuration options and their current values.
#[serde_as(deserialize_as = "DefaultOnError<VecSkipError<_>>")]
#[cfg_attr(feature = "schemars", schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true)))]
#[serde_as(deserialize_as = "VecSkipError<_>")]
#[cfg_attr(feature = "schemars", schemars(extend("x-deserialize-skip-invalid-items" = true)))]
pub config_options: Vec<SessionConfigOption>,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Omitted and `null` are equivalent and mean no metadata.
Expand Down Expand Up @@ -2271,8 +2271,8 @@ impl MessageId {
#[non_exhaustive]
pub struct AvailableCommandsUpdate {
/// Commands the agent can execute.
#[serde_as(deserialize_as = "DefaultOnError<VecSkipError<_>>")]
#[cfg_attr(feature = "schemars", schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true)))]
#[serde_as(deserialize_as = "VecSkipError<_>")]
#[cfg_attr(feature = "schemars", schemars(extend("x-deserialize-skip-invalid-items" = true)))]
pub available_commands: Vec<AvailableCommand>,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Omitted and `null` are equivalent and mean no metadata.
Expand Down Expand Up @@ -3684,6 +3684,43 @@ impl AgentNotification {
#[cfg(test)]
mod tests {

#[test]
fn replacement_lists_reject_non_arrays_instead_of_clearing() {
use serde_json::json;
for (update, key) in [
("config_option_update", "configOptions"),
("available_commands_update", "availableCommands"),
] {
let empty = json!({ "sessionUpdate": update, key: [] });
serde_json::from_value::<super::SessionUpdate>(empty).unwrap();
for bad in [json!("oops"), json!(null), json!({})] {
let wire = json!({ "sessionUpdate": update, key: bad });
assert!(
serde_json::from_value::<super::SessionUpdate>(wire).is_err(),
"{update} {bad}"
);
}
}
let plan = |entries: serde_json::Value| {
json!({ "sessionUpdate": "plan_update",
"plan": { "type": "items", "planId": "p", "entries": entries } })
};
serde_json::from_value::<super::SessionUpdate>(plan(json!([]))).unwrap();
assert!(serde_json::from_value::<super::SessionUpdate>(plan(json!("oops"))).is_err());
// Invalid items are still skipped.
let skipped =
plan(json!([42, { "content": "a", "priority": "high", "status": "pending" }]));
let super::SessionUpdate::PlanUpdate(update) =
serde_json::from_value::<super::SessionUpdate>(skipped).unwrap()
else {
panic!("expected plan_update");
};
let crate::v2::PlanUpdateContent::Items(items) = update.plan else {
panic!("expected items");
};
assert_eq!(items.entries.len(), 1);
}

#[test]
fn other_available_command_preserves_meta_verbatim() {
for meta in [serde_json::json!({ "k": 1 }), serde_json::json!("bad")] {
Expand Down
4 changes: 2 additions & 2 deletions agent-client-protocol-schema/src/v2/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ pub struct PlanItems {
///
/// When updating an item-based plan, the agent must send a complete list of all entries
/// with their current status. The client replaces that plan with each update.
#[serde_as(deserialize_as = "DefaultOnError<VecSkipError<_>>")]
#[cfg_attr(feature = "schemars", schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true)))]
#[serde_as(deserialize_as = "VecSkipError<_>")]
#[cfg_attr(feature = "schemars", schemars(extend("x-deserialize-skip-invalid-items" = true)))]
pub entries: Vec<PlanEntry>,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Omitted and `null` are equivalent and mean no metadata.
Expand Down
4 changes: 0 additions & 4 deletions schema/v2/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4274,7 +4274,6 @@
"items": {
"$ref": "#/$defs/SessionConfigOption"
},
"x-deserialize-default-on-error": true,
"x-deserialize-skip-invalid-items": true
},
"_meta": {
Expand Down Expand Up @@ -5815,7 +5814,6 @@
"items": {
"$ref": "#/$defs/PlanEntry"
},
"x-deserialize-default-on-error": true,
"x-deserialize-skip-invalid-items": true
},
"_meta": {
Expand Down Expand Up @@ -5858,7 +5856,6 @@
"items": {
"$ref": "#/$defs/AvailableCommand"
},
"x-deserialize-default-on-error": true,
"x-deserialize-skip-invalid-items": true
},
"_meta": {
Expand All @@ -5880,7 +5877,6 @@
"items": {
"$ref": "#/$defs/SessionConfigOption"
},
"x-deserialize-default-on-error": true,
"x-deserialize-skip-invalid-items": true
},
"_meta": {
Expand Down
4 changes: 0 additions & 4 deletions schema/v2/schema.unstable.json
Original file line number Diff line number Diff line change
Expand Up @@ -4757,7 +4757,6 @@
"items": {
"$ref": "#/$defs/SessionConfigOption"
},
"x-deserialize-default-on-error": true,
"x-deserialize-skip-invalid-items": true
},
"_meta": {
Expand Down Expand Up @@ -6556,7 +6555,6 @@
"items": {
"$ref": "#/$defs/PlanEntry"
},
"x-deserialize-default-on-error": true,
"x-deserialize-skip-invalid-items": true
},
"_meta": {
Expand Down Expand Up @@ -6671,7 +6669,6 @@
"items": {
"$ref": "#/$defs/AvailableCommand"
},
"x-deserialize-default-on-error": true,
"x-deserialize-skip-invalid-items": true
},
"_meta": {
Expand All @@ -6693,7 +6690,6 @@
"items": {
"$ref": "#/$defs/SessionConfigOption"
},
"x-deserialize-default-on-error": true,
"x-deserialize-skip-invalid-items": true
},
"_meta": {
Expand Down
Loading