Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/coding-agent/src/core/slash-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const CANONICAL_BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [
{ name: "copy", description: "Copy last agent message to clipboard" },
{ name: "name", description: "Set session display name" },
{ name: "session", description: "Show session info" },
{ name: "system-prompt", description: "Show the exact system prompt sent to the model" },
{ name: "logs", description: "Show where daemon and client logs are saved" },
{
name: "traces",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,14 @@ export class DaemonAgentConnection implements AgentConnection {
return data.text ?? undefined;
}

async getSystemPrompt(): Promise<string> {
const data = await this.requestData<{ systemPrompt: string }>({
type: "get_system_prompt",
activeSessionId: this.activeSessionId,
});
return data.systemPrompt;
}

async getToolDefinition(name: string): Promise<AgentConnectionToolDefinition | undefined> {
const data = await this.requestData<{ toolDefinition?: AgentConnectionToolDefinition }>({
type: "get_tool_definition",
Expand Down Expand Up @@ -832,6 +840,7 @@ function invalidatesCachedSnapshot(commandType: DaemonCommandBody["type"]): bool
case "get_session_tree":
case "get_user_messages_for_forking":
case "get_last_assistant_text":
case "get_system_prompt":
case "get_tool_definition":
case "export_html":
case "export_jsonl":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ export class DeferredAgentConnection implements AgentConnection {
return this.real ? this.real.getLastAssistantText() : undefined;
}

async getSystemPrompt(): Promise<string> {
return this.real ? this.real.getSystemPrompt() : "";
}

async getToolDefinition(name: string): Promise<AgentConnectionToolDefinition | undefined> {
return this.real ? this.real.getToolDefinition(name) : undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ export class InProcessAgentConnection implements AgentConnection {
return this.session.getLastAssistantText();
}

async getSystemPrompt(): Promise<string> {
return this.session.systemPrompt;
}

async getToolDefinition(name: string): Promise<AgentConnectionToolDefinition | undefined> {
return createAgentConnectionToolDefinition(this.session.getToolDefinition(name));
}
Expand Down
2 changes: 2 additions & 0 deletions packages/coding-agent/src/modes/agent-connection/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ export interface AgentConnection {
updateHeartbeat(action: AgentHeartbeatUpdateAction): Promise<AgentCronJob | undefined>;
getUserMessagesForForking(): Promise<AgentConnectionUserMessage[]>;
getLastAssistantText(): Promise<string | undefined>;
/** The system prompt currently in effect for the model (with any per-turn extension changes). */
getSystemPrompt(): Promise<string>;
getToolDefinition(name: string): Promise<AgentConnectionToolDefinition | undefined>;
setSessionEntryLabel(entryId: string, label: string | undefined): Promise<void>;
respondToExtensionUiRequest(requestId: string, response: AgentConnectionExtensionUiResponse): Promise<void>;
Expand Down
8 changes: 8 additions & 0 deletions packages/coding-agent/src/modes/daemon/daemon-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const DAEMON_COMMAND_TYPES: ReadonlySet<string> = new Set([
"get_session_tree",
"get_user_messages_for_forking",
"get_last_assistant_text",
"get_system_prompt",
"get_tool_definition",
"set_session_entry_label",
"extension_ui_response",
Expand Down Expand Up @@ -1379,6 +1380,13 @@ export class AgentDaemon {
});
}

case "get_system_prompt": {
const state = this.getSessionState(command.activeSessionId);
return success(command.id, "get_system_prompt", {
systemPrompt: state.runtime.session.systemPrompt,
});
}

case "get_tool_definition": {
const state = this.getSessionState(command.activeSessionId);
return success(command.id, "get_tool_definition", {
Expand Down
1 change: 1 addition & 0 deletions packages/coding-agent/src/modes/daemon/daemon-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export type DaemonCommand =
| { id?: string; type: "get_session_tree"; activeSessionId: string }
| { id?: string; type: "get_user_messages_for_forking"; activeSessionId: string }
| { id?: string; type: "get_last_assistant_text"; activeSessionId: string }
| { id?: string; type: "get_system_prompt"; activeSessionId: string }
| { id?: string; type: "get_tool_definition"; activeSessionId: string; name: string }
| { id?: string; type: "set_session_entry_label"; activeSessionId: string; entryId: string; label?: string }
| {
Expand Down
16 changes: 16 additions & 0 deletions packages/coding-agent/src/modes/interactive/interactive-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3334,6 +3334,11 @@ export class InteractiveMode {
this.editor.setText("");
return;
}
if (commandName === "system-prompt" && !commandArgs) {
await this.handleSystemPromptCommand();
this.editor.setText("");
return;
}
if (commandName === "traces") {
await this.handleTracesCommand(canonicalCommandText);
this.editor.setText("");
Expand Down Expand Up @@ -6715,6 +6720,17 @@ export class InteractiveMode {
this.ui.requestRender();
}

private async handleSystemPromptCommand(): Promise<void> {
const prompt = await this.agentConnection.getSystemPrompt();
const header = `${theme.bold("System Prompt")} ${theme.fg("dim", `(${prompt.length} chars)`)}`;

this.chatContainer.addChild(new Spacer(1));
this.chatContainer.addChild(new Text(header, 1, 0));
this.chatContainer.addChild(new Spacer(1));
this.chatContainer.addChild(new Text(prompt, 1, 0));
this.ui.requestRender();
}

private formatTraceUploadResult(result: AgentTraceUploadResult): string {
switch (result.status) {
case "uploaded":
Expand Down