diff --git a/.github/workflows/patched-release.yml b/.github/workflows/patched-release.yml index 15583c0bb698..170403b6c24d 100644 --- a/.github/workflows/patched-release.yml +++ b/.github/workflows/patched-release.yml @@ -1,4 +1,4 @@ -# Modified by Jonathan Mohrbacher, 2026: test-patches runs subdirectory hints tests; test-patches runs message id / truncate_from_message tests; the release also carries the aarch64-apple-darwin CLI. +# Modified by Jonathan Mohrbacher, 2026: test-patches runs subdirectory hints tests; test-patches runs message id / truncate_from_message tests; the release also carries the aarch64-apple-darwin CLI; test-patches runs role recipe thinking_effort tests. # Builds this branch (an upstream release tag plus a few local patches) with upstream's own # Linux CLI build workflow and patched-build-macos.yml (upstream's macOS CLI build, unsigned), so the result # differs from the upstream release only by the patches, and publishes the gnu tarballs and the @@ -55,7 +55,7 @@ jobs: - name: Test patched modules run: | F=code-mode,tree-sitter,aws-providers,telemetry,otel,rustls-tls,live-voice,system-keyring,platform-apps,chat-recall,scheduler,acp-http,online-model-meta - cargo test --release -p goose --features "$F" --lib -- gcpvertexai session_context test_parent_link_is_visible_to_providers gcpauth process_group cache_ttl max_turns_from_meta test_add_final_output_tool rolling self_compact compact_kind global_skill mcp_client_startup_timeout turn_error subagent_policy subdirectory_hints deliver_subdirectory_hints requeue_after_history_replacement message_id_from_meta agent_capabilities_advertise_truncate_from_message truncate_conversation_from_message requeue_hints_missing_from cache_miss_breaker + cargo test --release -p goose --features "$F" --lib -- gcpvertexai session_context test_parent_link_is_visible_to_providers gcpauth process_group cache_ttl max_turns_from_meta test_add_final_output_tool rolling self_compact compact_kind global_skill mcp_client_startup_timeout turn_error subagent_policy subdirectory_hints deliver_subdirectory_hints requeue_after_history_replacement message_id_from_meta agent_capabilities_advertise_truncate_from_message truncate_conversation_from_message requeue_hints_missing_from cache_miss_breaker recipe_thinking_effort recipe_without_thinking_effort thinking_effort_parsing invalid_thinking_effort cargo test --release -p goose --features "$F" --test acp_server_test -- test_session_settings test_prompt_max_turns_bounds_run test_prompt_self_compact test_recipe_session_after_reload_never_lists_self_compact_and_resume test_prompt_turn_error test_prompt_message_id_and_truncate_from_message cargo test --release -p goose --features "$F" --test rolling_memory cargo test --release -p goose --features "$F" --test self_compact diff --git a/crates/goose/src/acp/server/recipe/conversions.rs b/crates/goose/src/acp/server/recipe/conversions.rs index 1585177ec2a5..b39a44d38075 100644 --- a/crates/goose/src/acp/server/recipe/conversions.rs +++ b/crates/goose/src/acp/server/recipe/conversions.rs @@ -108,6 +108,7 @@ impl From for Settings { goose_model: dto.goose_model, temperature: dto.temperature, max_turns: dto.max_turns, + thinking_effort: None, } } } diff --git a/crates/goose/src/agents/platform_extensions/summon.rs b/crates/goose/src/agents/platform_extensions/summon.rs index 5a4ad9baab58..5425d893f6d7 100644 --- a/crates/goose/src/agents/platform_extensions/summon.rs +++ b/crates/goose/src/agents/platform_extensions/summon.rs @@ -1,4 +1,4 @@ -// Modified by Jonathan Mohrbacher, 2026: subagent policy: GOOSE_SUBAGENT_ROLES_DIR (~ expanded) is scanned first; recipe declared extensions replace parent; GOOSE_SUBAGENT_DEFAULT_RECIPE scopes delegates declaring no extensions. +// Modified by Jonathan Mohrbacher, 2026: subagent policy: GOOSE_SUBAGENT_ROLES_DIR (~ expanded) is scanned first; recipe declared extensions replace parent; GOOSE_SUBAGENT_DEFAULT_RECIPE scopes delegates declaring no extensions; recipe settings.thinking_effort overrides the inherited delegate effort. use crate::agents::extension::PlatformExtensionContext; use crate::agents::final_output_tool::FinalOutputTool; use crate::agents::mcp_client::{Error, McpClientTrait}; @@ -1548,6 +1548,7 @@ impl SummonClient { goose_model: None, temperature: None, max_turns: None, + thinking_effort: None, }) .max_turns = Some(max_turns); if recipe @@ -1795,6 +1796,7 @@ impl SummonClient { goose_provider: params.provider.clone(), temperature: params.temperature, max_turns: None, + thinking_effort: None, }); let mut builder = Recipe::builder() @@ -1994,6 +1996,10 @@ impl SummonClient { model_config = model_config.with_temperature(Some(temp)); } + if let Some(effort) = recipe.settings.as_ref().and_then(|s| s.thinking_effort) { + model_config = model_config.with_thinking_effort(effort); + } + Ok(model_config) } @@ -3339,6 +3345,7 @@ You review code."#; goose_model: None, temperature: None, max_turns: Some(10), + thinking_effort: None, }), activities: None, author: None, @@ -3612,6 +3619,145 @@ You review code."#; ); } + #[tokio::test] + #[serial] + async fn test_resolve_model_config_recipe_thinking_effort_overrides_parent_on_override() { + use goose_providers::thinking::ThinkingEffort; + + let _env = env_lock::lock_env([ + ("GOOSE_CONTEXT_LIMIT", None::<&str>), + ("GOOSE_MAX_TOKENS", None::<&str>), + ("GOOSE_SUBAGENT_MODEL", None::<&str>), + ]); + + let parent = parent_config().with_thinking_effort(ThinkingEffort::Medium); + let client = SummonClient::new(create_test_context()).unwrap(); + let params = DelegateParams { + model: Some(OVERRIDE_MODEL.to_string()), + ..Default::default() + }; + let recipe = Recipe::from_content( + r#" +version: "1.0.0" +title: "Test" +description: "Test" +instructions: "Test" +settings: + thinking_effort: high +"#, + ) + .expect("recipe with thinking_effort should parse"); + + let resolved = client + .resolve_model_config(¶ms, &recipe, &session_with(parent), PROVIDER, None) + .expect("resolve_model_config"); + + assert_eq!( + resolved.thinking_effort(), + Some(ThinkingEffort::High), + "recipe settings.thinking_effort must override inherited effort on model override" + ); + } + + #[tokio::test] + #[serial] + async fn test_resolve_model_config_recipe_thinking_effort_overrides_parent_on_clone() { + use goose_providers::thinking::ThinkingEffort; + + let _env = env_lock::lock_env([ + ("GOOSE_CONTEXT_LIMIT", None::<&str>), + ("GOOSE_MAX_TOKENS", None::<&str>), + ("GOOSE_SUBAGENT_MODEL", None::<&str>), + ]); + + let parent = parent_config().with_thinking_effort(ThinkingEffort::Medium); + let client = SummonClient::new(create_test_context()).unwrap(); + let params = DelegateParams::default(); + let recipe = Recipe::from_content( + r#" +version: "1.0.0" +title: "Test" +description: "Test" +instructions: "Test" +settings: + thinking_effort: high +"#, + ) + .expect("recipe with thinking_effort should parse"); + + let resolved = client + .resolve_model_config(¶ms, &recipe, &session_with(parent), PROVIDER, None) + .expect("resolve_model_config"); + + assert_eq!( + resolved.thinking_effort(), + Some(ThinkingEffort::High), + "recipe settings.thinking_effort must override inherited effort on same-model clone" + ); + } + + #[tokio::test] + #[serial] + async fn test_resolve_model_config_recipe_without_thinking_effort_inherits_parent() { + use goose_providers::thinking::ThinkingEffort; + + let _env = env_lock::lock_env([ + ("GOOSE_CONTEXT_LIMIT", None::<&str>), + ("GOOSE_MAX_TOKENS", None::<&str>), + ("GOOSE_SUBAGENT_MODEL", None::<&str>), + ]); + + let parent = parent_config().with_thinking_effort(ThinkingEffort::Medium); + let client = SummonClient::new(create_test_context()).unwrap(); + let params = DelegateParams { + model: Some(OVERRIDE_MODEL.to_string()), + ..Default::default() + }; + let recipe = empty_recipe(); + + let resolved = client + .resolve_model_config(¶ms, &recipe, &session_with(parent), PROVIDER, None) + .expect("resolve_model_config"); + + assert_eq!( + resolved.thinking_effort(), + Some(ThinkingEffort::Medium), + "recipe without thinking_effort must inherit parent's medium effort" + ); + } + + #[test] + fn test_recipe_yaml_thinking_effort_parsing() { + use goose_providers::thinking::ThinkingEffort; + + let valid_yaml = r#" +version: "1.0.0" +title: "Test" +description: "Test" +instructions: "Test" +settings: + thinking_effort: high +"#; + let recipe = + Recipe::from_content(valid_yaml).expect("recipe with thinking_effort should parse"); + assert_eq!( + recipe.settings.as_ref().and_then(|s| s.thinking_effort), + Some(ThinkingEffort::High), + "recipe yaml with thinking_effort: high must parse to Some(High)" + ); + + let bogus_yaml = r#" +version: "1.0.0" +title: "Test" +description: "Test" +instructions: "Test" +settings: + thinking_effort: bogus +"#; + let result = Recipe::from_content(bogus_yaml); + assert!(result.is_err(), "thinking_effort: bogus must fail to parse"); + } + fn extract_text(content: &ContentBlock) -> &str { use rmcp::model::ContentBlock; match content { @@ -3665,6 +3811,7 @@ You review code."#; goose_model: Some("recipe-model".to_string()), temperature: None, max_turns: None, + thinking_effort: None, }); let result = client .resolve_model_config( @@ -3699,6 +3846,7 @@ You review code."#; goose_model: None, temperature: None, max_turns: None, + thinking_effort: None, }); let (resolved_provider, _) = client .resolve_provider( @@ -3734,6 +3882,7 @@ You review code."#; goose_model: None, temperature: None, max_turns: None, + thinking_effort: None, }); let session = crate::session::Session::default(); let (_, result) = client diff --git a/crates/goose/src/recipe/mod.rs b/crates/goose/src/recipe/mod.rs index 149a9abd9ffe..63ffd99a7b1a 100644 --- a/crates/goose/src/recipe/mod.rs +++ b/crates/goose/src/recipe/mod.rs @@ -1,3 +1,4 @@ +// Modified by Jonathan Mohrbacher, 2026: recipe settings.thinking_effort overrides the inherited delegate effort. use anyhow::Result; use serde_json::Value; use std::collections::HashMap; @@ -108,6 +109,9 @@ pub struct Settings { #[serde(skip_serializing_if = "Option::is_none")] pub max_turns: Option, + + #[serde(default, skip_serializing_if = "Option::is_none")] + pub thinking_effort: Option, } #[derive(Serialize, Deserialize, Debug, Clone)] @@ -827,4 +831,36 @@ isGlobal: true"#; "settings.temperature: invalid type: string \"not_a_number\", expected f32" ); } + + #[test] + fn test_format_serde_error_invalid_thinking_effort() { + let valid_content = r#"{ + "version": "1.0.0", + "title": "Test", + "description": "Test", + "instructions": "Test", + "settings": { + "thinking_effort": "high" + } + }"#; + let recipe = + Recipe::from_content(valid_content).expect("valid thinking_effort should parse"); + assert_eq!( + recipe.settings.as_ref().and_then(|s| s.thinking_effort), + Some(goose_providers::thinking::ThinkingEffort::High) + ); + + let content = r#"{ + "version": "1.0.0", + "title": "Test", + "description": "Test", + "instructions": "Test", + "settings": { + "thinking_effort": "bogus" + } + }"#; + + let result = Recipe::from_content(content); + assert!(result.is_err(), "bogus thinking_effort must fail to parse"); + } } diff --git a/crates/goose/src/recipe/validate_recipe.rs b/crates/goose/src/recipe/validate_recipe.rs index f7d3b52de5e2..9e8c2afabb6f 100644 --- a/crates/goose/src/recipe/validate_recipe.rs +++ b/crates/goose/src/recipe/validate_recipe.rs @@ -100,7 +100,7 @@ fn schema_field(node: SchemaNode, field: &str) -> Option { _ => None, }, SchemaNode::Settings => match field { - "goose_provider" | "goose_model" | "temperature" | "max_turns" => { + "goose_provider" | "goose_model" | "temperature" | "max_turns" | "thinking_effort" => { Some(SchemaNode::Scalar) } _ => None, diff --git a/crates/goose/tests/acp_server_test.rs b/crates/goose/tests/acp_server_test.rs index 766e5085c232..627c330ba5e6 100644 --- a/crates/goose/tests/acp_server_test.rs +++ b/crates/goose/tests/acp_server_test.rs @@ -907,6 +907,7 @@ fn test_new_session_honors_recipe_model_without_recipe_provider() { goose_model: Some(recipe_model.to_string()), temperature: None, max_turns: None, + thinking_effort: None, }) .build() .unwrap();