feat: agent-aware rename via command-io hints [LET-7755] (#1250)

This commit is contained in:
Devansh Jain
2026-03-03 16:12:53 -08:00
committed by GitHub
parent 28ba2e7e1f
commit fd59b8c46b
4 changed files with 33 additions and 4 deletions

View File

@@ -2712,6 +2712,7 @@ export default function App({
input, input,
output: event.output, output: event.output,
success: event.success, success: event.success,
agentHint: event.agentHint,
}); });
}, []); }, []);
@@ -8160,6 +8161,7 @@ export default function App({
await client.agents.update(agentId, { name: newValue }); await client.agents.update(agentId, { name: newValue });
updateAgentName(newValue); updateAgentName(newValue);
cmd.agentHint = `Your name is now "${newValue}" — acknowledge this and save your new name to memory.`;
cmd.finish(`Agent renamed to "${newValue}"`, true); cmd.finish(`Agent renamed to "${newValue}"`, true);
} catch (error) { } catch (error) {
const errorDetails = formatErrorDetails(error, agentId); const errorDetails = formatErrorDetails(error, agentId);
@@ -13838,6 +13840,9 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
settingsManager.pinGlobal(agentId); settingsManager.pinGlobal(agentId);
} }
if (newName && newName !== agentName) {
cmd.agentHint = `Your name is now "${newName}" — acknowledge this and save your new name to memory.`;
}
cmd.finish( cmd.finish(
`Pinned "${newName || agentName || agentId.slice(0, 12)}" ${scopeText}.`, `Pinned "${newName || agentName || agentId.slice(0, 12)}" ${scopeText}.`,
true, true,

View File

@@ -22,6 +22,8 @@ export type CommandHandle = {
preformatted?: boolean, preformatted?: boolean,
) => void; ) => void;
fail: (output: string) => void; fail: (output: string) => void;
/** Extra context included only in the agent-facing reminder, not shown in the UI. */
agentHint?: string;
}; };
export type CommandFinishedEvent = { export type CommandFinishedEvent = {
@@ -31,6 +33,8 @@ export type CommandFinishedEvent = {
success: boolean; success: boolean;
dimOutput?: boolean; dimOutput?: boolean;
preformatted?: boolean; preformatted?: boolean;
/** Extra context included only in the agent-facing reminder, not shown in the UI. */
agentHint?: string;
}; };
type CreateId = (prefix: string) => string; type CreateId = (prefix: string) => string;
@@ -69,6 +73,14 @@ export function createCommandRunner({
onCommandFinished, onCommandFinished,
}: RunnerDeps) { }: RunnerDeps) {
function getHandle(id: string, input: string): CommandHandle { function getHandle(id: string, input: string): CommandHandle {
const handle: CommandHandle = {
id,
input,
update: null!,
finish: null!,
fail: null!,
};
const update = (updateData: CommandUpdate) => { const update = (updateData: CommandUpdate) => {
const previous = buffersRef.current.byId.get(id); const previous = buffersRef.current.byId.get(id);
const wasFinished = const wasFinished =
@@ -90,13 +102,16 @@ export function createCommandRunner({
success: next.success !== false, success: next.success !== false,
dimOutput: next.dimOutput, dimOutput: next.dimOutput,
preformatted: next.preformatted, preformatted: next.preformatted,
agentHint: handle.agentHint,
}); });
} }
refreshDerived(); refreshDerived();
}; };
const finish = ( handle.update = update;
handle.finish = (
finalOutput: string, finalOutput: string,
success = true, success = true,
dimOutput?: boolean, dimOutput?: boolean,
@@ -110,14 +125,14 @@ export function createCommandRunner({
preformatted, preformatted,
}); });
const fail = (finalOutput: string) => handle.fail = (finalOutput: string) =>
update({ update({
output: finalOutput, output: finalOutput,
phase: "finished", phase: "finished",
success: false, success: false,
}); });
return { id, input, update, finish, fail }; return handle;
} }
function start(input: string, output: string): CommandHandle { function start(input: string, output: string): CommandHandle {

View File

@@ -308,13 +308,20 @@ async function buildCommandIoReminder(
</user-command>`; </user-command>`;
}); });
const agentHints = recent
.filter((entry) => entry.agentHint)
.map((entry) => `- ${entry.agentHint}`);
const droppedLine = const droppedLine =
dropped > 0 ? `\nOmitted ${dropped} older command event(s).` : ""; dropped > 0 ? `\nOmitted ${dropped} older command event(s).` : "";
const hintsBlock =
agentHints.length > 0 ? `\n\n${agentHints.join("\n")}` : "";
return `${SYSTEM_REMINDER_OPEN} return `${SYSTEM_REMINDER_OPEN}
The following slash commands were executed in the Letta Code harness since your last user message. The following slash commands were executed in the Letta Code harness since your last user message.
Treat these as execution context from the CLI, not new user requests.${droppedLine} Treat these as execution context from the CLI, not new user requests.${droppedLine}
${commandBlocks.join("\n")} ${commandBlocks.join("\n")}${hintsBlock}
${SYSTEM_REMINDER_CLOSE} ${SYSTEM_REMINDER_CLOSE}
`; `;

View File

@@ -7,6 +7,8 @@ export interface CommandIoReminder {
input: string; input: string;
output: string; output: string;
success: boolean; success: boolean;
/** Extra context appended only in the agent-facing reminder, not shown in the UI. */
agentHint?: string;
} }
export interface ToolsetChangeReminder { export interface ToolsetChangeReminder {