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
46 changes: 23 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ aionui-cron = { path = "crates/aionui-cron" }
aionui-assistant = { path = "crates/aionui-assistant" }
aionui-app = { path = "crates/aionui-app" }

aion-agent = { git = "https://github.com/iOfficeAI/aionrs.git", tag = "v0.2.3" }
aion-providers = { git = "https://github.com/iOfficeAI/aionrs.git", tag = "v0.2.3" }
aion-types = { git = "https://github.com/iOfficeAI/aionrs.git", tag = "v0.2.3" }
aion-protocol = { git = "https://github.com/iOfficeAI/aionrs.git", tag = "v0.2.3" }
aion-config = { git = "https://github.com/iOfficeAI/aionrs.git", tag = "v0.2.3" }
aion-mcp = { git = "https://github.com/iOfficeAI/aionrs.git", tag = "v0.2.3" }
aion-agent = { git = "https://github.com/GodfatherPacino/aionrs.git", rev = "d91f2b2b70983ef4425f855543c627d4be9e3c0d" }
aion-providers = { git = "https://github.com/GodfatherPacino/aionrs.git", rev = "d91f2b2b70983ef4425f855543c627d4be9e3c0d" }
aion-types = { git = "https://github.com/GodfatherPacino/aionrs.git", rev = "d91f2b2b70983ef4425f855543c627d4be9e3c0d" }
aion-protocol = { git = "https://github.com/GodfatherPacino/aionrs.git", rev = "d91f2b2b70983ef4425f855543c627d4be9e3c0d" }
aion-config = { git = "https://github.com/GodfatherPacino/aionrs.git", rev = "d91f2b2b70983ef4425f855543c627d4be9e3c0d" }
aion-mcp = { git = "https://github.com/GodfatherPacino/aionrs.git", rev = "d91f2b2b70983ef4425f855543c627d4be9e3c0d" }

# Core framework
tokio = { version = "1", features = ["full"] }
Expand Down
57 changes: 56 additions & 1 deletion crates/aionui-ai-agent/src/factory/aionrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ pub(super) async fn build(

let provider = map_aionrs_provider(&row.platform, &model_id, row.model_protocols.as_deref())?;

let (base_url, compat_overrides) =
let (base_url, mut compat_overrides) =
resolve_aionrs_url_and_compat(&row.platform, &row.base_url, &provider, row.is_full_url);
configure_glm_52_thinking_compat(&mut compat_overrides, &provider, &model_id);

let bedrock_config = if row.platform == "bedrock" {
resolve_bedrock_config(row.bedrock_config.as_deref())
Expand Down Expand Up @@ -210,6 +211,17 @@ pub(super) async fn build(
Ok(AgentInstance::Aionrs(Arc::new(agent)))
}

fn glm_52_default_thinking_mode(model_id: &str) -> Option<String> {
let normalized = model_id.trim().to_ascii_lowercase();
let model_name = normalized.rsplit('/').next().unwrap_or(&normalized);
(model_name == "glm-5.2" || model_name.starts_with("glm-5.2-")).then(|| "enabled".to_owned())
}

fn configure_glm_52_thinking_compat(compat_overrides: &mut AionrsCompatOverrides, provider: &str, model_id: &str) {
compat_overrides.thinking_mode = glm_52_default_thinking_mode(model_id);
compat_overrides.emit_disabled_thinking = provider == "anthropic" && compat_overrides.thinking_mode.is_some();
}

/// Map AionUi DB platform/protocol settings to the aionrs provider identifier.
pub(crate) fn map_aionrs_provider(
platform: &str,
Expand Down Expand Up @@ -1707,4 +1719,47 @@ mod tests {

assert_eq!(overrides.system_prompt.as_deref(), Some("Be concise."));
}

#[test]
fn glm_52_defaults_to_enabled_thinking() {
assert_eq!(glm_52_default_thinking_mode("glm-5.2").as_deref(), Some("enabled"));
assert_eq!(
glm_52_default_thinking_mode("GLM-5.2-20260701").as_deref(),
Some("enabled")
);
assert_eq!(
glm_52_default_thinking_mode("zhanlu/glm-5.2").as_deref(),
Some("enabled")
);
assert_eq!(
glm_52_default_thinking_mode("z-ai/glm-5.2-20260701").as_deref(),
Some("enabled")
);
}

#[test]
fn non_glm_52_models_do_not_receive_a_thinking_override() {
assert!(glm_52_default_thinking_mode("glm-5.1").is_none());
assert!(glm_52_default_thinking_mode("claude-sonnet-4").is_none());
}

#[test]
fn anthropic_glm_52_emits_explicit_disabled_thinking() {
let mut compat = AionrsCompatOverrides::default();

configure_glm_52_thinking_compat(&mut compat, "anthropic", "zhanlu/glm-5.2-anthropic");

assert_eq!(compat.thinking_mode.as_deref(), Some("enabled"));
assert!(compat.emit_disabled_thinking);
}

#[test]
fn openai_glm_52_keeps_default_disabled_serialization() {
let mut compat = AionrsCompatOverrides::default();

configure_glm_52_thinking_compat(&mut compat, "openai", "glm-5.2");

assert_eq!(compat.thinking_mode.as_deref(), Some("enabled"));
assert!(!compat.emit_disabled_thinking);
}
}
Loading