Skip to content

Commit 47bbe66

Browse files
committed
feat(acp-nats): add integration test suite for Bridge, handlers, and workflows
- Add tests/ module with agent_handlers, builders, prefix, and workflows - Cover all 9 agent handlers with success and error paths - Test CancelledSessions, prompt waiter resolution, session.ready tasks Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
1 parent ba56cee commit 47bbe66

8 files changed

Lines changed: 1060 additions & 8 deletions

File tree

rsworkspace/crates/acp-nats/src/agent/cancel.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use super::Bridge;
22
use crate::nats::{self, FlushClient, PublishClient, RequestClient, agent};
33
use crate::session_id::AcpSessionId;
4-
use agent_client_protocol::{CancelNotification, Error, ErrorCode, Result};
4+
use agent_client_protocol::{
5+
CancelNotification, Error, ErrorCode, PromptResponse, Result, StopReason,
6+
};
57
use tracing::{info, instrument, warn};
68
use trogon_std::time::GetElapsed;
79

@@ -62,7 +64,10 @@ pub async fn handle<N: RequestClient + PublishClient + FlushClient, C: GetElapse
6264
.mark_cancelled(args.session_id.clone(), &bridge.clock);
6365
bridge
6466
.pending_session_prompt_responses
65-
.cancel_waiter_for_session(&args.session_id, Err("Session was cancelled".to_string()));
67+
.cancel_waiter_for_session(
68+
&args.session_id,
69+
Ok(PromptResponse::new(StopReason::Cancelled)),
70+
);
6671

6772
bridge.metrics.record_request(
6873
"cancel",

rsworkspace/crates/acp-nats/src/agent/prompt.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,9 @@ pub async fn handle<N: RequestClient + PublishClient + FlushClient, C: GetElapse
8989
.take_if_cancelled(&args.session_id, &bridge.clock)
9090
.is_some()
9191
{
92-
bridge
93-
.metrics
94-
.record_error("prompt", "session_cancelled_preflight");
95-
return Err(Error::new(
96-
ErrorCode::InvalidParams.into(),
97-
format!("Session {} was recently cancelled", args.session_id),
92+
info!(session_id = %args.session_id, "Prompt pre-flight: session already cancelled");
93+
return Ok(PromptResponse::new(
94+
agent_client_protocol::StopReason::Cancelled,
9895
));
9996
}
10097

rsworkspace/crates/acp-nats/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pub mod prompt_slot_counter;
1212
pub mod session_id;
1313
pub mod subject_token_violation;
1414
pub(crate) mod telemetry;
15+
#[cfg(test)]
16+
mod tests;
1517

1618
pub use acp_prefix::{AcpPrefix, AcpPrefixError};
1719
pub use agent::Bridge;

0 commit comments

Comments
 (0)