fix: allow messages starting with / to be sent to agent when unknown (#625)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Kian Jones
2026-01-21 21:36:21 -08:00
committed by GitHub
parent 0c5f53bdd2
commit 1968059434
3 changed files with 2116 additions and 36 deletions

2103
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -6033,26 +6033,16 @@ ${SYSTEM_REMINDER_CLOSE}`;
}
// === END custom command handling ===
// Immediately add command to transcript with "running" phase
const cmdId = uid("cmd");
buffersRef.current.byId.set(cmdId, {
kind: "command",
id: cmdId,
input: msg,
output: "",
phase: "running",
});
buffersRef.current.order.push(cmdId);
refreshDerived();
// Check if this is a known command before treating it as a slash command
const { executeCommand } = await import("./commands/registry");
const result = await executeCommand(aliasedMsg);
// Lock input during async operation
setCommandRunning(true);
try {
const { executeCommand } = await import("./commands/registry");
const result = await executeCommand(msg);
// Update the same command with result
// If command not found, fall through to send as regular message to agent
if (result.notFound) {
// Don't treat as command - continue to regular message handling below
} else {
// Known command - show in transcript and handle result
const cmdId = uid("cmd");
buffersRef.current.byId.set(cmdId, {
kind: "command",
id: cmdId,
@@ -6061,24 +6051,10 @@ ${SYSTEM_REMINDER_CLOSE}`;
phase: "finished",
success: result.success,
});
buffersRef.current.order.push(cmdId);
refreshDerived();
} catch (error) {
// Mark command as failed if executeCommand throws
const errorDetails = formatErrorDetails(error, agentId);
buffersRef.current.byId.set(cmdId, {
kind: "command",
id: cmdId,
input: msg,
output: `Failed: ${errorDetails}`,
phase: "finished",
success: false,
});
refreshDerived();
} finally {
// Unlock input
setCommandRunning(false);
return { submitted: true }; // Don't send commands to Letta agent
}
return { submitted: true }; // Don't send commands to Letta agent
}
// Build message content from display value (handles placeholders for text/images)

View File

@@ -384,7 +384,7 @@ export const commands: Record<string, Command> = {
*/
export async function executeCommand(
input: string,
): Promise<{ success: boolean; output: string }> {
): Promise<{ success: boolean; output: string; notFound?: boolean }> {
const [command, ...args] = input.trim().split(/\s+/);
if (!command) {
@@ -399,6 +399,7 @@ export async function executeCommand(
return {
success: false,
output: `Unknown command: ${command}`,
notFound: true,
};
}