Skip to content

sessions_send: support optional role parameter to avoid rendering system messages as user messages #15778

@crossthebridgetpa

Description

@crossthebridgetpa

Problem

When using sessions_send to inject orchestration messages into agent sessions (e.g., task instructions, pre-compaction flushes), the messages always render as role: user in the session history. This means client-facing chat UIs display internal system messages as if the end user sent them.

Current Behavior

sessions_send(sessionKey, message) injects the message with role: user, making it visible in chat history alongside real user messages.

Expected Behavior

sessions_send should accept an optional role parameter (e.g., system, developer) so orchestration messages can be injected without appearing in the user-facing conversation history.

Use Case

Multi-agent orchestration where a parent agent sends task instructions to child agents that have client-facing chat UIs. Internal messages like:

  • SYSTEM TASK: Continue your deep learning session...
  • Pre-compaction memory flush...
  • Heartbeat polls

...should not be visible to end users.

Current Workaround

Client-side filtering in chat.html to hide messages matching known system prefixes (/^(SYSTEM|Pre-compaction|HEARTBEAT)/i). This is fragile and requires updating the regex for every new message pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions