Skip to content

feat(vscode, cli): add system prompt inspection#7814

Closed
marius-kilocode wants to merge 5 commits intomainfrom
spectacular-artichoke
Closed

feat(vscode, cli): add system prompt inspection#7814
marius-kilocode wants to merge 5 commits intomainfrom
spectacular-artichoke

Conversation

@marius-kilocode
Copy link
Copy Markdown
Collaborator

@marius-kilocode marius-kilocode commented Mar 27, 2026

Summary

  • Adds a Show System Prompt button (glasses icon) to the VS Code extension chat header
  • Users can inspect the full assembled system prompt broken into collapsible sections by source (soul, provider prompt, environment, instruction files)
  • Each section shows its name, file path (if applicable), and content
  • Includes expand/collapse all and copy-to-clipboard actions
image image image

Changes

  • CLI server: New GET /session/:sessionID/system-prompt endpoint that assembles the prompt with source metadata via SystemPrompt.inspect()
  • SDK: Regenerated client.session.systemPrompt() method
  • Extension host: requestSystemPrompt message handler in KiloProvider
  • Webview: SystemPromptView component, button in TaskHeader, message types, CSS

How to test

  1. Open a session in the VS Code extension
  2. Send at least one message
  3. Click the glasses icon in the task header (next to the compact button)
  4. Verify the system prompt panel opens with collapsible sections
  5. Test expand/collapse all and copy buttons

Comment thread packages/kilo-vscode/src/KiloProvider.ts Outdated
Comment thread packages/kilo-vscode/webview-ui/src/components/chat/SystemPromptView.tsx Outdated
Comment thread packages/opencode/src/session/system.ts Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Mar 27, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/server/routes/session.ts 244 The system-prompt endpoint still returns separate segments even though LLM.stream() folds environment and instruction text into the first system string, so the inspector can drift from the prompt the model actually saw.
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
packages/kilo-docs/pages/code-with-ai/agents/chat-interface.md 89 The CLI tab documents Agent Manager and + / New Task controls that belong to the VS Code extension, so terminal users are pointed to UI that does not exist in the CLI.
Files Reviewed (12 files)
  • packages/kilo-docs/lib/nav/code-with-ai.ts - 0 issues
  • packages/kilo-docs/previous-docs-redirects.js - 0 issues
  • packages/kilo-docs/pages/code-with-ai/agents/chat-interface.md - 1 issue
  • packages/kilo-docs/pages/code-with-ai/agents/model-selection.md - 0 issues
  • packages/kilo-docs/pages/code-with-ai/agents/using-agents.md - 0 issues
  • packages/kilo-docs/pages/code-with-ai/platforms/cli.md - 0 issues
  • packages/kilo-docs/pages/getting-started/quickstart.md - 0 issues
  • packages/kilo-vscode/src/KiloProvider.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/chat/SystemPromptView.tsx - 0 issues
  • packages/opencode/src/server/routes/session.ts - 1 issue
  • packages/opencode/src/session/llm.ts - 0 issues
  • packages/opencode/src/session/system.ts - 0 issues

Reviewed by gpt-5.4-20260305 · 2,560,251 tokens

Comment thread packages/kilo-vscode/webview-ui/src/components/chat/SystemPromptView.tsx Outdated
Add a 'Show System Prompt' button (glasses icon) in the VS Code
extension chat header that lets users inspect the full assembled
system prompt with source metadata.

- Server: GET /session/:sessionID/system-prompt endpoint that
  assembles the prompt and returns each section (soul, provider,
  environment, instruction files) with provenance metadata
- SDK: regenerated client.session.systemPrompt() method
- Extension: KiloProvider handler + SystemPromptView component
  with collapsible sections, expand/collapse all, and copy
- Overlay layout: render panel inside messages area with absolute
  positioning so it never shifts the prompt input
- Session awareness: re-fetch on session switch, key responses by
  sessionID to prevent stale data from wrong session
- Workspace directory: pass directory for worktree session support
- Copy feedback: icon swaps to checkmark with green color for 1.5s
- i18n: add translated keys for all 18 locales (expand/collapse/copy/copied)
- Move promptOpen state from TaskHeader to ChatView
# Conflicts:
#	packages/kilo-vscode/webview-ui/src/types/messages.ts
* Uses VS Code CSS variables for theming
*/

/* ============================================
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a css file per components? this css file is becoming quite unwieldy

Comment thread packages/opencode/src/session/system.ts Outdated

/**
* Assemble the full system prompt with source metadata.
* Mirrors the assembly in LLM.stream() + SessionPrompt.loop()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fels tricky, how can we be sure this keeps in sync. I think if we dont actually reuse the logic this will only give peolpe a false feeling of safety/understanding

…y, extract CSS

- Extract SystemPrompt.header() used by both LLM.stream() and the
  inspection endpoint, eliminating duplicated assembly logic (Mark's
  review comment)
- Extract system-prompt.css from chat.css (Mark's review comment)
- Remove sources metadata - endpoint returns flat system[] array
  matching what LLM.stream() builds
- Simplify SystemPromptView to render segments directly
- Close panel when session is cleared (bot comment)
- Remove SystemPromptSource type
const identity = SystemPrompt.header({ model, agent })
const env = await SystemPrompt.environment(model, editorContext)
const instructions = await InstructionPrompt.system()
const system = [identity, ...env, ...instructions]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: This endpoint still does not mirror the prompt sent to the model

SessionPrompt.loop() builds input.system from environment() and InstructionPrompt.system(), and LLM.stream() folds that array into SystemPrompt.header(...extra), so the model receives a single combined system string. Returning [identity, ...env, ...instructions] here means the inspector/copy view can still drift from what the model actually saw.

agent: input.agent,
codex: isCodex,
extra: [...input.system, ...(input.user.system ? [input.user.system] : [])],
}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it better, but it is trickier to merge

@marius-kilocode
Copy link
Copy Markdown
Collaborator Author

@markijbema The technical debt might not be worth the feature. Let's reiterate on this later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants