Skip to content

Add excludeFromContext to custom messages sent via sendMessage() #5654

@zachmeador

Description

@zachmeador

What do you want to change?

Add excludeFromContext?: boolean to CustomMessage / pi.sendMessage(), mirroring the flag that bash-execution messages already have. convertToLlm would skip flagged custom messages the same way it already skips !! bash executions.

Why?

I have a /status command that prints a status panel into the chat. Today it works by patching InteractiveMode internals, and I want it to be a plain extension command instead.

Extension commands are supposed to produce output through sendMessage(), and together with registerMessageRenderer() that gives me a persistent, custom-rendered block in chat. The problem is that every custom message is also converted into a user message for the LLM. So the status panel ends up in model context, where it is just noise.

Built-in commands like /session and /changelog can print to chat without the model seeing it. Extension commands have no way to do the same. This flag would close that gap: output persisted in the session, rendered in the TUI, skipped for LLM calls.

How? (optional)

Three small changes: the flag on CustomMessage in core/messages.ts, a skip in convertToLlm's "custom" case, and plumbing through the sendMessage signatures in core/extensions/types.ts. Same shape as #5039, which added this flag to the bash RPC command. Happy to implement it if approved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions