Skip to content

openChat adds leading space to command-only messages #737

@hakaru

Description

@hakaru

In openChat (agent.js L413), when a message contains only a command with no preceding text, the translation logic still concatenates a space before the command:

message = (await handleTranslation(to_translate)).trim() + " " + remaining;

When to_translate is an empty string (command-only message), this produces " !goal(...)" with a leading space. In only_chat_with + whisper environments, this malformed message can echo back to the bot, causing the LLM to hallucinate non-existent commands (e.g. !Code).

Suggested fix:

let translated = (await handleTranslation(to_translate)).trim();
message = translated ? translated + " " + remaining : remaining;

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