adding logging, cleaning up configs
This commit is contained in:
@@ -10,6 +10,14 @@ pub(crate) fn acp_model_id(agent_id: &str) -> String {
|
||||
format!("acp:{}", agent_id.trim().to_ascii_lowercase())
|
||||
}
|
||||
|
||||
pub(crate) fn acp_provider_model_id(provider_id: &str, agent_id: &str) -> String {
|
||||
format!(
|
||||
"acp:{}:{}",
|
||||
provider_id.trim().to_ascii_lowercase(),
|
||||
agent_id.trim().to_ascii_lowercase()
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn acp_selection_model_id(
|
||||
agent_id: &str,
|
||||
values: &std::collections::BTreeMap<String, serde_json::Value>,
|
||||
@@ -26,6 +34,21 @@ pub(crate) fn acp_selection_model_id(
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn acp_provider_selection_identity(
|
||||
provider_id: &str,
|
||||
agent_id: &str,
|
||||
values: &std::collections::BTreeMap<String, serde_json::Value>,
|
||||
) -> String {
|
||||
let mut identity = acp_provider_model_id(provider_id, agent_id);
|
||||
for (key, value) in values {
|
||||
identity.push(':');
|
||||
identity.push_str(key);
|
||||
identity.push('=');
|
||||
identity.push_str(&canonical_json_value(value));
|
||||
}
|
||||
identity
|
||||
}
|
||||
|
||||
pub(crate) fn acp_selection_identity(
|
||||
agent_id: &str,
|
||||
values: &std::collections::BTreeMap<String, serde_json::Value>,
|
||||
|
||||
@@ -116,6 +116,7 @@ fn persisted_sessions_require_the_same_launch_identity() {
|
||||
let args = vec!["serve".to_owned()];
|
||||
let launch = resolve_acp_launch("custom", command, &args).unwrap();
|
||||
let backend = AcpConversationData {
|
||||
provider_id: String::new(),
|
||||
agent_id: "custom".to_owned(),
|
||||
launch_fingerprint: acp_launch_fingerprint("custom", command, &args),
|
||||
session_id: Some("session-123".to_owned()),
|
||||
@@ -139,6 +140,7 @@ fn persisted_sessions_require_the_same_launch_identity() {
|
||||
#[test]
|
||||
fn legacy_acp_sessions_fail_closed_without_a_launch_fingerprint() {
|
||||
let backend = AcpConversationData {
|
||||
provider_id: String::new(),
|
||||
agent_id: "codex".to_owned(),
|
||||
launch_fingerprint: String::new(),
|
||||
session_id: Some("legacy-session".to_owned()),
|
||||
|
||||
@@ -11,8 +11,9 @@ mod runtime_model;
|
||||
mod transport;
|
||||
|
||||
pub(crate) use launch::{
|
||||
acp_launch_fingerprint, acp_model_id, acp_selection_identity, acp_selection_model_id,
|
||||
resolve_acp_launch, validate_acp_dispatch, validate_acp_launch_identity,
|
||||
acp_launch_fingerprint, acp_model_id, acp_provider_selection_identity, acp_selection_identity,
|
||||
acp_selection_model_id, resolve_acp_launch, validate_acp_dispatch,
|
||||
validate_acp_launch_identity,
|
||||
};
|
||||
pub(crate) use permissions::resolve_acp_permissions;
|
||||
pub(crate) use runtime_model::{AcpDiscoveryState, AcpRuntimeModel};
|
||||
|
||||
@@ -13,7 +13,7 @@ use galaxy_agent_core::{
|
||||
TurnRequest,
|
||||
};
|
||||
|
||||
use super::launch::acp_selection_identity;
|
||||
use super::launch::{acp_provider_selection_identity, acp_selection_identity};
|
||||
use super::prompt::{prompt_content, GalaxyTerminalTools};
|
||||
use crate::ai::agent::api::{self, RequestParams};
|
||||
use crate::ai::agent::EntrypointType;
|
||||
@@ -88,7 +88,15 @@ pub(crate) async fn acp_output_stream(
|
||||
if let Some(server) = galaxy_mcp_server {
|
||||
mcp_servers.push(server);
|
||||
}
|
||||
let runtime_id = acp_selection_identity(&backend.agent_id, &backend.config_values);
|
||||
let runtime_id = if backend.provider_id.is_empty() {
|
||||
acp_selection_identity(&backend.agent_id, &backend.config_values)
|
||||
} else {
|
||||
acp_provider_selection_identity(
|
||||
&backend.provider_id,
|
||||
&backend.agent_id,
|
||||
&backend.config_values,
|
||||
)
|
||||
};
|
||||
let mut runtime_config =
|
||||
AcpAgentRuntimeConfig::new(runtime_id.clone(), backend.agent_id.clone(), cwd);
|
||||
runtime_config.config_values = backend
|
||||
@@ -184,7 +192,15 @@ fn response_translator(
|
||||
conversation_id: String::new(),
|
||||
needs_create_task: params.tasks.is_empty(),
|
||||
user_query,
|
||||
model_id: acp_selection_identity(&backend.agent_id, &backend.config_values),
|
||||
model_id: if backend.provider_id.is_empty() {
|
||||
acp_selection_identity(&backend.agent_id, &backend.config_values)
|
||||
} else {
|
||||
acp_provider_selection_identity(
|
||||
&backend.provider_id,
|
||||
&backend.agent_id,
|
||||
&backend.config_values,
|
||||
)
|
||||
},
|
||||
max_context_tokens: None,
|
||||
capabilities: RuntimeCapabilities::session_runtime(),
|
||||
empty_output_message: Some("> ACP agent completed without a text response.".to_owned()),
|
||||
|
||||
Reference in New Issue
Block a user