Skip to content
Open
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
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ unstable = [
"unstable_session_model",
"unstable_session_resume",
"unstable_session_usage",
"unstable_message_id",
]
unstable_cancel_request = []
unstable_session_fork = []
Expand All @@ -30,6 +31,7 @@ unstable_session_list = []
unstable_session_model = []
unstable_session_resume = []
unstable_session_usage = []
unstable_message_id = []

[[bin]]
name = "generate"
Expand Down
60 changes: 60 additions & 0 deletions src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,18 @@ impl HttpHeader {
pub struct PromptRequest {
/// The ID of the session to send this user message to
pub session_id: SessionId,
/// **UNSTABLE**
///
/// This capability is not part of the spec yet, and may be removed or changed at any point.
///
/// A client-generated unique identifier for this user message.
///
/// If provided, the Agent SHOULD echo this value as `userMessageId` in the
/// [`PromptResponse`] to confirm it was recorded.
/// Both clients and agents MUST use UUID format for message IDs.
#[cfg(feature = "unstable_message_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message_id: Option<String>,
/// The blocks of content that compose the user's message.
///
/// As a baseline, the Agent MUST support [`ContentBlock::Text`] and [`ContentBlock::ResourceLink`],
Expand Down Expand Up @@ -1978,11 +1990,29 @@ impl PromptRequest {
pub fn new(session_id: impl Into<SessionId>, prompt: Vec<ContentBlock>) -> Self {
Self {
session_id: session_id.into(),
#[cfg(feature = "unstable_message_id")]
message_id: None,
prompt,
meta: None,
}
}

/// **UNSTABLE**
///
/// This capability is not part of the spec yet, and may be removed or changed at any point.
///
/// A client-generated unique identifier for this user message.
///
/// If provided, the Agent SHOULD echo this value as `userMessageId` in the
/// [`PromptResponse`] to confirm it was recorded.
/// Both clients and agents MUST use UUID format for message IDs.
#[cfg(feature = "unstable_message_id")]
#[must_use]
pub fn message_id(mut self, message_id: impl IntoOption<String>) -> Self {
self.message_id = message_id.into_option();
self
}

/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
Expand All @@ -2003,6 +2033,18 @@ impl PromptRequest {
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct PromptResponse {
/// **UNSTABLE**
///
/// This capability is not part of the spec yet, and may be removed or changed at any point.
///
/// The acknowledged user message ID.
///
/// If the client provided a `messageId` in the [`PromptRequest`], the agent echoes it here
/// to confirm it was recorded. If the client did not provide one, the agent MAY assign one
/// and return it here. Absence of this field indicates the agent did not record a message ID.
#[cfg(feature = "unstable_message_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_message_id: Option<String>,
/// Indicates why the agent stopped processing the turn.
pub stop_reason: StopReason,
/// **UNSTABLE**
Expand All @@ -2026,13 +2068,31 @@ impl PromptResponse {
#[must_use]
pub fn new(stop_reason: StopReason) -> Self {
Self {
#[cfg(feature = "unstable_message_id")]
user_message_id: None,
stop_reason,
#[cfg(feature = "unstable_session_usage")]
usage: None,
meta: None,
}
}

/// **UNSTABLE**
///
/// This capability is not part of the spec yet, and may be removed or changed at any point.
///
/// The acknowledged user message ID.
///
/// If the client provided a `messageId` in the [`PromptRequest`], the agent echoes it here
/// to confirm it was recorded. If the client did not provide one, the agent MAY assign one
/// and return it here. Absence of this field indicates the agent did not record a message ID.
#[cfg(feature = "unstable_message_id")]
#[must_use]
pub fn user_message_id(mut self, user_message_id: impl IntoOption<String>) -> Self {
self.user_message_id = user_message_id.into_option();
self
}

/// **UNSTABLE**
///
/// This capability is not part of the spec yet, and may be removed or changed at any point.
Expand Down
30 changes: 30 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,18 @@ impl Cost {
pub struct ContentChunk {
/// A single item of content
pub content: ContentBlock,
/// **UNSTABLE**
///
/// This capability is not part of the spec yet, and may be removed or changed at any point.
///
/// A unique identifier for the message this chunk belongs to.
///
/// All chunks belonging to the same message share the same `messageId`.
/// A change in `messageId` indicates a new message has started.
/// Both clients and agents MUST use UUID format for message IDs.
#[cfg(feature = "unstable_message_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message_id: Option<String>,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
Expand All @@ -344,10 +356,28 @@ impl ContentChunk {
pub fn new(content: ContentBlock) -> Self {
Self {
content,
#[cfg(feature = "unstable_message_id")]
message_id: None,
meta: None,
}
}

/// **UNSTABLE**
///
/// This capability is not part of the spec yet, and may be removed or changed at any point.
///
/// A unique identifier for the message this chunk belongs to.
///
/// All chunks belonging to the same message share the same `messageId`.
/// A change in `messageId` indicates a new message has started.
/// Both clients and agents MUST use UUID format for message IDs.
#[cfg(feature = "unstable_message_id")]
#[must_use]
pub fn message_id(mut self, message_id: impl IntoOption<String>) -> Self {
self.message_id = message_id.into_option();
self
}

/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
Expand Down
2 changes: 2 additions & 0 deletions src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ fn test_notification_wire_format() {
text: "Hello".to_string(),
meta: None,
}),
#[cfg(feature = "unstable_message_id")]
message_id: None,
meta: None,
}),
meta: None,
Expand Down