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
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ impl Agent for CodeReviewAgent {
UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
}

fn is_readonly(&self) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ impl Agent for DeepReviewAgent {
UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
}

fn is_readonly(&self) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ impl Agent for CoworkMode {
UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
}

fn is_readonly(&self) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ impl Agent for DeepResearchMode {
UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
}

fn is_readonly(&self) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ impl Agent for UltimateHarness {
UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
}
fn is_readonly(&self) -> bool {
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ impl Agent for ComputerUseMode {
}

fn user_context_policy(&self) -> UserContextPolicy {
UserContextPolicy::empty()
.with_workspace_instructions()
.with_project_layout()
UserContextPolicy::empty().with_workspace_instructions()
}

fn is_readonly(&self) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ impl Agent for GeneralPurposeAgent {
UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
}

fn is_readonly(&self) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ impl Agent for SwarmPlannerAgent {
crate::agentic::agents::UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
}
}

Expand Down Expand Up @@ -180,6 +179,5 @@ impl Agent for SwarmWorkerAgent {
crate::agentic::agents::UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ impl PromptBuilderContext {
}
}

#[allow(clippy::too_many_arguments)]
pub async fn build_prompt_context_for_workspace(
workspace: &WorkspaceBinding,
workspace_id: Option<&str>,
Expand All @@ -158,6 +159,7 @@ pub async fn build_prompt_context_for_workspace(
supports_image_understanding: Option<bool>,
tool_listing_sections: ToolListingSections,
runtime_context_needs: RuntimeContextNeeds,
user_context_policy: &UserContextPolicy,
) -> Option<PromptBuilderContext> {
let workspace_path = workspace.root_path_string();

Expand Down Expand Up @@ -203,6 +205,7 @@ pub async fn build_prompt_context_for_workspace(

#[cfg(not(feature = "remote-workspace"))]
{
let _ = user_context_policy;
Some(base)
}

Expand Down Expand Up @@ -232,7 +235,6 @@ pub async fn build_prompt_context_for_workspace(
};

let ssh_manager = manager.get_ssh_manager().await;
let file_service = manager.get_file_service().await;
let (kernel_name, hostname) = if let Some(ref ssh) = ssh_manager {
if let Some(info) = ssh.get_server_info(connection_id).await {
(info.os_type, info.hostname)
Expand All @@ -242,15 +244,24 @@ pub async fn build_prompt_context_for_workspace(
} else {
("Linux".to_string(), "remote".to_string())
};
let remote_layout = if let Some(ref fs) = file_service {
match build_remote_workspace_layout_preview(fs, connection_id, &workspace_path, 200)
let remote_layout = if user_context_policy.includes(UserContextSection::ProjectLayout) {
if let Some(fs) = manager.get_file_service().await {
match build_remote_workspace_layout_preview(
&fs,
connection_id,
&workspace_path,
200,
)
.await
{
Ok((_, preview)) => Some(preview),
Err(e) => {
warn!("Remote workspace layout for prompt failed: {}", e);
None
{
Ok((_, preview)) => Some(preview),
Err(e) => {
warn!("Remote workspace layout for prompt failed: {}", e);
None
}
}
} else {
None
}
} else {
None
Expand Down Expand Up @@ -334,6 +345,15 @@ impl PromptBuilder {
});
}

if self.context.remote_execution.is_some() {
return render_project_layout(&ProjectLayoutFacts {
listing: "Remote workspace layout is unavailable.".to_string(),
reached_limit: false,
max_entries: self.file_tree_max_entries,
remote: true,
});
}

let formatted_listing = get_formatted_directory_listing(
&self.context.workspace_path,
self.file_tree_max_entries,
Expand Down Expand Up @@ -1097,6 +1117,7 @@ mod tests {
None,
ToolListingSections::default(),
RuntimeContextNeeds::default(),
&UserContextPolicy::empty().with_workspace_context(),
)
.await
.expect("prompt context should build");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,7 @@ impl ExecutionEngine {
supports_image_understanding: bool,
tool_listing_sections: ToolListingSections,
runtime_context_needs: RuntimeContextNeeds,
user_context_policy: &UserContextPolicy,
) -> Option<PromptBuilderContext> {
let workspace = context.workspace.as_ref()?;
let remote_file_delivery_channel = context
Expand All @@ -1479,6 +1480,7 @@ impl ExecutionEngine {
Some(supports_image_understanding),
tool_listing_sections,
runtime_context_needs,
user_context_policy,
)
.await
.map(|prompt_context| {
Expand Down Expand Up @@ -1747,6 +1749,7 @@ impl ExecutionEngine {
input.supports_image_understanding,
input.tool_listing_sections,
input.runtime_context_needs,
&input.current_agent.user_context_policy(),
)
.await;
let prepended_prompt_reminders = self
Expand Down
2 changes: 0 additions & 2 deletions src/crates/assembly/core/src/agentic/memories/phase2_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ impl Agent for MemoryPhase2Agent {
UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
}

fn tool_exposure_overrides(&self) -> &AgentToolPolicyOverrides {
Expand All @@ -86,7 +85,6 @@ mod tests {
UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
);
assert!(agent.default_tools().contains(&"Read".to_string()));
assert!(agent.default_tools().contains(&"Write".to_string()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ pub async fn build_embedded_user_context_reminder(
None,
ToolListingSections::default(),
Default::default(),
user_context_policy,
)
.await?;
PromptBuilder::new(context)
Expand Down
1 change: 0 additions & 1 deletion src/crates/execution/agent-runtime/src/agents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ pub fn standard_harness_user_context_policy() -> UserContextPolicy {
UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout()
.with_memory_summary()
}

Expand Down
3 changes: 1 addition & 2 deletions src/crates/execution/agent-runtime/src/custom_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,7 @@ pub fn custom_agent_tools_are_default(kind: CustomAgentKind, tools: &[String]) -
pub fn default_custom_agent_user_context_policy(kind: CustomAgentKind) -> UserContextPolicy {
let base = UserContextPolicy::empty()
.with_workspace_context()
.with_workspace_instructions()
.with_project_layout();
.with_workspace_instructions();
match kind {
CustomAgentKind::Mode | CustomAgentKind::Subagent => base,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fn mode_presentation_and_shared_context_policy_match_existing_mode_contract() {

assert_eq!(
standard_harness_user_context_policy().cache_scope_key(),
"workspace_context|workspace_instructions|project_layout|memory_summary"
"workspace_context|workspace_instructions|memory_summary"
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ const ID_REGEX = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
const DEFAULT_MODE_POLICY: UserContextSection[] = [
'workspace_context',
'workspace_instructions',
'project_layout',
];
const DEFAULT_SUBAGENT_POLICY: UserContextSection[] = [
'workspace_context',
'workspace_instructions',
'project_layout',
];
const DEFAULT_CUSTOM_MODE_TOOLS = [
'Read',
Expand Down
Loading