Skip to content

[Feature Request] WebSocket event to replace system prompt mid-conversation #374

Description

@thisames

Problem

The current contextual_update WebSocket event appends context to the conversation state.
There is no way to replace the system prompt mid-conversation via WebSocket.

Use case

In voice agent applications with multi-step flows (e.g., debt negotiation), the agent transitions
through distinct phases — each requiring a completely different system prompt with different
instructions, constraints, and persona behavior. The previous prompt must be fully replaced,
not augmented, because:

  1. Conflicting instructions — the old prompt's rules may contradict the new phase's behavior
  2. Token waste — accumulated contextual_update injections bloat the context window with
    outdated instructions
  3. Non-deterministic behavior — when old and new prompts coexist, the LLM must resolve
    conflicts on its own, leading to inconsistent responses

Current workaround

We route the agent through a custom LLM proxy (customLlm) and intercept /v1/chat/completions
to swap the system message before it reaches the LLM. This works but:

  • Adds latency (extra network hop)
  • Requires maintaining proxy infrastructure
  • Doesn't work with native ElevenLabs LLMs (only custom-llm mode)
  • contextual_update is still sent as a fallback but doesn't truly replace the prompt

Proposed solution

A new client-to-server WebSocket message type (e.g., prompt_override) that replaces the
active system prompt:

{
  "type": "prompt_override",                                                                     
  "text": "You are now in phase 2. Your new instructions are..."                               
}

Expected behavior

- The previous system prompt is discarded
- The new text becomes the sole system prompt for all subsequent LLM calls
- Works with both native ElevenLabs LLMs and custom-llm mode                                     
- Does not interrupt the ongoing conversation or TTS output
                                                                                                 
Alternative: replace mode on contextual_update                                                   
 
If adding a new message type is not desirable, a mode flag on the existing contextual_update     
would also solve this:                                                                         

{
  "type": "contextual_update",
  "text": "New full system prompt...",                                                           
  "mode": "replace"
}                                                                                                
                                                                                               
Where mode defaults to "append" (current behavior) for backwards compatibility.                  

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttrackingFeature request being monitored for interest, upvote to show supportupstreamIssue originates from upstream or generated code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions