Skip to content
Draft
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
3 changes: 3 additions & 0 deletions crates/goose-cli/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2382,6 +2382,9 @@ fn find_elicitation_request(message: &Message) -> Option<(String, String, Value)
id,
message,
requested_schema,
// The CLI renders the prompt itself; relay correlation fields
// are only meaningful to the ACP forwarding path.
..
} = &action.data
{
return Some((id.clone(), message.clone(), requested_schema.clone()));
Expand Down
42 changes: 41 additions & 1 deletion crates/goose-provider-types/src/base.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use async_trait::async_trait;
use futures::Stream;
use rmcp::model::Tool;
use rmcp::model::{ElicitationAction, Tool};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
Expand Down Expand Up @@ -462,6 +462,17 @@ pub trait Provider: Send + Sync {
Ok(())
}

async fn prepare_session(
&self,
provider_session_id: Option<&str>,
_has_provider_history: bool,
) -> Result<(), ProviderError> {
match provider_session_id {
Some(session_id) => self.resume(session_id).await,
None => Ok(()),
}
}

/// Primary streaming method that all providers must implement.
async fn stream(
&self,
Expand Down Expand Up @@ -657,6 +668,35 @@ pub trait Provider: Send + Sync {
) -> bool {
false
}

/// Reserve a live elicitation so nothing else can cancel or consume it.
///
/// The response must be persisted before it is delivered, and the waiter
/// must not be able to disappear in between — a stream dropping between the
/// two would leave an answer recorded that the originating agent never
/// received. Claiming takes the waiter out of the provider's pending set;
/// `release_elicitation` puts it back if the response cannot be persisted.
async fn claim_elicitation(&self, _request_id: &str) -> bool {
false
}

/// Return a claimed elicitation to the pending set unanswered.
async fn release_elicitation(&self, _request_id: &str) {}

/// Deliver a response to a claimed elicitation. Returns false when the
/// originating agent is no longer there to receive it.
async fn handle_elicitation_response(
&self,
_request_id: &str,
_user_data: &Value,
_action: &ElicitationAction,
) -> bool {
false
}

async fn has_pending_elicitation(&self, _request_id: &str) -> bool {
false
}
}

#[cfg(test)]
Expand Down
16 changes: 16 additions & 0 deletions crates/goose-provider-types/src/conversation/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ pub enum ActionRequiredData {
id: String,
message: String,
requested_schema: serde_json::Value,
#[serde(default, skip_serializing_if = "Option::is_none")]
tool_call_id: Option<String>,
#[serde(default, rename = "_meta", skip_serializing_if = "Option::is_none")]
meta: Option<ProviderMetadata>,
},
ElicitationResponse {
id: String,
Expand Down Expand Up @@ -513,12 +517,24 @@ impl MessageContentBlock {
id: S,
message: String,
requested_schema: serde_json::Value,
) -> Self {
Self::action_required_elicitation_with_context(id, message, requested_schema, None, None)
}

pub fn action_required_elicitation_with_context<S: Into<String>>(
id: S,
message: String,
requested_schema: serde_json::Value,
tool_call_id: Option<String>,
meta: Option<ProviderMetadata>,
) -> Self {
MessageContentBlock::ActionRequired(ActionRequired {
data: ActionRequiredData::Elicitation {
id: id.into(),
message,
requested_schema,
tool_call_id,
meta,
},
})
}
Expand Down
Loading