Skip to content

Commit 539dd62

Browse files
committed
feat(agents): Disable project layout by default
Remove project layout from built-in Agent context policies and custom Agent defaults to reduce automatic context injection. Keep explicit opt-in and the existing policy persistence rules. Generate remote layout previews only when requested, and report missing remote previews without falling back to the local filesystem.
1 parent 561c8d5 commit 539dd62

16 files changed

Lines changed: 36 additions & 27 deletions

File tree

‎src/crates/assembly/core/src/agentic/agents/definitions/hidden/code_review.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ impl Agent for CodeReviewAgent {
7070
UserContextPolicy::empty()
7171
.with_workspace_context()
7272
.with_workspace_instructions()
73-
.with_project_layout()
7473
}
7574

7675
fn is_readonly(&self) -> bool {

‎src/crates/assembly/core/src/agentic/agents/definitions/hidden/deep_review.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ impl Agent for DeepReviewAgent {
6767
UserContextPolicy::empty()
6868
.with_workspace_context()
6969
.with_workspace_instructions()
70-
.with_project_layout()
7170
}
7271

7372
fn is_readonly(&self) -> bool {

‎src/crates/assembly/core/src/agentic/agents/definitions/modes/cowork.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ impl Agent for CoworkMode {
9595
UserContextPolicy::empty()
9696
.with_workspace_context()
9797
.with_workspace_instructions()
98-
.with_project_layout()
9998
}
10099

101100
fn is_readonly(&self) -> bool {

‎src/crates/assembly/core/src/agentic/agents/definitions/modes/deep_research.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ impl Agent for DeepResearchMode {
8181
UserContextPolicy::empty()
8282
.with_workspace_context()
8383
.with_workspace_instructions()
84-
.with_project_layout()
8584
}
8685

8786
fn is_readonly(&self) -> bool {

‎src/crates/assembly/core/src/agentic/agents/definitions/modes/ultimate.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ impl Agent for UltimateHarness {
6565
UserContextPolicy::empty()
6666
.with_workspace_context()
6767
.with_workspace_instructions()
68-
.with_project_layout()
6968
}
7069
fn is_readonly(&self) -> bool {
7170
false

‎src/crates/assembly/core/src/agentic/agents/definitions/subagents/computer_use.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ impl Agent for ComputerUseMode {
6262
}
6363

6464
fn user_context_policy(&self) -> UserContextPolicy {
65-
UserContextPolicy::empty()
66-
.with_workspace_instructions()
67-
.with_project_layout()
65+
UserContextPolicy::empty().with_workspace_instructions()
6866
}
6967

7068
fn is_readonly(&self) -> bool {

‎src/crates/assembly/core/src/agentic/agents/definitions/subagents/general_purpose.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ impl Agent for GeneralPurposeAgent {
6363
UserContextPolicy::empty()
6464
.with_workspace_context()
6565
.with_workspace_instructions()
66-
.with_project_layout()
6766
}
6867

6968
fn is_readonly(&self) -> bool {

‎src/crates/assembly/core/src/agentic/agents/definitions/subagents/swarm.rs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ impl Agent for SwarmPlannerAgent {
5454
crate::agentic::agents::UserContextPolicy::empty()
5555
.with_workspace_context()
5656
.with_workspace_instructions()
57-
.with_project_layout()
5857
}
5958
}
6059

@@ -180,6 +179,5 @@ impl Agent for SwarmWorkerAgent {
180179
crate::agentic::agents::UserContextPolicy::empty()
181180
.with_workspace_context()
182181
.with_workspace_instructions()
183-
.with_project_layout()
184182
}
185183
}

‎src/crates/assembly/core/src/agentic/agents/prompt_builder/prompt_builder_impl.rs‎

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ impl PromptBuilderContext {
150150
}
151151
}
152152

153+
#[allow(clippy::too_many_arguments)]
153154
pub async fn build_prompt_context_for_workspace(
154155
workspace: &WorkspaceBinding,
155156
workspace_id: Option<&str>,
@@ -158,6 +159,7 @@ pub async fn build_prompt_context_for_workspace(
158159
supports_image_understanding: Option<bool>,
159160
tool_listing_sections: ToolListingSections,
160161
runtime_context_needs: RuntimeContextNeeds,
162+
user_context_policy: &UserContextPolicy,
161163
) -> Option<PromptBuilderContext> {
162164
let workspace_path = workspace.root_path_string();
163165

@@ -203,6 +205,7 @@ pub async fn build_prompt_context_for_workspace(
203205

204206
#[cfg(not(feature = "remote-workspace"))]
205207
{
208+
let _ = user_context_policy;
206209
Some(base)
207210
}
208211

@@ -232,7 +235,6 @@ pub async fn build_prompt_context_for_workspace(
232235
};
233236

234237
let ssh_manager = manager.get_ssh_manager().await;
235-
let file_service = manager.get_file_service().await;
236238
let (kernel_name, hostname) = if let Some(ref ssh) = ssh_manager {
237239
if let Some(info) = ssh.get_server_info(connection_id).await {
238240
(info.os_type, info.hostname)
@@ -242,15 +244,24 @@ pub async fn build_prompt_context_for_workspace(
242244
} else {
243245
("Linux".to_string(), "remote".to_string())
244246
};
245-
let remote_layout = if let Some(ref fs) = file_service {
246-
match build_remote_workspace_layout_preview(fs, connection_id, &workspace_path, 200)
247+
let remote_layout = if user_context_policy.includes(UserContextSection::ProjectLayout) {
248+
if let Some(fs) = manager.get_file_service().await {
249+
match build_remote_workspace_layout_preview(
250+
&fs,
251+
connection_id,
252+
&workspace_path,
253+
200,
254+
)
247255
.await
248-
{
249-
Ok((_, preview)) => Some(preview),
250-
Err(e) => {
251-
warn!("Remote workspace layout for prompt failed: {}", e);
252-
None
256+
{
257+
Ok((_, preview)) => Some(preview),
258+
Err(e) => {
259+
warn!("Remote workspace layout for prompt failed: {}", e);
260+
None
261+
}
253262
}
263+
} else {
264+
None
254265
}
255266
} else {
256267
None
@@ -334,6 +345,15 @@ impl PromptBuilder {
334345
});
335346
}
336347

348+
if self.context.remote_execution.is_some() {
349+
return render_project_layout(&ProjectLayoutFacts {
350+
listing: "Remote workspace layout is unavailable.".to_string(),
351+
reached_limit: false,
352+
max_entries: self.file_tree_max_entries,
353+
remote: true,
354+
});
355+
}
356+
337357
let formatted_listing = get_formatted_directory_listing(
338358
&self.context.workspace_path,
339359
self.file_tree_max_entries,
@@ -1097,6 +1117,7 @@ mod tests {
10971117
None,
10981118
ToolListingSections::default(),
10991119
RuntimeContextNeeds::default(),
1120+
&UserContextPolicy::empty().with_workspace_context(),
11001121
)
11011122
.await
11021123
.expect("prompt context should build");

‎src/crates/assembly/core/src/agentic/execution/execution_engine.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,7 @@ impl ExecutionEngine {
14641464
supports_image_understanding: bool,
14651465
tool_listing_sections: ToolListingSections,
14661466
runtime_context_needs: RuntimeContextNeeds,
1467+
user_context_policy: &UserContextPolicy,
14671468
) -> Option<PromptBuilderContext> {
14681469
let workspace = context.workspace.as_ref()?;
14691470
let remote_file_delivery_channel = context
@@ -1479,6 +1480,7 @@ impl ExecutionEngine {
14791480
Some(supports_image_understanding),
14801481
tool_listing_sections,
14811482
runtime_context_needs,
1483+
user_context_policy,
14821484
)
14831485
.await
14841486
.map(|prompt_context| {
@@ -1747,6 +1749,7 @@ impl ExecutionEngine {
17471749
input.supports_image_understanding,
17481750
input.tool_listing_sections,
17491751
input.runtime_context_needs,
1752+
&input.current_agent.user_context_policy(),
17501753
)
17511754
.await;
17521755
let prepended_prompt_reminders = self

0 commit comments

Comments
 (0)