Skip to content
Merged
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
14 changes: 13 additions & 1 deletion .github/workflows/patched-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,25 @@ jobs:
"acp::turn_error::tests::turn_error_message_under_the_cap_is_kept_whole" \
"acp::turn_error::tests::turn_error_message_over_the_cap_is_cut_on_a_char_boundary" \
"acp::server::tests::test_authentication_message_maps_to_auth_required" \
"acp::server::tests::test_other_error_messages_map_to_internal_error"
"acp::server::tests::test_other_error_messages_map_to_internal_error" \
"acp::server::session_settings::tests::max_turns_from_meta_absent_or_null_is_default" \
"acp::server::session_settings::tests::max_turns_from_meta_accepts_positive_integer" \
"acp::server::session_settings::tests::max_turns_from_meta_rejects_invalid_values" \
"acp::server::session_settings::tests::cache_ttl_is_normalized_and_validated"

run_exact_tests --release -p goose --features "$F" --test acp_server_test -- \
"test_prompt_reports_context_error_when_compaction_limit_is_exhausted" \
"test_prompt_fails_and_streams_the_error" \
"test_manual_compaction_refusal_fails_without_replacing_context"

run_exact_tests --release -p goose --features "$F" --test acp_session_settings_test -- \
"test_session_settings_set_rejects_invalid_input" \
"test_session_settings_set_persists_and_survives_reload" \
"test_session_settings_set_activates_cold_session" \
"test_prompt_max_turns_bounds_run" \
"test_session_settings_idempotent_prompts_byte_identical" \
"test_session_settings_templated_recipe_renders_consistently"

run_exact_tests --release -p goose-provider-types --lib -- \
"formats::anthropic::tests::native_claude_thinking_carries_display_and_block_binding" \
"formats::anthropic::tests::summarized_thinking_round_trips_with_its_signature" \
Expand Down
3 changes: 3 additions & 0 deletions crates/goose-sdk-types/src/custom_requests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Modified by Jonathan Mohrbacher, 2026: register the session_settings custom request module.
use agent_client_protocol::schema::v1::{
AvailableCommand, ContentBlock, McpServer, Meta, SessionInfo,
};
Expand All @@ -10,6 +11,8 @@ mod recipe;
pub use recipe::*;
mod schedule;
pub use schedule::*;
mod session_settings;
pub use session_settings::*;

/// Schema descriptor for a single custom method, produced by the
/// `#[custom_methods]` macro's generated `custom_method_schemas()` function.
Expand Down
3 changes: 2 additions & 1 deletion crates/goose-sdk-types/src/custom_requests/recipe.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Modified by Jonathan Mohrbacher, 2026: accept jsonSchema alias in RecipeResponseDto.
use std::collections::HashMap;

use agent_client_protocol::{JsonRpcRequest, JsonRpcResponse};
Expand Down Expand Up @@ -82,7 +83,7 @@ pub struct RecipeSettingsDto {

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
pub struct RecipeResponseDto {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(default, alias = "jsonSchema", skip_serializing_if = "Option::is_none")]
pub json_schema: Option<serde_json::Value>,
}

Expand Down
26 changes: 26 additions & 0 deletions crates/goose-sdk-types/src/custom_requests/session_settings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Modified by Jonathan Mohrbacher, 2026: SetSessionSettingsRequest pins a session's cache TTL and recipe.
use agent_client_protocol::JsonRpcRequest;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use super::{EmptyResponse, RecipeDto};

/// Pin a session's prompt-cache TTL and recipe, persisted on the session row.
///
/// The recipe is stored on the session and read every turn: its `title`,
/// `instructions` and `response` take effect. Its `settings`, `extensions`,
/// `prompt` and `parameters` are ignored, `retry` and `sub_recipes` are
/// dropped, and the session keeps its model.
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(
method = "_goose/unstable/session/settings/set",
response = EmptyResponse
)]
#[serde(rename_all = "camelCase")]
pub struct SetSessionSettingsRequest {
pub session_id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cache_ttl: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub recipe: Option<RecipeDto>,
}
5 changes: 5 additions & 0 deletions crates/goose/acp-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
"requestType": "SetSessionSystemPromptRequest_unstable",
"responseType": "EmptyResponse"
},
{
"method": "_goose/unstable/session/settings/set",
"requestType": "SetSessionSettingsRequest_unstable",
"responseType": "EmptyResponse"
},
{
"method": "_goose/unstable/session/steer",
"requestType": "SteerSessionRequest_unstable",
Expand Down
39 changes: 39 additions & 0 deletions crates/goose/acp-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,36 @@
],
"description": "How a session system prompt update should be applied."
},
"SetSessionSettingsRequest_unstable": {
"type": "object",
"properties": {
"sessionId": {
"type": "string"
},
"cacheTtl": {
"type": [
"string",
"null"
]
},
"recipe": {
"anyOf": [
{
"$ref": "#/$defs/RecipeDto"
},
{
"type": "null"
}
]
}
},
"required": [
"sessionId"
],
"description": "Pin a session's prompt-cache TTL and recipe, persisted on the session row.\n\nThe recipe is stored on the session and read every turn: its `title`,\n`instructions` and `response` take effect. Its `settings`, `extensions`,\n`prompt` and `parameters` are ignored, `retry` and `sub_recipes` are\ndropped, and the session keeps its model.",
"x-side": "agent",
"x-method": "_goose/unstable/session/settings/set"
},
"SteerSessionRequest_unstable": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -7340,6 +7370,15 @@
"description": "Params for _goose/unstable/session/system-prompt/set",
"title": "SetSessionSystemPromptRequest_unstable"
},
{
"allOf": [
{
"$ref": "#/$defs/SetSessionSettingsRequest_unstable"
}
],
"description": "Params for _goose/unstable/session/settings/set",
"title": "SetSessionSettingsRequest_unstable"
},
{
"allOf": [
{
Expand Down
6 changes: 4 additions & 2 deletions crates/goose/src/acp/server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Modified by Jonathan Mohrbacher, 2026: session/prompt turn_failed errors carry data.kind and data.message.
// Modified by Jonathan Mohrbacher, 2026: session/prompt turn_failed errors carry data.kind and data.message; register session_settings (settings/set) and honour session/prompt _meta.goose.maxTurns.
use crate::acp::custom_notifications::*;
use crate::acp::custom_requests::*;
pub(super) use crate::acp::response_builder::{
Expand Down Expand Up @@ -123,6 +123,7 @@ mod providers;
mod recipe;
mod resources;
mod schedule;
mod session_settings;
mod slash_commands;
mod sources;
mod tool_calls;
Expand Down Expand Up @@ -2242,6 +2243,7 @@ impl AcpConnection {
cx: &ConnectionTo<Client>,
args: PromptRequest,
) -> Result<PromptResponse, agent_client_protocol::Error> {
let max_turns = session_settings::max_turns_from_meta(args.meta.as_ref())?;
// The ACP session_id IS the thread ID.
let session_id = args.session_id.0.to_string();

Expand Down Expand Up @@ -2290,7 +2292,7 @@ impl AcpConnection {
let session_config = SessionConfig {
id: session_id.clone(),
schedule_id: None,
max_turns: None,
max_turns,
};

let reply = self
Expand Down
9 changes: 9 additions & 0 deletions crates/goose/src/acp/server/custom_dispatch.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Modified by Jonathan Mohrbacher, 2026: dispatch _goose/unstable/session/settings/set.
use super::*;
use goose_acp_macros::custom_methods;

Expand Down Expand Up @@ -126,6 +127,14 @@ impl AcpConnection {
self.on_set_session_system_prompt(req).await
}

#[custom_method(SetSessionSettingsRequest)]
async fn dispatch_set_session_settings(
&self,
req: SetSessionSettingsRequest,
) -> Result<EmptyResponse, agent_client_protocol::Error> {
self.on_set_session_settings(req).await
}

#[custom_method(SteerSessionRequest)]
async fn dispatch_steer_session(
&self,
Expand Down
Loading
Loading