From 7143dddf732be1b259f2fde83f225b44d10caf71 Mon Sep 17 00:00:00 2001 From: Douwe Osinga Date: Wed, 21 Oct 2026 00:07:33 +0000 Subject: [PATCH] Automatic Thinking Level Operation (#12237) --- crates/goose-agent/src/inference.rs | 67 ++++- crates/goose-agent/src/machine.rs | 4 + crates/goose-agent/src/operation.rs | 8 + .../src/conversation/message.rs | 3 + crates/goose/src/acp/provider.rs | 41 ++- crates/goose/src/acp/server/message_meta.rs | 4 + crates/goose/src/agents/agent.rs | 133 ++++++++- crates/goose/src/agents/state_machine/mod.rs | 3 + .../agents/state_machine/ops_auto_effort.rs | 267 ++++++++++++++++++ .../goose/src/agents/state_machine/session.rs | 24 ++ .../src/agents/state_machine/tests/mod.rs | 213 +++++++++++++- .../agents/state_machine/tests/pipeline.rs | 88 +++++- .../goose/src/agents/state_machine_builder.rs | 3 + ui/desktop/src/acp/__tests__/config.test.ts | 18 ++ .../sessionNotificationAdapter.test.ts | 22 +- ui/desktop/src/acp/adapter/messages.ts | 7 + ui/desktop/src/acp/adapter/shared.ts | 5 + ui/desktop/src/acp/adapter/tools.ts | 8 +- ui/desktop/src/acp/config.ts | 16 +- .../src/components/GooseMessage.test.tsx | 37 +++ ui/desktop/src/components/GooseMessage.tsx | 59 +++- .../src/components/MessageUsageStats.test.tsx | 22 +- .../src/components/MessageUsageStats.tsx | 26 +- .../components/settings/AgentLoopSettings.tsx | 103 +++++++ .../forms/DefaultProviderSetupForm.tsx | 5 +- ui/desktop/src/i18n/messages/de.json | 21 ++ ui/desktop/src/i18n/messages/en.json | 21 ++ ui/desktop/src/i18n/messages/es.json | 21 ++ ui/desktop/src/i18n/messages/fr.json | 21 ++ ui/desktop/src/i18n/messages/hi.json | 21 ++ ui/desktop/src/i18n/messages/id.json | 21 ++ ui/desktop/src/i18n/messages/it.json | 21 ++ ui/desktop/src/i18n/messages/ja.json | 21 ++ ui/desktop/src/i18n/messages/ko.json | 21 ++ ui/desktop/src/i18n/messages/ms.json | 21 ++ ui/desktop/src/i18n/messages/pt.json | 21 ++ ui/desktop/src/i18n/messages/ru.json | 21 ++ ui/desktop/src/i18n/messages/tr.json | 21 ++ ui/desktop/src/i18n/messages/vi.json | 21 ++ ui/desktop/src/i18n/messages/zh-CN.json | 21 ++ ui/desktop/src/i18n/messages/zh-TW.json | 21 ++ ui/desktop/src/types/message.ts | 1 + 42 files changed, 1479 insertions(+), 44 deletions(-) create mode 100644 crates/goose/src/agents/state_machine/ops_auto_effort.rs create mode 100644 ui/desktop/src/acp/__tests__/config.test.ts create mode 100644 ui/desktop/src/components/GooseMessage.test.tsx diff --git a/crates/goose-agent/src/inference.rs b/crates/goose-agent/src/inference.rs index a9fec4f27..20c3a5df2 100644 --- a/crates/goose-agent/src/inference.rs +++ b/crates/goose-agent/src/inference.rs @@ -17,9 +17,10 @@ use goose_provider_types::errors::ProviderError; use goose_provider_types::model::ModelConfig; use tracing_futures::Instrument; +use crate::machine::MachineSession; use crate::operation::{ applied, messages_since_kickoff, not_applicable, trailing_error, Emitter, Inference, - InferenceInput, Operation, OperationResult, + InferenceInput, Operation, OperationResult, CLIENT_LOG, }; use goose_provider_types::maybe_send::{MaybeSend, MaybeSync}; @@ -114,6 +115,39 @@ fn drop_repeated_tool_call_thinking(accumulator: &Conversation, chunk: &mut Mess .retain(|content| !(is_thinking(content) && prior.contains(&content))); } +fn pending_operation_logs(messages: &[Message]) -> Vec { + let mut seen = messages + .iter() + .flat_map(|message| message.metadata.operation_logs.iter().cloned()) + .collect::>(); + let mut logs = Vec::new(); + + for (operation, line) in messages + .iter() + .filter_map(|message| message.metadata.operations.as_deref()) + .flat_map(|operations| operations.iter()) + .filter_map(|(operation, notes)| { + notes + .get(CLIENT_LOG) + .and_then(serde_json::Value::as_str) + .map(|line| (operation, line)) + }) + { + let log = format!("ops_{operation}: {line}"); + if seen.insert(log.clone()) { + logs.push(log); + } + } + + logs +} + +fn attach_operation_logs(message: &mut Message, logs: &mut Vec) { + if message.role == rmcp::model::Role::Assistant && !logs.is_empty() { + message.metadata.operation_logs = std::mem::take(logs); + } +} + pub fn chat_span( provider: &dyn Provider, model_config: &ModelConfig, @@ -347,10 +381,17 @@ impl<'a, S: MaybeSync, E: InferenceEffect> InferenceRunner<'a, S, E> { emit.message(message); } - fn error_outcome(&self, err: &ProviderError, emit: &Emitter) -> Result> { + fn error_outcome( + &self, + err: &ProviderError, + operation_logs: &mut Vec, + emit: &Emitter, + ) -> Result> { tracing::Span::current().record("error.type", err.telemetry_type()); tracing::error!("LLM provider error: {err}"); - self.emit_message(Message::from_provider_error(err), emit); + let mut message = Message::from_provider_error(err); + attach_operation_logs(&mut message, operation_logs); + self.emit_message(message, emit); applied(self.take_output()) } } @@ -374,7 +415,7 @@ impl Operation for InferenceRunner<'_, S #[cfg_attr(not(target_arch = "wasm32"), async_trait)] #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] -impl Inference for InferenceRunner<'_, S, E> { +impl Inference for InferenceRunner<'_, S, E> { fn applies(&self, conversation: &Conversation) -> bool { let Ok(turn) = messages_since_kickoff(conversation) else { return false; @@ -401,9 +442,14 @@ impl Inference for InferenceRunner<'_, S if !should_infer(conversation, messages) { return not_applicable(); } + let mut operation_logs = pending_operation_logs(messages); let mut messages_for_provider = messages_for_provider(conversation, messages, false); - let span = inference_span(self.provider.as_ref(), &self.model_config); + let model_config = session + .thinking_effort() + .map(|effort| self.model_config.clone().with_thinking_effort(effort)) + .unwrap_or_else(|| self.model_config.clone()); + let span = inference_span(self.provider.as_ref(), &model_config); async { let PreparedInferenceRequest { @@ -445,7 +491,7 @@ impl Inference for InferenceRunner<'_, S let stream = self .provider .stream( - &self.model_config, + &model_config, &system_prompt, conversation_for_provider.messages(), &tools, @@ -454,10 +500,10 @@ impl Inference for InferenceRunner<'_, S let mut stream = match stream { Ok(stream) => stream, - Err(err) => return self.error_outcome(&err, emit), + Err(err) => return self.error_outcome(&err, &mut operation_logs, emit), }; - let requested_model = self.model_config.model_name.clone(); + let requested_model = model_config.model_name.clone(); let resolved_model = self .provider .fetch_model_info(&requested_model) @@ -476,7 +522,7 @@ impl Inference for InferenceRunner<'_, S while let Some(result) = stream.next().await { let (msg_opt, usage_opt) = match result { Ok(chunk) => chunk, - Err(err) => return self.error_outcome(&err, emit), + Err(err) => return self.error_outcome(&err, &mut operation_logs, emit), }; if let Some(usage) = usage_opt { record_chat_usage(&tracing::Span::current(), &usage); @@ -498,6 +544,7 @@ impl Inference for InferenceRunner<'_, S if chunk.content.is_empty() && !chunk.metadata.output_token_limit_reached { self.output().accumulator.push(chunk); } else { + attach_operation_logs(&mut chunk, &mut operation_logs); self.emit_message(chunk, emit); } } @@ -525,6 +572,7 @@ impl Inference for InferenceRunner<'_, S let mut marker = Message::assistant() .with_text(EMPTY_RESPONSE_MESSAGE) .with_visibility(false, false); + attach_operation_logs(&mut marker, &mut operation_logs); marker.metadata.set_operation_note( EMPTY_RESPONSE_NOTE_SCOPE, EMPTY_RESPONSE_NOTE, @@ -545,6 +593,7 @@ impl Inference for InferenceRunner<'_, S message.content.clear(); message.metadata.user_visible = false; message.metadata.agent_visible = true; + attach_operation_logs(&mut message, &mut operation_logs); output.accumulator.clear(); message }; diff --git a/crates/goose-agent/src/machine.rs b/crates/goose-agent/src/machine.rs index 423bdc6d9..7d0c1d317 100644 --- a/crates/goose-agent/src/machine.rs +++ b/crates/goose-agent/src/machine.rs @@ -14,10 +14,14 @@ use crate::operation::{ use goose_provider_types::conversation::message::{Message, MessageContent}; use goose_provider_types::conversation::Conversation; use goose_provider_types::maybe_send::{MaybeSend, MaybeSync}; +use goose_provider_types::thinking::ThinkingEffort; pub trait MachineSession: MaybeSend + MaybeSync { fn id(&self) -> &str; fn conversation(&self) -> Option<&Conversation>; + fn thinking_effort(&self) -> Option { + None + } } #[cfg_attr(not(target_arch = "wasm32"), async_trait)] diff --git a/crates/goose-agent/src/operation.rs b/crates/goose-agent/src/operation.rs index fbfc922e3..902b36f54 100644 --- a/crates/goose-agent/src/operation.rs +++ b/crates/goose-agent/src/operation.rs @@ -24,6 +24,8 @@ pub type OperationStream<'a, T> = Pin + Send + 'a>>; #[cfg(target_arch = "wasm32")] pub type OperationStream<'a, T> = Pin + 'a>>; +pub const CLIENT_LOG: &str = "client_log"; + pub struct SlashCommand<'a> { pub command: &'a str, pub params_str: &'a str, @@ -230,6 +232,12 @@ pub enum ConversationEffect { tool_call_id: String, patch: serde_json::Value, }, + SetMessageOperationNote { + message_id: String, + operation: String, + key: String, + value: serde_json::Value, + }, SetMessageVisibility { message_id: String, user_visible: bool, diff --git a/crates/goose-provider-types/src/conversation/message.rs b/crates/goose-provider-types/src/conversation/message.rs index 76719c2f2..a545854ad 100644 --- a/crates/goose-provider-types/src/conversation/message.rs +++ b/crates/goose-provider-types/src/conversation/message.rs @@ -846,6 +846,8 @@ pub struct MessageMetadata { pub turn_context: bool, #[serde(default, skip_serializing_if = "Option::is_none")] pub usage: Option>, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub operation_logs: Vec, /// What an operation did to this message, keyed by operation name. Read back /// from the persisted conversation so a rebuilt pipeline knows what already /// happened. Never sent to providers. @@ -863,6 +865,7 @@ impl Default for MessageMetadata { steer: false, turn_context: false, usage: None, + operation_logs: Vec::new(), operations: None, } } diff --git a/crates/goose/src/acp/provider.rs b/crates/goose/src/acp/provider.rs index 308f5bc35..df1d67713 100644 --- a/crates/goose/src/acp/provider.rs +++ b/crates/goose/src/acp/provider.rs @@ -700,7 +700,20 @@ impl Provider for AcpProvider { .load_session(SessionId::new(session_id)) .await .map_err(|error| ProviderError::RequestFailed(error.to_string()))?; + let applied_model = self.model_config_option_id.as_ref().and_then(|config_id| { + loaded + .response + .config_options + .as_deref()? + .iter() + .find(|option| option.id.0.as_ref() == config_id.as_str()) + .and_then(|option| match &option.kind { + SessionConfigKind::Select(select) => Some(select.current_value.0.to_string()), + _ => None, + }) + }); *self.session.lock().unwrap() = loaded; + *self.applied_model.lock().unwrap() = applied_model; self.handoff_context_sent.store(true, Ordering::Release); let _ = self .tx @@ -2281,7 +2294,7 @@ fn replace_effort_state( /// and the agent share pass through; goose's own enum values map onto their /// closest agent equivalent. Anything else yields `None` so we never send a /// value the agent would reject. -pub(super) fn map_effort_value( +pub(crate) fn map_effort_value( capability: &ThinkingEffortCapability, value: &str, ) -> Option { @@ -2861,8 +2874,8 @@ mod tests { #[tokio::test] async fn resume_replaces_session_and_skips_handoff() { - let (tx, mut rx) = mpsc::channel(2); - let (provider, _) = test_provider_with_tx(Some(tx)); + let (tx, mut rx) = mpsc::channel(3); + let provider = test_provider_with_model_option(tx, Some("configured-model".to_string())); let handle = tokio::spawn(async move { provider.resume("saved-session").await.unwrap(); @@ -2878,7 +2891,15 @@ mod tests { }; assert_eq!(session_id.to_string(), "saved-session"); response_tx - .send(Ok(NewSessionResponse::new("saved-session"))) + .send(Ok(NewSessionResponse::new("saved-session").config_options( + vec![SessionConfigOption::select( + "model", + "Model", + "session-model", + effort_select_options(&["session-model", "configured-model"]), + ) + .category(SessionConfigOptionCategory::Model)], + ))) .unwrap(); let ClientRequest::CloseSession { session_id } = @@ -2901,6 +2922,18 @@ mod tests { let claim = provider.claim_handoff_context(&messages); assert!(!claim.first_prompt); assert!(!claim.include_context); + + let handle = tokio::spawn(async move { + provider + .apply_model_if_changed("configured-model") + .await + .unwrap(); + }); + assert_eq!( + expect_set_config_option(&mut rx).await, + ("model".to_string(), "configured-model".to_string()) + ); + handle.await.unwrap(); } #[tokio::test] diff --git a/crates/goose/src/acp/server/message_meta.rs b/crates/goose/src/acp/server/message_meta.rs index d96882f21..afb3046d3 100644 --- a/crates/goose/src/acp/server/message_meta.rs +++ b/crates/goose/src/acp/server/message_meta.rs @@ -19,6 +19,8 @@ struct GooseMessageMeta<'a> { fallback_content: bool, #[serde(skip_serializing_if = "Option::is_none")] inference: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + operation_logs: Option<&'a [String]>, } // The provider session id stays on the server: clients only need to know which model answered. @@ -50,6 +52,8 @@ fn goose_message_meta( requested_model: &inference.requested_model, resolved_model: inference.resolved_model.as_deref(), }), + operation_logs: (!message.metadata.operation_logs.is_empty()) + .then_some(message.metadata.operation_logs.as_slice()), }; match serde_json::to_value(message_meta) { diff --git a/crates/goose/src/agents/agent.rs b/crates/goose/src/agents/agent.rs index 16ae009ac..6086914c8 100644 --- a/crates/goose/src/agents/agent.rs +++ b/crates/goose/src/agents/agent.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use std::fmt; use std::sync::Arc; +use std::time::Duration; use anyhow::{anyhow, Context, Result}; use futures::stream::BoxStream; @@ -19,7 +20,8 @@ use crate::agents::provider_manager::ProviderManager; use crate::agents::state_machine::ops_recipe; use crate::agents::state_machine::{ has_unapplied_tool_confirmation_response, pending_tool_confirmations, - persist_tool_confirmation_decision, run_goose, Emitter, GooseEffect, StateMachine, SteerQueue, + persist_tool_confirmation_decision, run_goose, AutoEffortOperation, Emitter, GooseEffect, + Operation, StateMachine, SteerQueue, }; use crate::agents::state_machine_builder::{build_state_machine, StateMachineConfig}; use crate::agents::subagent_handler::ForegroundSubagentRunner; @@ -41,8 +43,10 @@ use crate::security::security_inspector::SecurityInspector; use crate::session::{Session, SessionManager, SessionNameUpdate}; use crate::tool_inspection::ToolInspectionManager; use crate::tool_monitor::RepetitionInspector; +use goose_providers::api_client::{ApiClient, AuthMethod}; use goose_providers::errors::ProviderError; use goose_providers::thinking::{ThinkingEffort, ThinkingEffortSupport}; +use goose_providers::typesafe::{TypeSafeProvider, TYPESAFE_DEFAULT_HOST, TYPESAFE_DEFAULT_MODEL}; use rmcp::model::{ElicitationAction, GetPromptResult, Prompt, Tool}; use serde_json::Value; use tokio::sync::{mpsc, Mutex}; @@ -50,6 +54,65 @@ use tokio_util::sync::CancellationToken; use tracing::{error, instrument, warn}; const DEFAULT_STOP_HOOK_BLOCK_CAP: u32 = 8; +const AUTO_EFFORTS: [ThinkingEffort; 5] = [ + ThinkingEffort::Off, + ThinkingEffort::Low, + ThinkingEffort::Medium, + ThinkingEffort::High, + ThinkingEffort::Max, +]; + +pub(super) fn available_auto_efforts( + provider_name: &str, + model_config: &goose_providers::model::ModelConfig, + support: ThinkingEffortSupport, +) -> Vec { + let applied_as_selected = |effort: &ThinkingEffort, applied: Option| match effort { + ThinkingEffort::Off => applied.as_deref() == Some("none"), + ThinkingEffort::Low => applied.as_deref() == Some("low"), + ThinkingEffort::Medium => applied.as_deref() == Some("medium"), + ThinkingEffort::High => applied.as_deref() == Some("high"), + ThinkingEffort::Max => matches!(applied.as_deref(), Some("xhigh" | "max")), + }; + + match support { + ThinkingEffortSupport::Unspecified + if provider_name == goose_providers::openai::OPEN_AI_PROVIDER_NAME + && model_config.is_openai_reasoning_model() => + { + AUTO_EFFORTS + .into_iter() + .filter(|effort| { + applied_as_selected( + effort, + goose_providers::formats::openai::openai_reasoning_effort_for_thinking( + &model_config.model_name, + *effort, + ), + ) + }) + .collect() + } + ThinkingEffortSupport::Unspecified + if provider_name == goose_providers::formats::anthropic::ANTHROPIC_PROVIDER_NAME + && model_config.is_reasoning_model() => + { + let always_on = goose_providers::canonical::maybe_get_canonical_model( + provider_name, + &model_config.model_name, + ) + .and_then(|model| model.thinking_mode) + == Some(goose_providers::canonical::ThinkingMode::AlwaysOnAdaptive); + AUTO_EFFORTS + .into_iter() + .filter(|effort| !always_on || *effort != ThinkingEffort::Off) + .collect() + } + ThinkingEffortSupport::Unspecified + | ThinkingEffortSupport::Unsupported + | ThinkingEffortSupport::Options(_) => Vec::new(), + } +} fn provider_creation_error(error: anyhow::Error, context: impl fmt::Display) -> anyhow::Error { let message = format!("{context}: {error}"); @@ -591,6 +654,48 @@ impl Agent { crate::context_mgmt::compute_tool_call_cutoff(context_limit, compaction_threshold) }); + let auto_effort = (|| { + let config = Config::global(); + if !config + .get_param::("GOOSE_AUTO_EFFORT_ENABLED") + .unwrap_or(false) + { + return None; + } + + let efforts = available_auto_efforts( + provider.get_name(), + &model_config, + provider.thinking_effort_support(), + ); + if efforts.is_empty() { + return None; + } + + let api_key = config + .get_secret::("TYPESAFE_API_KEY") + .ok()? + .trim() + .to_string(); + if api_key.is_empty() { + return None; + } + + let tls_config = crate::config::tls::provider_tls_config_from_config(config).ok()?; + let api_client = ApiClient::with_timeout_and_tls( + TYPESAFE_DEFAULT_HOST.to_string(), + AuthMethod::BearerToken(api_key), + Duration::from_secs(2), + tls_config, + ) + .ok()?; + Some(Arc::new(AutoEffortOperation::new( + Arc::new(TypeSafeProvider::new(api_client)), + TYPESAFE_DEFAULT_MODEL.to_string(), + efforts, + )) as Arc>) + })(); + build_state_machine(StateMachineConfig { provider, model_config, @@ -609,6 +714,7 @@ impl Agent { on_failure_timeout: std::time::Duration::from_secs(on_failure_timeout), stop_hook_block_cap, max_turns, + extra_operations: auto_effort.into_iter().collect(), cancel, }) } @@ -866,6 +972,31 @@ impl Agent { let provider = self.provider(&session_id).await?; let model_config = self.effective_model_config_for_session(&session_id).await?; + let session = session_manager.get_session(&session_id, true).await?; + let saved_provider_session_id = session + .conversation + .as_ref() + .and_then(|conversation| { + super::latest_provider_session_id(conversation.messages(), provider.get_name()) + }) + .map(str::to_string); + if let Some(saved_provider_session_id) = saved_provider_session_id { + if let Err(error) = provider.resume(&saved_provider_session_id).await { + warn!( + provider = provider.get_name(), + %error, + "Could not resume provider session; continuing with a handoff" + ); + } + } + if let Err(error) = provider.apply_model_selection(&model_config).await { + warn!( + provider = provider.get_name(), + %error, + "Could not apply model selection before building state machine" + ); + } + let context_limit = crate::context_limit::get_context_limit(provider.as_ref(), &model_config.model_name) .await?; diff --git a/crates/goose/src/agents/state_machine/mod.rs b/crates/goose/src/agents/state_machine/mod.rs index 41aea4dc6..8051e4c02 100644 --- a/crates/goose/src/agents/state_machine/mod.rs +++ b/crates/goose/src/agents/state_machine/mod.rs @@ -7,6 +7,7 @@ mod effects; mod inference_preparation; +mod ops_auto_effort; mod ops_bang_shell; mod ops_compaction; mod ops_doctor; @@ -44,6 +45,7 @@ pub use goose_agent::operation::{ applied, assistant_turn_count, ends_turn, last_effective_role, messages_since_kickoff, not_applicable, trailing_error, yielded, yielded_with, ConversationEffect, Emitter, Inference, InferenceInput, MachineEffect, Operation, OperationResult, RunStatus, SlashCommand, StepResult, + CLIENT_LOG, }; pub(super) use goose_agent::subagent::SubagentOperation; pub(crate) use tool_confirmation::{ @@ -52,6 +54,7 @@ pub(crate) use tool_confirmation::{ }; pub(super) use inference_preparation::GooseInferenceRequestPreparer; +pub(super) use ops_auto_effort::AutoEffortOperation; pub(super) use ops_bang_shell::BangShellOperation; pub(super) use ops_compaction::CompactionOperation; pub(super) use ops_doctor::DoctorOperation; diff --git a/crates/goose/src/agents/state_machine/ops_auto_effort.rs b/crates/goose/src/agents/state_machine/ops_auto_effort.rs new file mode 100644 index 000000000..568f7ce92 --- /dev/null +++ b/crates/goose/src/agents/state_machine/ops_auto_effort.rs @@ -0,0 +1,267 @@ +use std::collections::HashMap; +use std::sync::Arc; + +use anyhow::{anyhow, Result}; +use async_trait::async_trait; +use goose_providers::conversation::{effective_role, Conversation, EffectiveRole}; +use goose_providers::decision::{ + DecisionAnswer, DecisionProvider, DecisionQuestion, DecisionRequest, +}; +use goose_providers::thinking::ThinkingEffort; +use serde::{Deserialize, Serialize}; + +use super::{ + applied, last_effective_role, messages_since_kickoff, not_applicable, ConversationEffect, + Emitter, GooseEffect, Operation, OperationResult, CLIENT_LOG, +}; +use crate::session::Session; + +const DECISION: &str = "decision"; +const OPERATION: &str = "auto_effort"; + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +struct EffortDecision { + effort: Option, + model: Option, + confidence: Option, + probabilities: HashMap, +} + +impl EffortDecision { + fn fallback() -> Self { + Self { + effort: None, + model: None, + confidence: None, + probabilities: HashMap::new(), + } + } +} + +pub struct AutoEffortOperation { + provider: Arc, + model: String, + efforts: Vec, +} + +impl AutoEffortOperation { + pub(crate) fn new( + provider: Arc, + model: String, + efforts: Vec, + ) -> Self { + Self { + provider, + model, + efforts, + } + } + + async fn classify(&self, request: &str) -> Result { + let criteria = self + .efforts + .iter() + .map(|effort| { + let description = match effort { + ThinkingEffort::Off => { + "No reasoning is needed, such as a greeting or a direct factual response." + } + ThinkingEffort::Low => { + "A small amount of reasoning is enough for a simple, well-scoped task." + } + ThinkingEffort::Medium => { + "The task needs several reasoning steps or ordinary coding work." + } + ThinkingEffort::High => { + "The task is complex, ambiguous, or needs careful planning and verification." + } + ThinkingEffort::Max => { + "The task is exceptionally difficult or high stakes and benefits from the deepest available reasoning." + } + }; + (effort.to_string(), description.to_string()) + }) + .collect(); + let mut response = self + .provider + .create_decision(&DecisionRequest { + model: self.model.clone(), + state: request.into(), + questions: HashMap::from([( + "effort".to_string(), + DecisionQuestion::Choice { + instructions: + "Choose the least thinking effort that can reliably handle this request." + .to_string(), + criteria, + }, + )]), + }) + .await?; + let answer = response + .answers + .remove("effort") + .ok_or_else(|| anyhow!("decision provider returned no effort answer"))?; + let DecisionAnswer::Choice { + choice, + confidence, + probabilities, + } = answer + else { + return Err(anyhow!( + "decision provider returned a non-choice effort answer" + )); + }; + let effort = choice.parse().map_err(anyhow::Error::msg)?; + if !self.efforts.contains(&effort) { + return Err(anyhow!( + "decision provider returned unavailable effort '{effort}'" + )); + } + + Ok(EffortDecision { + effort: Some(effort), + model: Some(response.model), + confidence: Some(confidence), + probabilities, + }) + } +} + +fn classification_request(messages: &[crate::conversation::message::Message]) -> String { + let kickoff = &messages[0]; + let kickoff_text = kickoff.as_concat_text(); + if crate::agents::execute_commands::parse_slash_command(&kickoff_text) + .is_some_and(|command| matches!(command.command, "doctor" | "prompt")) + { + return kickoff_text; + } + + messages + .iter() + .rev() + .filter(|message| message.is_agent_visible()) + .find_map(|message| { + let message = message.agent_visible_content(); + matches!(effective_role(&message), EffectiveRole::User) + .then(|| message.as_concat_text()) + }) + .unwrap_or_default() +} + +pub(super) fn current_turn_effort(conversation: &Conversation) -> Option { + let decision = messages_since_kickoff(conversation) + .ok()? + .first()? + .metadata + .operation_note(OPERATION, DECISION)?; + serde_json::from_value::(decision.clone()) + .ok()? + .effort +} + +#[async_trait] +impl Operation for AutoEffortOperation { + fn name(&self) -> &'static str { + OPERATION + } + + async fn run( + &self, + _session: &Session, + conversation: &Conversation, + emit: &Emitter, + ) -> Result> { + let messages = messages_since_kickoff(conversation)?; + let kickoff = &messages[0]; + if self.message_meta(kickoff, DECISION).is_some() + || !matches!( + last_effective_role(messages)?, + EffectiveRole::User | EffectiveRole::Tool + ) + { + return not_applicable(); + } + + let request = classification_request(messages); + if request.trim().is_empty() { + return not_applicable(); + } + + let decision = tokio::select! { + _ = emit.cancelled() => return not_applicable(), + result = self.classify(&request) => match result { + Ok(decision) => decision, + Err(error) => { + tracing::warn!(%error, "Automatic effort selection failed; using configured effort"); + EffortDecision::fallback() + } + } + }; + let Some(message_id) = kickoff.id.clone() else { + return not_applicable(); + }; + + let mut effects = Vec::new(); + let client_log = decision.effort.map(|effort| format!("thinking {effort}")); + effects.push( + ConversationEffect::SetMessageOperationNote { + message_id: message_id.clone(), + operation: self.name().to_string(), + key: DECISION.to_string(), + value: serde_json::to_value(decision)?, + } + .into(), + ); + if let Some(client_log) = client_log { + effects.push( + ConversationEffect::SetMessageOperationNote { + message_id, + operation: self.name().to_string(), + key: CLIENT_LOG.to_string(), + value: client_log.into(), + } + .into(), + ); + } + + applied(effects) + } +} + +#[cfg(test)] +mod tests { + use super::classification_request; + use crate::conversation::message::Message; + + #[test] + fn doctor_classifies_the_typed_command_instead_of_diagnostics() { + let messages = vec![ + Message::user() + .with_text("/doctor") + .with_visibility(true, false), + Message::user() + .with_text("system info and private logs") + .with_visibility(false, true), + ]; + + assert_eq!(classification_request(&messages), "/doctor"); + } + + #[test] + fn prompt_classifies_the_typed_command_instead_of_extension_content() { + let messages = vec![ + Message::user() + .with_text("/prompt private-context topic=rust") + .with_visibility(true, false), + Message::user() + .with_text("extension content containing a credential") + .with_visibility(false, true), + ]; + + assert_eq!( + classification_request(&messages), + "/prompt private-context topic=rust" + ); + } +} diff --git a/crates/goose/src/agents/state_machine/session.rs b/crates/goose/src/agents/state_machine/session.rs index 37f092c29..c620a7d71 100644 --- a/crates/goose/src/agents/state_machine/session.rs +++ b/crates/goose/src/agents/state_machine/session.rs @@ -11,6 +11,8 @@ use crate::session::{Session, SessionManager}; use goose_agent::machine::{EffectHandler, EffectUsage, MachineSession, SessionLoader}; use goose_agent::operation::{ConversationEffect, Emitter, MachineEffect}; +use super::ops_auto_effort::current_turn_effort; + fn contains_tool_confirmation_request(message: &Message) -> bool { message.content.iter().any(|content| { matches!( @@ -27,6 +29,16 @@ impl MachineSession for Session { fn conversation(&self) -> Option<&Conversation> { self.conversation.as_ref() } + fn thinking_effort(&self) -> Option { + self.conversation + .as_ref() + .and_then(current_turn_effort) + .or_else(|| { + self.model_config + .as_ref() + .and_then(|config| config.thinking_effort()) + }) + } } #[async_trait] @@ -84,6 +96,18 @@ impl EffectHandler for SessionManager { self.update_tool_request_meta(&session.id, tool_call_id, patch.clone()) .await?; } + GooseEffect::Conversation(ConversationEffect::SetMessageOperationNote { + message_id, + operation, + key, + value, + }) => { + self.update_message_metadata(&session.id, message_id, |mut metadata| { + metadata.set_operation_note(operation, key, value.clone()); + metadata + }) + .await?; + } GooseEffect::Conversation(ConversationEffect::SetMessageVisibility { message_id, user_visible, diff --git a/crates/goose/src/agents/state_machine/tests/mod.rs b/crates/goose/src/agents/state_machine/tests/mod.rs index 49550fac6..33d5bc4bc 100644 --- a/crates/goose/src/agents/state_machine/tests/mod.rs +++ b/crates/goose/src/agents/state_machine/tests/mod.rs @@ -201,13 +201,168 @@ async fn max_turns_counts_inference_calls_and_injects_budget() -> Result<()> { } #[tokio::test] -async fn turn_context_is_persisted_once_per_turn_and_reused_across_inferences() -> Result<()> { +async fn auto_effort_is_scoped_to_each_turn_and_reused_across_inferences() -> Result<()> { + use std::sync::Arc; + + use goose_providers::api_client::{ApiClient, AuthMethod}; + use goose_providers::model::ModelConfig; + use goose_providers::thinking::{ThinkingEffort, ThinkingEffortSupport}; + use goose_providers::typesafe::TypeSafeProvider; + use serde_json::json; + use wiremock::matchers::{body_partial_json, header, method, path}; + use wiremock::{Mock, MockServer, ResponseTemplate}; + + use crate::agents::agent::available_auto_efforts; + use crate::agents::state_machine::AutoEffortOperation; + let (pipeline, api) = test_pipeline().await?; + let skill_dir = pipeline + .working_dir() + .join(".agents/skills/auto-effort-review"); + std::fs::create_dir_all(&skill_dir)?; + std::fs::write( + skill_dir.join("SKILL.md"), + "---\nname: auto-effort-review\ndescription: Review helper\n---\nReview the expanded request carefully.\n", + )?; + let skill = crate::skills::list_installed_skills(Some(pipeline.working_dir())) + .into_iter() + .find(|skill| skill.name == "auto-effort-review") + .expect("project skill should be installed"); + let expanded_skill_prompt = crate::skills::loaded_skill_context_with_args(&skill, None)?; + + let jev = MockServer::start().await; + for (request, effort) in [ + ("add one", "high"), + (expanded_skill_prompt.as_str(), "high"), + ("hello", "off"), + ] { + let probabilities = std::collections::HashMap::from([(effort, 0.9)]); + Mock::given(method("POST")) + .and(path("/v1/systemone")) + .and(header("authorization", "Bearer test-key")) + .and(body_partial_json(json!({ + "model": "test-effort-model", + "state": request + }))) + .respond_with(ResponseTemplate::new(200).set_body_json(json!({ + "model": "jev-latest", + "answers": { + "effort": { + "type": "choice", + "choice": effort, + "confidence": 0.9, + "probabilities": probabilities + } + }, + "usage": {"input_tokens": 12, "output_tokens": 3} + }))) + .expect(1) + .mount(&jev) + .await; + } + Mock::given(method("POST")) + .and(path("/v1/systemone")) + .and(header("authorization", "Bearer test-key")) + .and(body_partial_json(json!({ + "model": "test-effort-model", + "state": "fallback" + }))) + .respond_with(ResponseTemplate::new(500)) + .expect(1) + .mount(&jev) + .await; + + let decision_provider = TypeSafeProvider::new(ApiClient::new_with_tls( + jev.uri(), + AuthMethod::BearerToken("test-key".to_string()), + None, + )?); + let efforts = vec![ThinkingEffort::Off, ThinkingEffort::High]; + assert_eq!( + available_auto_efforts( + "openai", + &ModelConfig::new("gpt-5-pro"), + ThinkingEffortSupport::Unspecified, + ), + vec![ThinkingEffort::High] + ); + assert_eq!( + available_auto_efforts( + "anthropic", + &ModelConfig::new("claude-opus-5-5").with_canonical_limits("anthropic"), + ThinkingEffortSupport::Unspecified, + ), + vec![ + ThinkingEffort::Low, + ThinkingEffort::Medium, + ThinkingEffort::High, + ThinkingEffort::Max, + ] + ); + assert!(available_auto_efforts( + "claude-acp", + &ModelConfig::new("current"), + ThinkingEffortSupport::Options(goose_providers::thinking::ThinkingEffortCapability { + option_id: "effort".to_string(), + values: vec![goose_providers::thinking::ThinkingEffortOption { + value: "high".to_string(), + label: "High".to_string(), + }], + current: Some("high".to_string()), + }), + ) + .is_empty()); + for (provider, model) in [ + ("snowflake", "openai-gpt-5"), + ("snowflake", "claude-sonnet-4-5"), + ("zhipu", "glm-5.3"), + ("ollama", "qwen3"), + ] { + assert!(available_auto_efforts( + provider, + &ModelConfig::new(model), + ThinkingEffortSupport::Unspecified, + ) + .is_empty()); + } + let pipeline = pipeline + .with_model_config( + ModelConfig::new(goose_providers::openai::OPEN_AI_DEFAULT_MODEL) + .with_canonical_limits("openai") + .with_thinking_effort(ThinkingEffort::Low), + ) + .await + .record_model_configs() + .with_operation(Arc::new(AutoEffortOperation::new( + Arc::new(decision_provider), + "test-effort-model".to_string(), + efforts, + ))); api.on("add one").call(ADD, value(1)); api.on("result: 1").reply("The total is 1"); + api.on("Review the expanded request carefully") + .reply("reviewed"); api.on("hello").reply("hi there!"); + api.on("fallback").reply("using configured effort"); - let result = pipeline.run(["add one", "hello"]).await?; + let result = pipeline + .run(["add one", "/auto-effort-review", "hello", "fallback"]) + .await?; + + let requests = jev + .received_requests() + .await + .expect("requests should be recorded"); + assert_eq!(requests.len(), 4); + for request in requests { + let body: serde_json::Value = serde_json::from_slice(&request.body)?; + let criteria = body["questions"]["effort"]["criteria"] + .as_object() + .expect("effort criteria should be an object"); + assert_eq!(criteria.len(), 2); + assert!(criteria.contains_key("off")); + assert!(criteria.contains_key("high")); + } let conversation = result.conversation(); let events: Vec<_> = conversation @@ -217,7 +372,7 @@ async fn turn_context_is_persisted_once_per_turn_and_reused_across_inferences() .collect(); assert_eq!( events.len(), - 2, + 4, "one turn-context event per turn; the turn's second inference reuses it" ); assert!(events.iter().all(|event| !event.is_user_visible())); @@ -225,6 +380,58 @@ async fn turn_context_is_persisted_once_per_turn_and_reused_across_inferences() .calls() .iter() .all(|call| call.input_contains(""))); + assert_eq!( + pipeline.recorded_efforts(), + vec![ + Some(ThinkingEffort::High), + Some(ThinkingEffort::High), + Some(ThinkingEffort::High), + Some(ThinkingEffort::Off), + Some(ThinkingEffort::Low), + ] + ); + + let decisions: Vec<_> = conversation + .messages() + .iter() + .filter_map(|message| message.metadata.operation_note("auto_effort", "decision")) + .collect(); + assert_eq!(decisions.len(), 4); + assert_eq!(decisions[0]["effort"], "high"); + assert_eq!(decisions[0]["probabilities"]["high"], 0.9); + assert_eq!(decisions[1]["effort"], "high"); + assert_eq!(decisions[2]["effort"], "off"); + assert!(decisions[3]["effort"].is_null()); + + let logged_messages: Vec<_> = conversation + .messages() + .iter() + .filter(|message| !message.metadata.operation_logs.is_empty()) + .collect(); + assert_eq!(logged_messages.len(), 3); + assert_eq!( + logged_messages[0].metadata.operation_logs, + ["ops_auto_effort: thinking high"] + ); + assert_eq!( + logged_messages[1].metadata.operation_logs, + ["ops_auto_effort: thinking high"] + ); + assert_eq!( + logged_messages[2].metadata.operation_logs, + ["ops_auto_effort: thinking off"] + ); + assert!(logged_messages[0].is_tool_call()); + assert_eq!(logged_messages[1].as_concat_text(), "reviewed"); + assert_eq!(logged_messages[2].as_concat_text(), "hi there!"); + assert_eq!( + result + .session + .model_config + .as_ref() + .and_then(|config| config.thinking_effort()), + Some(ThinkingEffort::Low) + ); Ok(()) } diff --git a/crates/goose/src/agents/state_machine/tests/pipeline.rs b/crates/goose/src/agents/state_machine/tests/pipeline.rs index 570ee0242..cbfea4890 100644 --- a/crates/goose/src/agents/state_machine/tests/pipeline.rs +++ b/crates/goose/src/agents/state_machine/tests/pipeline.rs @@ -15,7 +15,7 @@ use crate::agents::extension_manager::{ }; use crate::agents::mcp_client::McpClientTrait; use crate::agents::state_machine::{ - messages_since_kickoff, Emitter, GooseEffect, RunStatus, StateMachine, SteerQueue, + messages_since_kickoff, Emitter, GooseEffect, Operation, RunStatus, StateMachine, SteerQueue, }; use crate::agents::state_machine_builder::{build_state_machine, StateMachineConfig}; use crate::agents::subagent_handler::ForegroundSubagentRunner; @@ -33,12 +33,64 @@ use crate::session::extension_data::EnabledExtensionsState; use crate::session::{GoalState, Session, SessionManager, SessionType}; use crate::tool_inspection::ToolInspectionManager; use goose_providers::model::ModelConfig; +use goose_providers::thinking::ThinkingEffort; struct FeatureProvider { inner: Arc, features: ProviderFeatures, } +struct RecordingProvider { + inner: Arc, + model_configs: Arc>>, +} + +#[async_trait::async_trait] +impl Provider for RecordingProvider { + fn get_name(&self) -> &str { + self.inner.get_name() + } + + fn provider_session_id(&self) -> Option { + self.inner.provider_session_id() + } + + async fn resume(&self, session_id: &str) -> Result<(), goose_providers::errors::ProviderError> { + self.inner.resume(session_id).await + } + + async fn stream( + &self, + model_config: &ModelConfig, + system: &str, + messages: &[Message], + tools: &[rmcp::model::Tool], + ) -> Result { + self.model_configs + .lock() + .unwrap() + .push(model_config.clone()); + self.inner + .stream(model_config, system, messages, tools) + .await + } + + async fn get_context_limit(&self, model: &str, override_limit: Option) -> usize { + self.inner.get_context_limit(model, override_limit).await + } + + fn manages_own_context(&self) -> bool { + self.inner.manages_own_context() + } + + async fn fetch_model_info( + &self, + model_name: &str, + ) -> Result { + self.inner.fetch_model_info(model_name).await + } +} + #[async_trait::async_trait] impl Provider for FeatureProvider { fn get_name(&self) -> &str { @@ -99,6 +151,8 @@ pub(super) struct TestPipeline { max_turns: u32, scheduler: Option>, subagent_host: Arc, + extra_operations: Vec>>, + recorded_model_configs: Option>>>, _temp_dir: Arc, } @@ -129,6 +183,7 @@ impl TestPipeline { on_failure_timeout: std::time::Duration::from_secs(1), stop_hook_block_cap: self.stop_hook_block_cap, max_turns: self.max_turns, + extra_operations: self.extra_operations.clone(), cancel, }) } @@ -183,6 +238,35 @@ impl TestPipeline { self } + pub(super) fn with_operation( + mut self, + operation: Arc>, + ) -> Self { + self.extra_operations.push(operation); + self + } + + pub(super) fn record_model_configs(mut self) -> Self { + let model_configs = Arc::new(StdMutex::new(Vec::new())); + self.provider = Arc::new(RecordingProvider { + inner: self.provider, + model_configs: model_configs.clone(), + }); + self.recorded_model_configs = Some(model_configs); + self + } + + pub(super) fn recorded_efforts(&self) -> Vec> { + self.recorded_model_configs + .as_ref() + .expect("model config recording was not enabled") + .lock() + .unwrap() + .iter() + .map(ModelConfig::thinking_effort) + .collect() + } + pub(super) fn working_dir(&self) -> &std::path::Path { &self.working_dir } @@ -787,6 +871,8 @@ async fn build_test_pipeline( max_turns: MAX_TURNS, scheduler, subagent_host, + extra_operations: Vec::new(), + recorded_model_configs: None, _temp_dir: temp_dir, }; let extension_manager = pipeline.extension_manager.clone(); diff --git a/crates/goose/src/agents/state_machine_builder.rs b/crates/goose/src/agents/state_machine_builder.rs index 27cb5f30c..fd9972f61 100644 --- a/crates/goose/src/agents/state_machine_builder.rs +++ b/crates/goose/src/agents/state_machine_builder.rs @@ -39,6 +39,7 @@ pub(crate) struct StateMachineConfig<'a> { pub(crate) on_failure_timeout: Duration, pub(crate) stop_hook_block_cap: u32, pub(crate) max_turns: u32, + pub(crate) extra_operations: Vec>>, pub(crate) cancel: CancellationToken, } @@ -63,6 +64,7 @@ pub(crate) fn build_state_machine( on_failure_timeout, stop_hook_block_cap, max_turns, + extra_operations, cancel, } = config; let manages_own_context = provider.manages_own_context(); @@ -118,6 +120,7 @@ pub(crate) fn build_state_machine( Arc::new(MaxTurnsOperation::new(max_turns)), ]; operations.extend(remaining_operations); + operations.extend(extra_operations); let request_preparer = GooseInferenceRequestPreparer { extension_manager, extension_lease, diff --git a/ui/desktop/src/acp/__tests__/config.test.ts b/ui/desktop/src/acp/__tests__/config.test.ts new file mode 100644 index 000000000..da2a6a8bc --- /dev/null +++ b/ui/desktop/src/acp/__tests__/config.test.ts @@ -0,0 +1,18 @@ +import { describe, expect, it } from 'vitest'; +import { hasConfiguredSecret, isMaskedConfigValue } from '../config'; + +describe('ACP config values', () => { + it('recognizes masked secret values', () => { + const value = { maskedValue: '********' }; + + expect(isMaskedConfigValue(value)).toBe(true); + expect(hasConfiguredSecret(value)).toBe(true); + }); + + it.each([null, '', '********', {}, { maskedValue: '' }, { maskedValue: 1 }])( + 'does not treat %j as a configured secret', + (value) => { + expect(hasConfiguredSecret(value)).toBe(false); + } + ); +}); diff --git a/ui/desktop/src/acp/__tests__/sessionNotificationAdapter.test.ts b/ui/desktop/src/acp/__tests__/sessionNotificationAdapter.test.ts index 7e1e5c119..61b2786e0 100644 --- a/ui/desktop/src/acp/__tests__/sessionNotificationAdapter.test.ts +++ b/ui/desktop/src/acp/__tests__/sessionNotificationAdapter.test.ts @@ -138,7 +138,13 @@ describe('createAcpSessionNotificationAdapter', () => { it('maps and merges text chunks by role', () => { const adapter = createAcpSessionNotificationAdapter(); - adapter.apply(agentText('Hello ')); + adapter.apply( + acpUpdate({ + sessionUpdate: 'agent_message_chunk', + content: { type: 'text', text: 'Hello ' }, + _meta: { goose: { operationLogs: ['ops_auto_effort: thinking high'] } }, + } as SessionNotification['update']) + ); const secondChunkStateChanges = adapter.apply(agentText('world')); let messages = expectOnlyMessagesChange(secondChunkStateChanges); @@ -146,6 +152,7 @@ describe('createAcpSessionNotificationAdapter', () => { expect(messages).toHaveLength(1); expect(messages[0].role).toBe('assistant'); expect(firstContent(messages[0])).toMatchObject({ type: 'text', text: 'Hello world' }); + expect(messages[0].metadata.operationLogs).toEqual(['ops_auto_effort: thinking high']); const userTextStateChanges = adapter.apply(userText('Question')); messages = expectOnlyMessagesChange(userTextStateChanges); @@ -340,7 +347,13 @@ describe('createAcpSessionNotificationAdapter', () => { }); const thoughtAdapter = createAcpSessionNotificationAdapter(); - thoughtAdapter.apply(agentThought('Thinking ')); + thoughtAdapter.apply( + acpUpdate({ + sessionUpdate: 'agent_thought_chunk', + content: { type: 'text', text: 'Thinking ' }, + _meta: { goose: { operationLogs: ['ops_auto_effort: thinking high'] } }, + } as SessionNotification['update']) + ); const thoughtStateChanges = thoughtAdapter.apply(agentThought('more')); const thoughtMessages = expectOnlyMessagesChange(thoughtStateChanges); @@ -351,6 +364,9 @@ describe('createAcpSessionNotificationAdapter', () => { thinking: 'Thinking more', signature: '', }); + expect(thoughtMessages[0].metadata.operationLogs).toEqual([ + 'ops_auto_effort: thinking high', + ]); }); it('preserves output-limit metadata when creating a thought message', () => { @@ -521,6 +537,7 @@ describe('createAcpSessionNotificationAdapter', () => { locations: [{ path: 'README.md', line: 1 }], _meta: { goose: { + operationLogs: ['ops_auto_effort: thinking high'], toolCall: { extensionName: 'developer', toolName: 'read_file', @@ -533,6 +550,7 @@ describe('createAcpSessionNotificationAdapter', () => { expect(messages).toHaveLength(1); expect(messages[0].role).toBe('assistant'); + expect(messages[0].metadata.operationLogs).toEqual(['ops_auto_effort: thinking high']); expect(firstContent(messages[0])).toMatchObject({ type: 'toolRequest', id: 'tool-1', diff --git a/ui/desktop/src/acp/adapter/messages.ts b/ui/desktop/src/acp/adapter/messages.ts index bc4a2eeef..8735b42f8 100644 --- a/ui/desktop/src/acp/adapter/messages.ts +++ b/ui/desktop/src/acp/adapter/messages.ts @@ -41,6 +41,9 @@ export function applyContentChunk( existing.metadata.fallbackContent = shouldSkipFallbackChunk ? undefined : gooseMeta.fallbackContent; + if (gooseMeta.operationLogs) { + existing.metadata.operationLogs = gooseMeta.operationLogs; + } applyInferenceMeta(existing, gooseMeta); if (shouldSkipFallbackChunk) { @@ -72,6 +75,7 @@ export function applyContentChunk( ...(gooseMeta.steer ? { steer: true } : {}), outputTokenLimitReached: gooseMeta.outputTokenLimitReached, fallbackContent: gooseMeta.fallbackContent, + ...(gooseMeta.operationLogs ? { operationLogs: gooseMeta.operationLogs } : {}), }, }; applyInferenceMeta(message, gooseMeta); @@ -105,6 +109,9 @@ export function applyThoughtChunk( } message.metadata.outputTokenLimitReached = gooseMeta.outputTokenLimitReached; + if (gooseMeta.operationLogs) { + message.metadata.operationLogs = gooseMeta.operationLogs; + } applyInferenceMeta(message, gooseMeta); const lastContent = message.content[message.content.length - 1]; diff --git a/ui/desktop/src/acp/adapter/shared.ts b/ui/desktop/src/acp/adapter/shared.ts index a8c249bdc..a5cf35f18 100644 --- a/ui/desktop/src/acp/adapter/shared.ts +++ b/ui/desktop/src/acp/adapter/shared.ts @@ -28,6 +28,7 @@ export interface GooseMessageMeta { created?: number; outputTokenLimitReached?: boolean; fallbackContent?: boolean; + operationLogs?: string[]; steer?: boolean; inference?: InferenceMetadata; } @@ -69,12 +70,16 @@ export function getGooseMessageMeta(update: { _meta?: unknown }): GooseMessageMe } const outputTokenLimitReached = goose.outputTokenLimitReached === true; + const operationLogs = Array.isArray(goose.operationLogs) + ? goose.operationLogs.filter((line): line is string => typeof line === 'string') + : undefined; return { created: typeof goose.created === 'number' ? goose.created : undefined, messageId: typeof goose.messageId === 'string' ? goose.messageId : undefined, outputTokenLimitReached: outputTokenLimitReached ? true : undefined, fallbackContent: goose.fallbackContent === true ? true : undefined, + operationLogs, steer: goose.steer === true ? true : undefined, inference: getInferenceMeta(goose.inference), }; diff --git a/ui/desktop/src/acp/adapter/tools.ts b/ui/desktop/src/acp/adapter/tools.ts index ff877a223..c46572894 100644 --- a/ui/desktop/src/acp/adapter/tools.ts +++ b/ui/desktop/src/acp/adapter/tools.ts @@ -120,6 +120,9 @@ function getOrCreateAssistantMessageForUpdate( ): Message { const existing = findMessageForChunk(state, 'assistant', gooseMeta.messageId, gooseMeta.created); if (existing) { + if (gooseMeta.operationLogs) { + existing.metadata.operationLogs = gooseMeta.operationLogs; + } return existing; } @@ -128,7 +131,10 @@ function getOrCreateAssistantMessageForUpdate( role: 'assistant', created: gooseMeta.created ?? Math.floor(Date.now() / 1000), content: [], - metadata: { ...DEFAULT_VISIBLE_MESSAGE_METADATA }, + metadata: { + ...DEFAULT_VISIBLE_MESSAGE_METADATA, + ...(gooseMeta.operationLogs ? { operationLogs: gooseMeta.operationLogs } : {}), + }, }; state.messages.push(message); return message; diff --git a/ui/desktop/src/acp/config.ts b/ui/desktop/src/acp/config.ts index 7ca81030b..852993462 100644 --- a/ui/desktop/src/acp/config.ts +++ b/ui/desktop/src/acp/config.ts @@ -1,6 +1,20 @@ import { getAcpClient } from './acpConnection'; export type ConfigReadValue = unknown; +export type MaskedConfigValue = { maskedValue: string }; + +export function isMaskedConfigValue(value: unknown): value is MaskedConfigValue { + return ( + typeof value === 'object' && + value !== null && + 'maskedValue' in value && + typeof value.maskedValue === 'string' + ); +} + +export function hasConfiguredSecret(value: unknown): boolean { + return isMaskedConfigValue(value) && value.maskedValue.length > 0; +} export async function acpReadConfig( key: string, @@ -12,7 +26,7 @@ export async function acpReadConfig( return null; } if (isSecret) { - return { maskedValue: value as string }; + return { maskedValue: value as string } satisfies MaskedConfigValue; } return value; } diff --git a/ui/desktop/src/components/GooseMessage.test.tsx b/ui/desktop/src/components/GooseMessage.test.tsx new file mode 100644 index 000000000..168beec0c --- /dev/null +++ b/ui/desktop/src/components/GooseMessage.test.tsx @@ -0,0 +1,37 @@ +import { render, screen } from '@testing-library/react'; +import { describe, expect, it, vi } from 'vitest'; +import { IntlTestWrapper } from '../i18n/test-utils'; +import type { Message } from '../types/message'; +import GooseMessage from './GooseMessage'; + +describe('GooseMessage', () => { + it('renders operation details for a thinking-only message', () => { + const message: Message = { + content: [{ type: 'thinking', thinking: 'Working it out', signature: '' }], + created: 1, + metadata: { + agentVisible: true, + operationLogs: ['ops_auto_effort: thinking high'], + userVisible: true, + }, + role: 'assistant', + }; + + render( + , + { wrapper: IntlTestWrapper } + ); + + expect(screen.getByText('Thinking')).toBeInTheDocument(); + expect(screen.getByLabelText('ops_auto_effort: thinking high')).toBeInTheDocument(); + }); +}); diff --git a/ui/desktop/src/components/GooseMessage.tsx b/ui/desktop/src/components/GooseMessage.tsx index f7cd0c71d..d856b0d78 100644 --- a/ui/desktop/src/components/GooseMessage.tsx +++ b/ui/desktop/src/components/GooseMessage.tsx @@ -83,6 +83,8 @@ function GooseMessage({ const elicitationContent = getElicitationContent(message); const hasToolConfirmation = toolConfirmationContent !== undefined; const hasElicitation = elicitationContent !== undefined; + const hasMessageDetails = + message.metadata.usage != null || (message.metadata.operationLogs?.length ?? 0) > 0; const outputTokenLimitNotice = isOutputTokenLimitFallback ? "Response reached the model's output-token limit before returning content." : "Response reached the model's output-token limit and may be incomplete."; @@ -98,15 +100,38 @@ function GooseMessage({
{thinkingContent && ( - +
+ + {!displayText.trim() && imagePaths.length === 0 && toolRequests.length === 0 && ( +
+
+ {!isStreaming && !hideTimestamp && timestamp} +
+ {!isStreaming && hasMessageDetails && ( +
+ +
+ )} +
+ )} +
)} {(displayText.trim() || imagePaths.length > 0) && ( @@ -137,9 +162,12 @@ function GooseMessage({
)} - {!isStreaming && message.metadata.usage && ( + {!isStreaming && hasMessageDetails && (
- +
)}
@@ -179,15 +207,18 @@ function GooseMessage({
{!isStreaming && !hideTimestamp && timestamp}
- {!isStreaming && message.metadata.usage && ( + {!isStreaming && hasMessageDetails && (
- +
)} diff --git a/ui/desktop/src/components/MessageUsageStats.test.tsx b/ui/desktop/src/components/MessageUsageStats.test.tsx index 5cf8671a1..91c7a7d0e 100644 --- a/ui/desktop/src/components/MessageUsageStats.test.tsx +++ b/ui/desktop/src/components/MessageUsageStats.test.tsx @@ -33,8 +33,10 @@ const FULL_USAGE: MessageUsage = { isCompaction: false, }; -function renderUsage(usage: MessageUsage) { - return render(, { wrapper: IntlTestWrapper }); +function renderUsage(usage: MessageUsage, operationLogs?: string[]) { + return render(, { + wrapper: IntlTestWrapper, + }); } describe('MessageUsageStats', () => { @@ -79,7 +81,7 @@ describe('MessageUsageStats', () => { it('breaks down tokens and cost in the tooltip on hover', async () => { const user = userEvent.setup(); - renderUsage(FULL_USAGE); + renderUsage(FULL_USAGE, ['ops_auto_effort: thinking off']); await user.hover(screen.getByText('1.5k tok')); @@ -92,5 +94,19 @@ describe('MessageUsageStats', () => { expect(tooltip.getByText('Output')).toBeInTheDocument(); expect(tooltip.getByText('340')).toBeInTheDocument(); expect(tooltip.getByText('(estimated)')).toBeInTheDocument(); + expect(tooltip.getByText('ops_auto_effort: thinking off')).toBeInTheDocument(); + }); + + it('shows operation logs without usage metadata', async () => { + const user = userEvent.setup(); + render(, { + wrapper: IntlTestWrapper, + }); + + await user.hover(screen.getByLabelText('ops_auto_effort: thinking off')); + + expect( + within(await screen.findByRole('tooltip')).getByText('ops_auto_effort: thinking off') + ).toBeInTheDocument(); }); }); diff --git a/ui/desktop/src/components/MessageUsageStats.tsx b/ui/desktop/src/components/MessageUsageStats.tsx index 5e0ead795..6f05821a9 100644 --- a/ui/desktop/src/components/MessageUsageStats.tsx +++ b/ui/desktop/src/components/MessageUsageStats.tsx @@ -107,9 +107,15 @@ function StatRow({ /** * Per-message usage chip (tok/s, cost, total tokens) with a tooltip breaking - * down tokens, caching, timing, and cost. Renders nothing without data. + * down tokens, caching, timing, cost, and operation logs. */ -export default function MessageUsageStats({ usage }: { usage: MessageUsage }) { +export default function MessageUsageStats({ + usage, + operationLogs = [], +}: { + usage?: MessageUsage | null; + operationLogs?: string[]; +}) { const intl = useIntl(); const { inputTokens, @@ -122,7 +128,7 @@ export default function MessageUsageStats({ usage }: { usage: MessageUsage }) { elapsedMs, timeToFirstTokenMs, isCompaction, - } = usage; + } = usage ?? {}; const tps = tokensPerSecond(outputTokens, elapsedMs); @@ -151,6 +157,12 @@ export default function MessageUsageStats({ usage }: { usage: MessageUsage }) { ); } + if (chipSegments.length === 0 && operationLogs.length > 0) { + chipSegments.push( + + ); + } + if (chipSegments.length === 0) { return null; } @@ -280,6 +292,14 @@ export default function MessageUsageStats({ usage }: { usage: MessageUsage }) { {intl.formatMessage(i18n.compaction)} )} + + {operationLogs.length > 0 && ( +
+ {operationLogs.map((line, index) => ( +
{line}
+ ))} +
+ )} diff --git a/ui/desktop/src/components/settings/AgentLoopSettings.tsx b/ui/desktop/src/components/settings/AgentLoopSettings.tsx index 6937c8f4a..9d46c0c3f 100644 --- a/ui/desktop/src/components/settings/AgentLoopSettings.tsx +++ b/ui/desktop/src/components/settings/AgentLoopSettings.tsx @@ -1,8 +1,10 @@ import { type ReactNode, useEffect, useState } from 'react'; import { useConfig } from '../ConfigContext'; +import { Button } from '../ui/button'; import { Input } from '../ui/input'; import { Card, CardContent, CardHeader, CardTitle } from '../ui/card'; import { defineMessages, useIntl } from '../../i18n'; +import { hasConfiguredSecret } from '../../acp/config'; const i18n = defineMessages({ title: { @@ -25,6 +27,35 @@ const i18n = defineMessages({ id: 'settings.agentLoop.operations.slashCommands.description', defaultMessage: 'Recognizes commands such as /compact, /skills, and recipe shortcuts.', }, + autoEffortTitle: { + id: 'settings.agentLoop.operations.autoEffort.title', + defaultMessage: 'Automatic thinking effort', + }, + autoEffortDescription: { + id: 'settings.agentLoop.operations.autoEffort.description', + defaultMessage: + 'Uses Jev to choose the thinking effort for each request. Request text is sent to TypeSafe AI; skill and recipe slash commands include their expanded local instructions.', + }, + typesafeApiKeyLabel: { + id: 'settings.agentLoop.operations.autoEffort.apiKey.label', + defaultMessage: 'TypeSafe API key', + }, + typesafeApiKeyPlaceholder: { + id: 'settings.agentLoop.operations.autoEffort.apiKey.placeholder', + defaultMessage: 'Enter API key', + }, + apiKeyConfigured: { + id: 'settings.agentLoop.operations.autoEffort.apiKey.configured', + defaultMessage: 'Configured', + }, + saveApiKey: { + id: 'settings.agentLoop.operations.autoEffort.apiKey.save', + defaultMessage: 'Save key', + }, + removeApiKey: { + id: 'settings.agentLoop.operations.autoEffort.apiKey.remove', + defaultMessage: 'Remove key', + }, maxTurnsTitle: { id: 'settings.agentLoop.operations.maxTurns.title', defaultMessage: 'Max turns', @@ -206,6 +237,9 @@ export default function AgentLoopSettings() { const intl = useIntl(); const { read, remove, upsert } = useConfig(); const [slashCommandsEnabled, setSlashCommandsEnabled] = useState(true); + const [autoEffortEnabled, setAutoEffortEnabled] = useState(false); + const [typesafeApiKey, setTypesafeApiKey] = useState(''); + const [typesafeApiKeyConfigured, setTypesafeApiKeyConfigured] = useState(false); const [toolPairCompactionEnabled, setToolPairCompactionEnabled] = useState(false); const [numbers, setNumbers] = useState(defaultNumberSettings); @@ -222,6 +256,8 @@ export default function AgentLoopSettings() { read('GOOSE_RECIPE_RETRY_TIMEOUT_SECONDS', false), read('GOOSE_RECIPE_ON_FAILURE_TIMEOUT_SECONDS', false), read('GOOSE_STOP_HOOK_BLOCK_CAP', false), + read('GOOSE_AUTO_EFFORT_ENABLED', false), + read('TYPESAFE_API_KEY', true), ]).then( ([ maxTurns, @@ -233,10 +269,14 @@ export default function AgentLoopSettings() { retryTimeout, failureTimeout, stopHookBlockCap, + autoEffort, + typesafeApiKey, ]) => { if (!active) return; setSlashCommandsEnabled(typeof slashCommands === 'boolean' ? slashCommands : true); + setAutoEffortEnabled(typeof autoEffort === 'boolean' ? autoEffort : false); + setTypesafeApiKeyConfigured(hasConfiguredSecret(typesafeApiKey)); setToolPairCompactionEnabled( typeof toolPairCompaction === 'boolean' ? toolPairCompaction : false ); @@ -291,6 +331,25 @@ export default function AgentLoopSettings() { await upsert('GOOSE_SLASH_COMMANDS_ENABLED', checked, false); }; + const handleAutoEffortToggle = async (checked: boolean) => { + setAutoEffortEnabled(checked); + await upsert('GOOSE_AUTO_EFFORT_ENABLED', checked, false); + }; + + const saveTypesafeApiKey = async () => { + const apiKey = typesafeApiKey.trim(); + if (!apiKey) return; + await upsert('TYPESAFE_API_KEY', apiKey, true); + setTypesafeApiKey(''); + setTypesafeApiKeyConfigured(true); + }; + + const removeTypesafeApiKey = async () => { + await remove('TYPESAFE_API_KEY', true); + setTypesafeApiKey(''); + setTypesafeApiKeyConfigured(false); + }; + const saveToolCallCutoff = async () => { if (numbers.toolCallCutoff.trim() === '') { await remove('GOOSE_TOOL_CALL_CUTOFF', false); @@ -318,6 +377,50 @@ export default function AgentLoopSettings() { onEnabledChange={handleSlashCommandsToggle} /> + +
+ +
+ setTypesafeApiKey(event.target.value)} + /> + + {typesafeApiKeyConfigured && ( + + )} +
+
+
+ ; -type ConfigValue = string | { maskedValue: string }; +type ConfigValue = string | MaskedConfigValue; export interface ConfigInput { serverValue?: ConfigValue; value?: string; @@ -144,7 +145,7 @@ export default function DefaultProviderSetupForm({ const getPlaceholder = (parameter: ConfigKey): string => { if (parameter.secret) { const serverValue = configValues[parameter.name]?.serverValue; - if (typeof serverValue === 'object' && 'maskedValue' in serverValue) { + if (isMaskedConfigValue(serverValue)) { return serverValue.maskedValue; } } diff --git a/ui/desktop/src/i18n/messages/de.json b/ui/desktop/src/i18n/messages/de.json index c4bdb9afe..66ffe6438 100644 --- a/ui/desktop/src/i18n/messages/de.json +++ b/ui/desktop/src/i18n/messages/de.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Automatisch" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Konfiguriert" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "TypeSafe-API-Schlüssel" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "API-Schlüssel eingeben" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Schlüssel entfernen" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Schlüssel speichern" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Verwendet Jev, um den Denkaufwand für jede Anfrage auszuwählen. Anfragetext wird an TypeSafe AI gesendet; Slash-Befehle für Skills und Rezepte enthalten deren erweiterte lokale Anweisungen." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Automatischer Denkaufwand" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Blockierungslimit" }, diff --git a/ui/desktop/src/i18n/messages/en.json b/ui/desktop/src/i18n/messages/en.json index 4187e56a8..b22063679 100644 --- a/ui/desktop/src/i18n/messages/en.json +++ b/ui/desktop/src/i18n/messages/en.json @@ -3977,6 +3977,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Auto" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Configured" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "TypeSafe API key" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "Enter API key" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Remove key" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Save key" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Uses Jev to choose the thinking effort for each request. Request text is sent to TypeSafe AI; skill and recipe slash commands include their expanded local instructions." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Automatic thinking effort" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Block limit" }, diff --git a/ui/desktop/src/i18n/messages/es.json b/ui/desktop/src/i18n/messages/es.json index fc7cb29e7..fab198d64 100644 --- a/ui/desktop/src/i18n/messages/es.json +++ b/ui/desktop/src/i18n/messages/es.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Automático" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Configurada" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "Clave de API de TypeSafe" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "Introduce la clave de API" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Eliminar clave" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Guardar clave" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Usa Jev para elegir el esfuerzo de razonamiento de cada solicitud. El texto se envía a TypeSafe AI; los comandos de habilidades y recetas incluyen sus instrucciones locales ampliadas." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Esfuerzo de razonamiento automático" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Límite de bloqueos" }, diff --git a/ui/desktop/src/i18n/messages/fr.json b/ui/desktop/src/i18n/messages/fr.json index e620711b6..bbe33cac1 100644 --- a/ui/desktop/src/i18n/messages/fr.json +++ b/ui/desktop/src/i18n/messages/fr.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Automatique" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Configurée" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "Clé API TypeSafe" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "Saisissez la clé API" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Supprimer la clé" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Enregistrer la clé" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Utilise Jev pour choisir l’effort de raisonnement de chaque requête. Le texte est envoyé à TypeSafe AI ; les commandes de compétences et de recettes incluent leurs instructions locales développées." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Effort de raisonnement automatique" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Limite de blocage" }, diff --git a/ui/desktop/src/i18n/messages/hi.json b/ui/desktop/src/i18n/messages/hi.json index 508f593d2..a370aa134 100644 --- a/ui/desktop/src/i18n/messages/hi.json +++ b/ui/desktop/src/i18n/messages/hi.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "स्वचालित" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "कॉन्फ़िगर किया गया" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "TypeSafe API कुंजी" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "API कुंजी दर्ज करें" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "कुंजी हटाएँ" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "कुंजी सहेजें" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "हर अनुरोध के लिए सोचने का स्तर चुनने हेतु Jev का उपयोग करता है। अनुरोध का पाठ TypeSafe AI को भेजा जाता है; स्किल और रेसिपी स्लैश कमांड में उनके विस्तारित स्थानीय निर्देश शामिल होते हैं।" + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "स्वचालित सोचने का स्तर" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "ब्लॉक सीमा" }, diff --git a/ui/desktop/src/i18n/messages/id.json b/ui/desktop/src/i18n/messages/id.json index d027833de..dcb833a3c 100644 --- a/ui/desktop/src/i18n/messages/id.json +++ b/ui/desktop/src/i18n/messages/id.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Otomatis" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Terkonfigurasi" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "Kunci API TypeSafe" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "Masukkan kunci API" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Hapus kunci" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Simpan kunci" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Menggunakan Jev untuk memilih tingkat penalaran bagi setiap permintaan. Teks permintaan dikirim ke TypeSafe AI; perintah garis miring skill dan resep menyertakan instruksi lokal yang telah diperluas." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Tingkat penalaran otomatis" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Batas pemblokiran" }, diff --git a/ui/desktop/src/i18n/messages/it.json b/ui/desktop/src/i18n/messages/it.json index 2ab23149f..314745782 100644 --- a/ui/desktop/src/i18n/messages/it.json +++ b/ui/desktop/src/i18n/messages/it.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Automatico" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Configurata" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "Chiave API TypeSafe" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "Inserisci la chiave API" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Rimuovi chiave" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Salva chiave" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Usa Jev per scegliere il livello di ragionamento per ogni richiesta. Il testo viene inviato a TypeSafe AI; i comandi slash di skill e ricette includono le relative istruzioni locali espanse." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Livello di ragionamento automatico" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Limite di blocco" }, diff --git a/ui/desktop/src/i18n/messages/ja.json b/ui/desktop/src/i18n/messages/ja.json index 78757b20c..ce179dc24 100644 --- a/ui/desktop/src/i18n/messages/ja.json +++ b/ui/desktop/src/i18n/messages/ja.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "自動" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "設定済み" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "TypeSafe APIキー" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "APIキーを入力" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "キーを削除" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "キーを保存" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Jevを使用してリクエストごとの思考レベルを選択します。リクエストのテキストはTypeSafe AIに送信され、スキルやレシピのスラッシュコマンドには展開されたローカル指示が含まれます。" + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "思考レベルの自動選択" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "ブロック上限" }, diff --git a/ui/desktop/src/i18n/messages/ko.json b/ui/desktop/src/i18n/messages/ko.json index fda7f6b4c..8353c08cb 100644 --- a/ui/desktop/src/i18n/messages/ko.json +++ b/ui/desktop/src/i18n/messages/ko.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "자동" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "구성됨" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "TypeSafe API 키" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "API 키 입력" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "키 제거" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "키 저장" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Jev를 사용해 각 요청의 사고 수준을 선택합니다. 요청 텍스트는 TypeSafe AI로 전송되며, 스킬 및 레시피 슬래시 명령에는 확장된 로컬 지침이 포함됩니다." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "자동 사고 수준" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "차단 한도" }, diff --git a/ui/desktop/src/i18n/messages/ms.json b/ui/desktop/src/i18n/messages/ms.json index 1852c9a62..fb35f2a75 100644 --- a/ui/desktop/src/i18n/messages/ms.json +++ b/ui/desktop/src/i18n/messages/ms.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Automatik" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Dikonfigurasi" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "Kunci API TypeSafe" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "Masukkan kunci API" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Alih keluar kunci" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Simpan kunci" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Menggunakan Jev untuk memilih tahap pemikiran bagi setiap permintaan. Teks permintaan dihantar kepada TypeSafe AI; perintah garis miring kemahiran dan resipi menyertakan arahan tempatan yang telah dikembangkan." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Tahap pemikiran automatik" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Had sekatan" }, diff --git a/ui/desktop/src/i18n/messages/pt.json b/ui/desktop/src/i18n/messages/pt.json index 8f3883c1c..bb0fbd3f0 100644 --- a/ui/desktop/src/i18n/messages/pt.json +++ b/ui/desktop/src/i18n/messages/pt.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Automático" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Configurada" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "Chave de API da TypeSafe" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "Insira a chave de API" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Remover chave" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Salvar chave" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Usa o Jev para escolher o nível de raciocínio de cada solicitação. O texto é enviado à TypeSafe AI; comandos de barra de habilidades e receitas incluem suas instruções locais expandidas." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Nível de raciocínio automático" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Limite de bloqueios" }, diff --git a/ui/desktop/src/i18n/messages/ru.json b/ui/desktop/src/i18n/messages/ru.json index bd9150e81..8f7337f4e 100644 --- a/ui/desktop/src/i18n/messages/ru.json +++ b/ui/desktop/src/i18n/messages/ru.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Автоматически" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Настроено" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "API-ключ TypeSafe" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "Введите API-ключ" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Удалить ключ" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Сохранить ключ" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Использует Jev для выбора уровня рассуждений для каждого запроса. Текст отправляется в TypeSafe AI; слеш-команды навыков и рецептов включают их развёрнутые локальные инструкции." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Автоматический уровень рассуждений" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Лимит блокировок" }, diff --git a/ui/desktop/src/i18n/messages/tr.json b/ui/desktop/src/i18n/messages/tr.json index f91a90c49..e02b94ab4 100644 --- a/ui/desktop/src/i18n/messages/tr.json +++ b/ui/desktop/src/i18n/messages/tr.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Otomatik" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Yapılandırıldı" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "TypeSafe API anahtarı" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "API anahtarını girin" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Anahtarı kaldır" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Anahtarı kaydet" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Her istek için düşünme düzeyini seçmek üzere Jev’i kullanır. İstek metni TypeSafe AI’a gönderilir; beceri ve tarif eğik çizgi komutları genişletilmiş yerel talimatlarını içerir." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Otomatik düşünme düzeyi" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Engelleme sınırı" }, diff --git a/ui/desktop/src/i18n/messages/vi.json b/ui/desktop/src/i18n/messages/vi.json index 3ead8ca96..c2811c3b7 100644 --- a/ui/desktop/src/i18n/messages/vi.json +++ b/ui/desktop/src/i18n/messages/vi.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "Tự động" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "Đã cấu hình" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "Khóa API TypeSafe" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "Nhập khóa API" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "Xóa khóa" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "Lưu khóa" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "Sử dụng Jev để chọn mức suy luận cho từng yêu cầu. Nội dung được gửi đến TypeSafe AI; lệnh gạch chéo kỹ năng và công thức bao gồm hướng dẫn cục bộ đã mở rộng." + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "Mức suy luận tự động" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "Giới hạn chặn" }, diff --git a/ui/desktop/src/i18n/messages/zh-CN.json b/ui/desktop/src/i18n/messages/zh-CN.json index 375169eb5..4976882c0 100644 --- a/ui/desktop/src/i18n/messages/zh-CN.json +++ b/ui/desktop/src/i18n/messages/zh-CN.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "自动" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "已配置" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "TypeSafe API 密钥" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "输入 API 密钥" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "移除密钥" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "保存密钥" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "使用 Jev 为每个请求选择思考级别。请求文本会发送给 TypeSafe AI;技能和配方斜杠命令会包含展开后的本地指令。" + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "自动思考级别" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "阻止上限" }, diff --git a/ui/desktop/src/i18n/messages/zh-TW.json b/ui/desktop/src/i18n/messages/zh-TW.json index 60c1cec26..874a77874 100644 --- a/ui/desktop/src/i18n/messages/zh-TW.json +++ b/ui/desktop/src/i18n/messages/zh-TW.json @@ -4682,6 +4682,27 @@ "settings.agentLoop.operations.auto.placeholder": { "defaultMessage": "自動" }, + "settings.agentLoop.operations.autoEffort.apiKey.configured": { + "defaultMessage": "已設定" + }, + "settings.agentLoop.operations.autoEffort.apiKey.label": { + "defaultMessage": "TypeSafe API 金鑰" + }, + "settings.agentLoop.operations.autoEffort.apiKey.placeholder": { + "defaultMessage": "輸入 API 金鑰" + }, + "settings.agentLoop.operations.autoEffort.apiKey.remove": { + "defaultMessage": "移除金鑰" + }, + "settings.agentLoop.operations.autoEffort.apiKey.save": { + "defaultMessage": "儲存金鑰" + }, + "settings.agentLoop.operations.autoEffort.description": { + "defaultMessage": "使用 Jev 為每個請求選擇思考層級。請求文字會傳送至 TypeSafe AI;技能和配方斜線命令會包含展開後的本機指示。" + }, + "settings.agentLoop.operations.autoEffort.title": { + "defaultMessage": "自動思考層級" + }, "settings.agentLoop.operations.blockLimit.label": { "defaultMessage": "封鎖上限" }, diff --git a/ui/desktop/src/types/message.ts b/ui/desktop/src/types/message.ts index 2984e793c..99951bfcb 100644 --- a/ui/desktop/src/types/message.ts +++ b/ui/desktop/src/types/message.ts @@ -182,6 +182,7 @@ export type MessageMetadata = { agentVisible: boolean; fallbackContent?: boolean; inference?: InferenceMetadata | null; + operationLogs?: string[]; outputTokenLimitReached?: boolean; steer?: boolean; usage?: MessageUsage | null;