Skip to content

Commit a8b9ad0

Browse files
baxendrone01
andcommitted
Preserve cleared creation instructions over harness defaults
Keep card seeding and harness lifecycle behavior from main while seeding tool requests only initially. Carry explicit clears to harnesses with nonempty defaults. Co-authored-by: drone01 <e12008b05c49247c92d156d919b55c33ca739e39e3741d1f1497398d263d7013@buzz.block.builderlab.xyz> Signed-off-by: Bradley Axen <[email protected]>
1 parent 0bd8198 commit a8b9ad0

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

‎src/bundled/agents/AgentCreateDialog.test.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,6 @@ it("keeps requested instructions the owner cleared when choosing a harness", asy
14011401
...notes,
14021402
key,
14031403
title,
1404-
defaults: () => ({ config: { notes: "start", instructions: "" } }),
14051404
carry: (config) => {
14061405
const { instructions } = config as Notes;
14071406
return instructions.trim() ? { instructions } : {};

‎src/bundled/agents/AgentCreateDialog.tsx‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,22 @@ export function AgentCreateDialog({
125125
};
126126
/** The agent's settings in `item`, or a new agent's defaults, with the
127127
* requested instructions. */
128-
const seed = (item: RegisteredAgentType | undefined) => {
129-
const instructions = update
130-
? update.request.instructions
131-
: (request?.instructions ?? draft?.instructions);
132-
const config = !update
133-
? startingConfig(item)
134-
: item?.key === update.agent.type
135-
? update.agent.config
128+
const seed = (item: RegisteredAgentType | undefined, initial = true) => {
129+
if (!update) {
130+
const config = startingConfig(item);
131+
const instructions =
132+
(initial ? request?.instructions : undefined) ?? draft?.instructions;
133+
return instructions && item?.adopt
134+
? item.adopt({ instructions }, config)
135+
: config;
136+
}
137+
const { agent, request: proposed } = update;
138+
const config =
139+
item?.key === agent.type
140+
? agent.config
136141
: (migration(item)?.config ?? startingConfig(item));
137-
return instructions !== undefined && item?.adopt
138-
? item.adopt({ instructions }, config)
142+
return proposed.instructions !== undefined && item?.adopt
143+
? item.adopt({ instructions: proposed.instructions }, config)
139144
: config;
140145
};
141146
const [config, setConfig] = useState(() => seed(type));
@@ -208,12 +213,13 @@ export function AgentCreateDialog({
208213
const item = types.find((candidate) => candidate.key === key);
209214
if (!item || key === type?.key) return;
210215
setLeft(type ? { key: type.key, config } : undefined);
211-
// A new agent's request or card seeds only the first harness; from then
212-
// on its instructions are what the owner left, cleared ones included.
213-
const next = update ? seed(item) : startingConfig(item);
216+
// A creation request seeds only the first harness, not later choices.
217+
const next = seed(item, false);
218+
// Carry the owner's edits, including an explicit clear, across harnesses.
214219
const carried =
215220
update || !type?.carry ? undefined : type.carry(config).instructions;
216-
const instructions = carried || (draft && type?.carry ? "" : undefined);
221+
const instructions =
222+
carried || ((draft || request) && type?.carry ? "" : undefined);
217223
restoreHarnessFocus.current = item.key;
218224
setConfigurationReady(false);
219225
chooseModel(

0 commit comments

Comments
 (0)