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
1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ prep-tests:
# Prepare subprocess fixtures, then run all tests, including doctests.
test: prep-tests
cargo test --workspace --all-features --locked
cargo test -p agent-client-protocol --no-default-features --locked
2 changes: 1 addition & 1 deletion md/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- [Request Cancellation](./request-cancellation.md)
- [Ordered Application Dispatch](./ordered-application-dispatch.md)
- [Configurable LLM Providers](./llm-providers.md)
- [Protocol V2](./protocol-v2.md)
- [Protocol V2 and Version Routing](./protocol-v2.md)
- [Runnable V2 Quickstart](./protocol-v2-quickstart.md)
- [Session Operation Coordination](./session-operation-coordination.md)

Expand Down
115 changes: 82 additions & 33 deletions md/protocol-v2.md

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/agent-client-protocol-conductor/src/conductor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ impl InitializeProtocol {
} else if requested == ProtocolVersion::V1 {
Self::V1
} else {
return Err(Error::invalid_request()
.data(format!("unsupported ACP protocol version {requested}")));
return Err(agent_client_protocol::util::unsupported_protocol_version(
requested,
&[ProtocolVersion::V1, ProtocolVersion::V2],
));
};

Ok(InitializeProtocolSelection {
Expand Down
17 changes: 16 additions & 1 deletion src/agent-client-protocol-conductor/tests/initialization_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,10 @@ async fn assert_invalid_final_agent_initialize_response(
async fn assert_raw_initialize_rejected(
params: serde_json::Value,
expected_error: &str,
expected_code: i32,
) -> Result<(), Error> {
run_raw_client_with_conductor(ProxiesAndAgent::new(Agent.v2()), async move |cx| {
let requested = params.get("protocolVersion").cloned();
let request = UntypedMessage {
method: "initialize".to_string(),
params,
Expand All @@ -334,6 +336,16 @@ async fn assert_raw_initialize_rejected(
.await
.expect("invalid initialize request should not hang")
.expect_err("invalid initialize request must be rejected");
assert_eq!(i32::from(error.code), expected_code);
if expected_code == -32022 {
assert_eq!(
error.data,
Some(serde_json::json!({
"requested": requested.expect("a version mismatch has a requested version"),
"supported": [1, 2],
}))
);
}
assert!(
error.to_string().contains(expected_error),
"unexpected initialize rejection: {error:?}"
Expand Down Expand Up @@ -473,16 +485,19 @@ async fn v2_conductor_rejects_invalid_protocol_versions_with_responses() -> Resu
assert_raw_initialize_rejected(
serde_json::json!({}),
"protocolVersion must be a valid ACP protocol version",
-32602,
)
.await?;
assert_raw_initialize_rejected(
serde_json::json!({ "protocolVersion": "2" }),
"protocolVersion must be a valid ACP protocol version",
-32602,
)
.await?;
assert_raw_initialize_rejected(
serde_json::json!({ "protocolVersion": 0 }),
"unsupported ACP protocol version 0",
"Unsupported protocol version",
-32022,
)
.await
}
Expand Down
2 changes: 2 additions & 0 deletions src/agent-client-protocol/src/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pub use crate::jsonrpc::handlers::NullHandler;
use crate::jsonrpc::handlers::{ChainedHandler, NamedHandler};
use crate::jsonrpc::handlers::{MessageHandler, NotificationHandler, RequestHandler};
use crate::jsonrpc::outgoing_actor::{OutgoingMessageTx, send_raw_message};
#[cfg(feature = "unstable_protocol_v2")]
pub(crate) use crate::jsonrpc::protocol_compat::normalize_v1_initialize_request;
use crate::jsonrpc::protocol_compat::{ProtocolCompat, ProtocolMode};
pub use crate::jsonrpc::raw_error::{RawJsonRpcError, RawJsonRpcResponse};
use crate::jsonrpc::run::SpawnedRun;
Expand Down
Loading
Loading