refactor(cli): move /system upgrade hint into thinking tips (#1411)
Co-authored-by: Letta Code <noreply@letta.com>
This commit is contained in:
@@ -981,8 +981,9 @@ export default function App({
|
|||||||
setAgentState((prev) => (prev ? { ...prev, name } : prev));
|
setAgentState((prev) => (prev ? { ...prev, name } : prev));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Check if the current agent would benefit from switching to the default prompt
|
// Check if the current agent would benefit from switching to the default prompt.
|
||||||
const shouldShowDefaultPromptTip = useCallback(() => {
|
// Used to conditionally include the /system tip in streaming tip rotation.
|
||||||
|
const includeSystemPromptUpgradeTip = useMemo(() => {
|
||||||
if (!agentState?.id || !agentState.system) return false;
|
if (!agentState?.id || !agentState.system) return false;
|
||||||
const memMode = settingsManager.isMemfsEnabled(agentState.id)
|
const memMode = settingsManager.isMemfsEnabled(agentState.id)
|
||||||
? "memfs"
|
? "memfs"
|
||||||
@@ -3079,8 +3080,6 @@ export default function App({
|
|||||||
? `Resuming conversation with **${agentName}**`
|
? `Resuming conversation with **${agentName}**`
|
||||||
: `Starting new conversation with **${agentName}**`;
|
: `Starting new conversation with **${agentName}**`;
|
||||||
|
|
||||||
const showPromptTip = shouldShowDefaultPromptTip();
|
|
||||||
|
|
||||||
// Command hints - vary based on agent state:
|
// Command hints - vary based on agent state:
|
||||||
// - Resuming: show /new (they may want a fresh conversation)
|
// - Resuming: show /new (they may want a fresh conversation)
|
||||||
// - New session + unpinned: show /pin (they should save their agent)
|
// - New session + unpinned: show /pin (they should save their agent)
|
||||||
@@ -3092,9 +3091,6 @@ export default function App({
|
|||||||
"→ **/new** start a new conversation",
|
"→ **/new** start a new conversation",
|
||||||
"→ **/init** initialize your agent's memory",
|
"→ **/init** initialize your agent's memory",
|
||||||
"→ **/remember** teach your agent",
|
"→ **/remember** teach your agent",
|
||||||
...(showPromptTip
|
|
||||||
? ["→ **/system** upgrade to the latest default prompt"]
|
|
||||||
: []),
|
|
||||||
]
|
]
|
||||||
: isPinned
|
: isPinned
|
||||||
? [
|
? [
|
||||||
@@ -3103,9 +3099,6 @@ export default function App({
|
|||||||
"→ **/memory** view your agent's memory",
|
"→ **/memory** view your agent's memory",
|
||||||
"→ **/init** initialize your agent's memory",
|
"→ **/init** initialize your agent's memory",
|
||||||
"→ **/remember** teach your agent",
|
"→ **/remember** teach your agent",
|
||||||
...(showPromptTip
|
|
||||||
? ["→ **/system** upgrade to the latest default prompt"]
|
|
||||||
: []),
|
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
"→ **/agents** list all agents",
|
"→ **/agents** list all agents",
|
||||||
@@ -3113,9 +3106,6 @@ export default function App({
|
|||||||
"→ **/pin** save + name your agent",
|
"→ **/pin** save + name your agent",
|
||||||
"→ **/init** initialize your agent's memory",
|
"→ **/init** initialize your agent's memory",
|
||||||
"→ **/remember** teach your agent",
|
"→ **/remember** teach your agent",
|
||||||
...(showPromptTip
|
|
||||||
? ["→ **/system** upgrade to the latest default prompt"]
|
|
||||||
: []),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Build status lines with optional release notes above header
|
// Build status lines with optional release notes above header
|
||||||
@@ -3151,7 +3141,6 @@ export default function App({
|
|||||||
agentProvenance,
|
agentProvenance,
|
||||||
resumedExistingConversation,
|
resumedExistingConversation,
|
||||||
releaseNotes,
|
releaseNotes,
|
||||||
shouldShowDefaultPromptTip,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Fetch llmConfig when agent is ready
|
// Fetch llmConfig when agent is ready
|
||||||
@@ -13075,9 +13064,6 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|||||||
? `Starting new conversation with **${agentName}**`
|
? `Starting new conversation with **${agentName}**`
|
||||||
: "Creating a new agent";
|
: "Creating a new agent";
|
||||||
|
|
||||||
// Only show prompt tip for existing agents, not brand new ones
|
|
||||||
const showPromptTip = continueSession && shouldShowDefaultPromptTip();
|
|
||||||
|
|
||||||
// Command hints - for pinned agents show /memory, for unpinned show /pin
|
// Command hints - for pinned agents show /memory, for unpinned show /pin
|
||||||
const commandHints = isPinned
|
const commandHints = isPinned
|
||||||
? [
|
? [
|
||||||
@@ -13086,9 +13072,6 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|||||||
"→ **/memory** view your agent's memory",
|
"→ **/memory** view your agent's memory",
|
||||||
"→ **/init** initialize your agent's memory",
|
"→ **/init** initialize your agent's memory",
|
||||||
"→ **/remember** teach your agent",
|
"→ **/remember** teach your agent",
|
||||||
...(showPromptTip
|
|
||||||
? ["→ **/system** upgrade to the latest default prompt"]
|
|
||||||
: []),
|
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
"→ **/agents** list all agents",
|
"→ **/agents** list all agents",
|
||||||
@@ -13096,9 +13079,6 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|||||||
"→ **/pin** save + name your agent",
|
"→ **/pin** save + name your agent",
|
||||||
"→ **/init** initialize your agent's memory",
|
"→ **/init** initialize your agent's memory",
|
||||||
"→ **/remember** teach your agent",
|
"→ **/remember** teach your agent",
|
||||||
...(showPromptTip
|
|
||||||
? ["→ **/system** upgrade to the latest default prompt"]
|
|
||||||
: []),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Build status lines with optional release notes above header
|
// Build status lines with optional release notes above header
|
||||||
@@ -13133,7 +13113,6 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|||||||
agentState,
|
agentState,
|
||||||
refreshDerived,
|
refreshDerived,
|
||||||
releaseNotes,
|
releaseNotes,
|
||||||
shouldShowDefaultPromptTip,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const liveTrajectorySnapshot =
|
const liveTrajectorySnapshot =
|
||||||
@@ -13511,6 +13490,7 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|||||||
tokenCount={trajectoryTokenDisplay}
|
tokenCount={trajectoryTokenDisplay}
|
||||||
elapsedBaseMs={liveTrajectoryElapsedBaseMs}
|
elapsedBaseMs={liveTrajectoryElapsedBaseMs}
|
||||||
thinkingMessage={thinkingMessage}
|
thinkingMessage={thinkingMessage}
|
||||||
|
includeSystemPromptUpgradeTip={includeSystemPromptUpgradeTip}
|
||||||
onSubmit={onSubmit}
|
onSubmit={onSubmit}
|
||||||
onBashSubmit={handleBashSubmit}
|
onBashSubmit={handleBashSubmit}
|
||||||
bashRunning={bashRunning}
|
bashRunning={bashRunning}
|
||||||
|
|||||||
@@ -477,6 +477,7 @@ const StreamingStatus = memo(function StreamingStatus({
|
|||||||
tokenCount,
|
tokenCount,
|
||||||
elapsedBaseMs,
|
elapsedBaseMs,
|
||||||
thinkingMessage,
|
thinkingMessage,
|
||||||
|
includeSystemPromptUpgradeTip,
|
||||||
agentName,
|
agentName,
|
||||||
interruptRequested,
|
interruptRequested,
|
||||||
networkPhase,
|
networkPhase,
|
||||||
@@ -488,6 +489,7 @@ const StreamingStatus = memo(function StreamingStatus({
|
|||||||
tokenCount: number;
|
tokenCount: number;
|
||||||
elapsedBaseMs: number;
|
elapsedBaseMs: number;
|
||||||
thinkingMessage: string;
|
thinkingMessage: string;
|
||||||
|
includeSystemPromptUpgradeTip: boolean;
|
||||||
agentName: string | null | undefined;
|
agentName: string | null | undefined;
|
||||||
interruptRequested: boolean;
|
interruptRequested: boolean;
|
||||||
networkPhase: "upload" | "download" | "error" | null;
|
networkPhase: "upload" | "download" | "error" | null;
|
||||||
@@ -529,7 +531,6 @@ const StreamingStatus = memo(function StreamingStatus({
|
|||||||
const [shimmerOffset, setShimmerOffset] = useState(-3);
|
const [shimmerOffset, setShimmerOffset] = useState(-3);
|
||||||
const [elapsedMs, setElapsedMs] = useState(0);
|
const [elapsedMs, setElapsedMs] = useState(0);
|
||||||
const [tipMessage, setTipMessage] = useState("");
|
const [tipMessage, setTipMessage] = useState("");
|
||||||
const tipInitializedRef = useRef(false);
|
|
||||||
const streamStartRef = useRef<number | null>(null);
|
const streamStartRef = useRef<number | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -583,15 +584,9 @@ const StreamingStatus = memo(function StreamingStatus({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (streaming && visible) {
|
if (streaming && visible) {
|
||||||
if (!tipInitializedRef.current) {
|
setTipMessage(getRandomThinkingTip({ includeSystemPromptUpgradeTip }));
|
||||||
setTipMessage(getRandomThinkingTip());
|
|
||||||
tipInitializedRef.current = true;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}, [streaming, visible, includeSystemPromptUpgradeTip]);
|
||||||
tipInitializedRef.current = false;
|
|
||||||
}, [streaming, visible]);
|
|
||||||
|
|
||||||
const estimatedTokens = charsToTokens(tokenCount);
|
const estimatedTokens = charsToTokens(tokenCount);
|
||||||
const totalElapsedMs = elapsedBaseMs + elapsedMs;
|
const totalElapsedMs = elapsedBaseMs + elapsedMs;
|
||||||
@@ -724,6 +719,7 @@ export function Input({
|
|||||||
tokenCount,
|
tokenCount,
|
||||||
elapsedBaseMs = 0,
|
elapsedBaseMs = 0,
|
||||||
thinkingMessage,
|
thinkingMessage,
|
||||||
|
includeSystemPromptUpgradeTip = true,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
onBashSubmit,
|
onBashSubmit,
|
||||||
bashRunning = false,
|
bashRunning = false,
|
||||||
@@ -766,6 +762,7 @@ export function Input({
|
|||||||
tokenCount: number;
|
tokenCount: number;
|
||||||
elapsedBaseMs?: number;
|
elapsedBaseMs?: number;
|
||||||
thinkingMessage: string;
|
thinkingMessage: string;
|
||||||
|
includeSystemPromptUpgradeTip?: boolean;
|
||||||
onSubmit: (message?: string) => Promise<{ submitted: boolean }>;
|
onSubmit: (message?: string) => Promise<{ submitted: boolean }>;
|
||||||
onBashSubmit?: (command: string) => Promise<void>;
|
onBashSubmit?: (command: string) => Promise<void>;
|
||||||
bashRunning?: boolean;
|
bashRunning?: boolean;
|
||||||
@@ -1713,6 +1710,7 @@ export function Input({
|
|||||||
tokenCount={tokenCount}
|
tokenCount={tokenCount}
|
||||||
elapsedBaseMs={elapsedBaseMs}
|
elapsedBaseMs={elapsedBaseMs}
|
||||||
thinkingMessage={thinkingMessage}
|
thinkingMessage={thinkingMessage}
|
||||||
|
includeSystemPromptUpgradeTip={includeSystemPromptUpgradeTip}
|
||||||
agentName={agentName}
|
agentName={agentName}
|
||||||
interruptRequested={interruptRequested}
|
interruptRequested={interruptRequested}
|
||||||
networkPhase={networkPhase}
|
networkPhase={networkPhase}
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ const THINKING_VERBS = [
|
|||||||
"internalizing",
|
"internalizing",
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
export const SYSTEM_PROMPT_UPGRADE_TIP =
|
||||||
|
"Use /system to upgrade to the latest default prompt.";
|
||||||
|
|
||||||
export const THINKING_TIPS = [
|
export const THINKING_TIPS = [
|
||||||
"Use /remember [instructions] to remember something from the conversation.",
|
"Use /remember [instructions] to remember something from the conversation.",
|
||||||
"Use /palace to inspect your agent's memory palace.",
|
"Use /palace to inspect your agent's memory palace.",
|
||||||
@@ -51,6 +54,11 @@ export const THINKING_TIPS = [
|
|||||||
"Use /init to initialize (or re-init) your agent's memory.",
|
"Use /init to initialize (or re-init) your agent's memory.",
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
const THINKING_TIPS_WITH_SYSTEM_UPGRADE = [
|
||||||
|
...THINKING_TIPS,
|
||||||
|
SYSTEM_PROMPT_UPGRADE_TIP,
|
||||||
|
];
|
||||||
|
|
||||||
type ThinkingVerb = (typeof THINKING_VERBS)[number];
|
type ThinkingVerb = (typeof THINKING_VERBS)[number];
|
||||||
|
|
||||||
const PAST_TENSE_VERBS: Record<ThinkingVerb, string> = {
|
const PAST_TENSE_VERBS: Record<ThinkingVerb, string> = {
|
||||||
@@ -103,11 +111,6 @@ function getRandomVerb(): string {
|
|||||||
return THINKING_VERBS[index] ?? "thinking";
|
return THINKING_VERBS[index] ?? "thinking";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomTip(): string {
|
|
||||||
const index = Math.floor(Math.random() * THINKING_TIPS.length);
|
|
||||||
return THINKING_TIPS[index] ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a random thinking verb phrase (e.g., "is thinking", "is processing")
|
// Get a random thinking verb phrase (e.g., "is thinking", "is processing")
|
||||||
export function getRandomThinkingVerb(): string {
|
export function getRandomThinkingVerb(): string {
|
||||||
return `is ${getRandomVerb()}`;
|
return `is ${getRandomVerb()}`;
|
||||||
@@ -131,6 +134,16 @@ export function getRandomThinkingMessage(agentName?: string | null): string {
|
|||||||
return verb.charAt(0).toUpperCase() + verb.slice(1);
|
return verb.charAt(0).toUpperCase() + verb.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRandomThinkingTip(): string {
|
export function getRandomThinkingTip(options?: {
|
||||||
return getRandomTip();
|
includeSystemPromptUpgradeTip?: boolean;
|
||||||
|
}): string {
|
||||||
|
const tipPool =
|
||||||
|
(options?.includeSystemPromptUpgradeTip ?? true)
|
||||||
|
? THINKING_TIPS_WITH_SYSTEM_UPGRADE
|
||||||
|
: THINKING_TIPS;
|
||||||
|
if (tipPool.length === 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
const index = Math.floor(Math.random() * tipPool.length);
|
||||||
|
return tipPool[index] ?? "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test";
|
|||||||
import {
|
import {
|
||||||
getRandomThinkingMessage,
|
getRandomThinkingMessage,
|
||||||
getRandomThinkingTip,
|
getRandomThinkingTip,
|
||||||
|
SYSTEM_PROMPT_UPGRADE_TIP,
|
||||||
THINKING_TIPS,
|
THINKING_TIPS,
|
||||||
} from "../../cli/helpers/thinkingMessages";
|
} from "../../cli/helpers/thinkingMessages";
|
||||||
|
|
||||||
@@ -54,4 +55,12 @@ describe("Thinking messages", () => {
|
|||||||
expect(tip.length).toBeGreaterThan(0);
|
expect(tip.length).toBeGreaterThan(0);
|
||||||
expect((THINKING_TIPS as readonly string[]).includes(tip)).toBe(true);
|
expect((THINKING_TIPS as readonly string[]).includes(tip)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("can exclude /system upgrade tip from the selection pool", () => {
|
||||||
|
const tips = Array.from({ length: 50 }, () =>
|
||||||
|
getRandomThinkingTip({ includeSystemPromptUpgradeTip: false }),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(tips.every((tip) => tip !== SYSTEM_PROMPT_UPGRADE_TIP)).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user