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
9 changes: 8 additions & 1 deletion .github/workflows/patched-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,14 @@ jobs:
"context_mgmt::rolling::tests::rolling_settings_write_null" \
"context_mgmt::rolling::tests::rolling_state_default_absent" \
"context_mgmt::rolling::tests::rolling_state_invalid_defaults" \
"context_mgmt::rolling::tests::rolling_state_roundtrip"
"context_mgmt::rolling::tests::rolling_state_roundtrip" \
"agents::state_machine::subdirectory_hints::tests::hints_are_appended_to_the_tool_response_for_the_agent_only" \
"agents::state_machine::subdirectory_hints::tests::hints_already_in_the_conversation_are_not_delivered_again" \
"agents::state_machine::subdirectory_hints::tests::hints_hidden_from_the_agent_return_with_the_next_call_into_the_directory" \
"agents::state_machine::subdirectory_hints::tests::a_quoted_marker_does_not_count_as_delivered" \
"agents::state_machine::subdirectory_hints::tests::failed_tool_responses_do_not_carry_hints" \
"agents::state_machine::subdirectory_hints::tests::hints_go_to_the_last_successful_response_in_directory_order" \
"agents::state_machine::tests::prompt_skill_lifecycle::prompt_and_skill_lifecycle"

run_exact_tests --release -p goose --features "$F" --test self_compact -- \
"test_happy_path_self_compact" \
Expand Down
3 changes: 2 additions & 1 deletion crates/goose/src/agents/state_machine/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Modified by Jonathan Mohrbacher, 2026: export retry and compaction failure checks for turn errors; self-compaction operation; rolling memory operation.
// Modified by Jonathan Mohrbacher, 2026: export retry and compaction failure checks for turn errors; self-compaction operation; rolling memory operation; subdirectory_hints module.
//! Runs an ordered, re-entrant pipeline over persisted conversation state.
//!
//! Callers persist incoming messages, construct `Step`s from their own operations,
Expand Down Expand Up @@ -29,6 +29,7 @@ mod ops_tool_pair_compaction;
mod ops_toolcalling;
mod proactive_compaction;
mod session;
mod subdirectory_hints;
pub(crate) use session::run as run_goose;
mod tool_approval;
mod tool_confirmation;
Expand Down
15 changes: 12 additions & 3 deletions crates/goose/src/agents/state_machine/ops_platform_extensions.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Modified by Jonathan Mohrbacher, 2026: platform tool responses carry subdirectory hints.
use std::sync::{Arc, Mutex};

use anyhow::Result;
Expand Down Expand Up @@ -121,11 +122,19 @@ impl Operation<Session, GooseEffect> for PlatformExtensionOperation {
if calls.is_empty() {
return not_applicable();
}
let mut session = session.clone();
let mut call_session = session.clone();
if let Some(directory) = tools.working_dir() {
session.working_dir = directory.to_path_buf();
call_session.working_dir = directory.to_path_buf();
}
self.execution.run(calls, &session, emit).await
self.execution
.run(
calls,
&call_session,
conversation,
&session.working_dir,
emit,
)
.await
}

async fn finalize_cancellation(
Expand Down
36 changes: 17 additions & 19 deletions crates/goose/src/agents/state_machine/ops_toolcalling.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Modified by Jonathan Mohrbacher, 2026: subdirectory hints are delivered in tool responses, not the system prompt.
//! Exposes extension capabilities and executes requests that belong to them.

use std::collections::{HashMap, HashSet};
Expand All @@ -15,6 +16,7 @@ use crate::agents::extension::ExtensionInfo;
use crate::agents::extension_manager::CallRequest;
use crate::agents::reply_parts::is_tool_visible_to_model;
use crate::agents::state_machine::ops_llm::{ADVERTISED_TOOLS_NOTE, LLM_OPERATION_NAME};
use crate::agents::state_machine::subdirectory_hints::deliver_subdirectory_hints;
use crate::agents::state_machine::{
applied, messages_since_kickoff, not_applicable, yielded_with, Command, ConversationEffect,
Emitter, GooseEffect, Operation, OperationResult,
Expand All @@ -27,7 +29,6 @@ use crate::conversation::message::{
ActionRequiredData, Message, MessageContent, ProviderMetadata, ToolRequest,
};
use crate::conversation::Conversation;
use crate::hints::load_hints::SubdirectoryHintTracker;
use crate::session::Session;

pub(super) const EXPIRED_APPROVAL_RESPONSE: &str =
Expand Down Expand Up @@ -698,23 +699,9 @@ impl Operation<Session, GooseEffect> for ToolExecutionOperation {
async fn prompt_parts(
&self,
session: &Session,
conversation: &Conversation,
_conversation: &Conversation,
) -> Result<Vec<(String, String)>> {
let mut hints = SubdirectoryHintTracker::new();
for message in conversation
.messages()
.iter()
.filter(|message| message.is_agent_visible())
{
for content in &message.content {
if let MessageContent::ToolRequest(request) = content {
if let Ok(tool_call) = &request.tool_call {
hints.record_tool_arguments(&tool_call.arguments, &session.working_dir);
}
}
}
}
let mut prompt_parts = hints.load_new_hints(&session.working_dir);
let mut prompt_parts = Vec::new();

let tools = ToolSnapshot::for_session(&self.tools, &self.services, &session.id).await?;
#[cfg(feature = "code-mode")]
Expand Down Expand Up @@ -847,7 +834,15 @@ impl Operation<Session, GooseEffect> for ToolExecutionOperation {
};
calls.push((request, result));
}
self.execution.run(calls, &call_session, emit).await
self.execution
.run(
calls,
&call_session,
conversation,
&session.working_dir,
emit,
)
.await
}
}

Expand Down Expand Up @@ -882,6 +877,8 @@ impl ToolExecution {
&self,
calls: Vec<(ToolRequest, ToolCallResult)>,
session: &Session,
conversation: &Conversation,
hint_working_dir: &Path,
emit: &Emitter,
) -> Result<OperationResult<GooseEffect>> {
let mut tool_streams = Vec::new();
Expand Down Expand Up @@ -929,7 +926,8 @@ impl ToolExecution {
}

let (actions, response) = self.take_batch();
let response = response.ok_or_else(|| anyhow!("tool batch produced no responses"))?;
let mut response = response.ok_or_else(|| anyhow!("tool batch produced no responses"))?;
deliver_subdirectory_hints(&mut response, conversation, hint_working_dir);
emit.emit(AgentEvent::Message(response.user_visible_content()));
applied(actions.into_iter().chain([response]).map(GooseEffect::from))
}
Expand Down
Loading
Loading