Fix disabled instruction restart snapshots

Co-authored-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz>
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
This commit is contained in:
Taylor Ho
2026-08-25 12:06:31 -07:00
committed by Rizz
parent fed570bbd4
commit 10e34c731f
6 changed files with 74 additions and 4 deletions

View File

@@ -247,6 +247,10 @@ pub fn build_managed_agent_summary(
// The prospective side is computed only for a tracked pair: an unstamped
// agent has nothing to compare against.
let shared_instructions_enabled = app
.state::<crate::app_state::AppState>()
.shared_instructions_enabled
.load(std::sync::atomic::Ordering::Relaxed);
let tracked_spawn = pair_key.as_ref().zip(pair_runtime).map(|(key, runtime)| {
let current = crate::managed_agents::spawn_snapshot::prospective_spawn_config_snapshot(
record,
@@ -254,6 +258,7 @@ pub fn build_managed_agent_summary(
teams,
&key.relay_url,
global_config,
shared_instructions_enabled,
super::owner_only_access_build(),
);
(runtime, current)

View File

@@ -1235,6 +1235,7 @@ fn make_pair_runtime_placeholder() -> crate::managed_agents::ManagedAgentPairRun
&[],
"wss://relay.example",
&Default::default(),
true,
false,
),
setup_mode: false,

View File

@@ -264,6 +264,7 @@ pub(crate) fn prospective_spawn_config_snapshot(
teams: &[TeamRecord],
workspace_relay: &str,
global: &GlobalAgentConfig,
shared_instructions_enabled: bool,
enforced_owner_only: bool,
) -> SpawnConfigSnapshot {
// Prospective re-snapshot: apply the same `apply_persona_snapshot` the
@@ -304,9 +305,12 @@ pub(crate) fn prospective_spawn_config_snapshot(
EffectiveConfigResult::OrphanedInstance { .. } => (None, None, None),
};
let assigned_shared_instructions =
let assigned_shared_instructions: &[String] = if shared_instructions_enabled {
super::effective_config::resolve_effective_assigned_shared_instructions(record, personas)
.unwrap_or_default();
.unwrap_or_default()
} else {
&[]
};
SpawnConfigSnapshot::from_inputs(SpawnConfigInputs {
record,

View File

@@ -21,6 +21,7 @@ fn snapshot_with_policy(
teams,
workspace_relay,
global,
true,
enforced_owner_only,
)
.canonical()

View File

@@ -1,5 +1,53 @@
use super::*;
#[test]
fn restart_stamp_omits_shared_instructions_when_experiment_is_disabled() {
let mut rec = record();
rec.persona_id = Some("pers".into());
let mut live = persona("pers", Some("goose"), "prompt");
live.assigned_shared_instructions = vec![format!("30023:{}:kept", "b".repeat(64))];
let personas = [live];
let global = GlobalAgentConfig::default();
let descriptor =
crate::managed_agents::resolve_effective_harness_descriptor(&rec, &personas, &global)
.unwrap();
let effective = resolve_effective_config(&rec, &personas, &global)
.require_resolved()
.unwrap();
let mut command = std::process::Command::new("buzz-acp");
let assigned =
crate::managed_agents::shared_instructions::resolve_and_apply_assigned_shared_instructions_env(
&mut command,
&rec,
&personas,
false,
)
.unwrap();
let stamped = SpawnConfigSnapshot::from_inputs(SpawnConfigInputs {
record: &rec,
descriptor: &descriptor,
relay_url: "wss://ws.example",
team_instructions: None,
system_prompt: effective.system_prompt.value.as_deref(),
model: effective.model.value.as_deref(),
provider: effective.provider.value.as_deref(),
assigned_shared_instructions: assigned,
enforced_owner_only: false,
});
let current = prospective_spawn_config_snapshot(
&rec,
&personas,
&[],
"wss://ws.example",
&global,
false,
false,
);
assert!(stamped.assigned_shared_instructions.is_empty());
assert_eq!(stamped.canonical(), current.canonical());
}
#[test]
fn restart_stamp_uses_live_shared_instructions_and_clears_diff() {
let mut rec = record();
@@ -38,8 +86,15 @@ fn restart_stamp_uses_live_shared_instructions_and_clears_diff() {
assigned_shared_instructions: assigned,
enforced_owner_only: false,
});
let current =
prospective_spawn_config_snapshot(&rec, &personas, &[], "wss://ws.example", &global, false);
let current = prospective_spawn_config_snapshot(
&rec,
&personas,
&[],
"wss://ws.example",
&global,
true,
false,
);
assert_eq!(
stamped.assigned_shared_instructions,

View File

@@ -137,6 +137,7 @@ fn backfill_of_promptless_record_keeps_spawn_snapshot_stable() {
&[],
"wss://ws.example",
&Default::default(),
true,
false,
);
@@ -154,6 +155,7 @@ fn backfill_of_promptless_record_keeps_spawn_snapshot_stable() {
&[],
"wss://ws.example",
&Default::default(),
true,
false,
);
@@ -189,6 +191,7 @@ fn backfill_of_prompted_record_keeps_spawn_snapshot_stable() {
&[],
"wss://ws.example",
&Default::default(),
true,
false,
);
@@ -206,6 +209,7 @@ fn backfill_of_prompted_record_keeps_spawn_snapshot_stable() {
&[],
"wss://ws.example",
&Default::default(),
true,
false,
);