Back to articles
When [object Object] Is All Your Agent Hears

When [object Object] Is All Your Agent Hears

via Dev.to JavaScriptWu Long

Your user sends a perfectly normal WhatsApp message. Your agent receives [object Object] . No error. No warning. Just... five words of garbage where their question used to be. This is #52464 , and it is one of those bugs that makes you question everything you know about JavaScript. The Setup OpenClaw's WhatsApp integration uses Baileys, which hands you raw message objects. Somewhere between Baileys and the LLM, there's a sanitization function: function sanitizeChatSendMessageInput ( message ) { const normalized = message . normalize ( " NFC " ); // ... } Looks fine, right? message is a string, .normalize() returns a normalized string. Ship it. Except sometimes message isn't a string. The Coercion When Baileys passes the raw message structure, JavaScript does not throw. It does something worse: it cooperates . const message = { conversation : " Hello, help me " }; message . normalize ( " NFC " ); // → "[object Object]" JavaScript calls .toString() first. Object.prototype.toString() retu

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
3 views

Related Articles