Skip to content

feat: add S hotkey to apply agent prompt as system override mid-session#812

Open
lenam2001 wants to merge 1 commit intocan1357:mainfrom
lenam2001:feat/agent-prompt-override
Open

feat: add S hotkey to apply agent prompt as system override mid-session#812
lenam2001 wants to merge 1 commit intocan1357:mainfrom
lenam2001:feat/agent-prompt-override

Conversation

@lenam2001
Copy link
Copy Markdown

Feature: Apply Agent System Prompt Mid-Session (S hotkey)

Problem

The /agents dashboard in oh-my-pi currently only supports:

  • Enable/disable agent (Space)
  • Edit model override (Enter)
  • Create new agent (N)

There is no way to apply an agent's system prompt into the current session to switch persona mid-session (e.g., librarian → coordinator → tutor).

Solution

Add hotkey S in the Agent Dashboard to apply the selected agent's system prompt into the current active session.

Files Modified

File Change
packages/coding-agent/src/modes/components/agent-dashboard.ts onApplySystemPrompt callback, #applySelectedAgentPrompt(), S hotkey handler, footer hint
packages/coding-agent/src/modes/controllers/selector-controller.ts Wire onApplySystemPromptsession.applyAgentSystemPrompt()
packages/coding-agent/src/session/agent-session.ts Add applyAgentSystemPrompt(agentName, prompt) — updates agent.setSystemPrompt() + persists custom_message entry

Design Decisions

  • Callback bridge between AgentDashboard (UI) and AgentSession (logic) to preserve separation of concerns
  • custom_message entry with display: false to avoid cluttering the TUI
  • Model remains unchanged — only system prompt is overridden (use Enter if model switch is also needed)

Verification

  • TypeScript compile (bun tsc --noEmit): pass
  • Biome check + tsgo (bun run check): pass (962 files, no errors)
  • Full repo build: blocked by Rust native compilation (pi_natives) on Windows
  • Unit tests: blocked by native addon load failure on Windows
  • Runtime test in live omp session: pending

Agent Workflow Context

This feature enables the multi-agent orchestration pattern used in OpenCode-style configurations where agents transition through roles mid-session:

  1. 1st_librarian — discovers context
  2. 2nd_coordinator — plans and delegates
  3. 3rd_tutor — teaches and explains

With the S hotkey, users can now fluidly switch between these personas without restarting the session.

Next Steps

  • Maintainer review
  • Runtime verification in live omp session: /agents → select agent → press S → confirm system prompt switch

@lenam2001
Copy link
Copy Markdown
Author

📎 Related discussion thread opened at #813 for broader feedback on multi-agent persona switching workflows.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0e4b16374

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

* Updates the agent's system prompt and appends a custom message entry.
*/
applyAgentSystemPrompt(agentName: string, prompt: string): void {
this.agent.setSystemPrompt(prompt);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Persist applied prompt as the session base prompt

Updating only agent.setSystemPrompt(prompt) here makes the S hotkey ineffective for sessions that have an extension runner: before each user prompt, emitBeforeAgentStart falls back to this.#baseSystemPrompt and overwrites the applied prompt (agent-session.ts around lines 2757-2760). In that environment, users will see “Applied ... agent prompt” but the next turn runs with the old base prompt, so the feature silently fails unless #baseSystemPrompt is updated too.

Useful? React with 👍 / 👎.

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.

1 participant