ChatApp with Bots
Reported by candidates from OpenAI's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
You're looking at OpenAI's May 2026 OA, and it's a design problem dressed up as a chat app. This isn't about algorithms; it's about object-oriented thinking, separation of concerns, and the ability to wire up extensible systems without tight coupling. You need channels, bots, message history, and a command dispatcher. The trick is that bots are stateless handlers that respond to specific triggers, and each channel owns its own history. If you blank on the architecture, StealthCoder can pull the skeleton out of the problem text in seconds.
The problem
Implement a small in-memory chat application that supports multiple channels and extensible bots. Each channel maintains its own message history and any bot state associated with that channel. The design should allow new bot types to be added without modifying the core chat logic. For this problem, process a list of commands: Assume two example bots exist: EchoBot replies with the same text it receives, and HelpBot replies with a help string when the message text is help. Function Description Complete the function runChatAppCommands in the editor below. runChatAppCommands has the following parameter: Returns String[]: the lines produced by all PRINT commands, in order. Each channel keeps an independent message log. EchoBot answers in channel A, while HelpBot answers in channel B. The same bot can respond multiple times inside the same channel, and channel history preserves insertion order.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern here is design and simulation. You're building a small event-driven system: commands come in (ADD_MESSAGE, CREATE_CHANNEL, REGISTER_BOT, PRINT), and you dispatch them to the right objects. Each channel is a container for messages and bot state. Bots are simple handlers (EchoBot echoes, HelpBot replies to 'help'). The key is making the bot interface flexible enough that you can add new bots without rewriting the dispatcher. Use a map of channel names to channel objects, and a map of bot types to bot instances per channel. When a message arrives, check each bot's condition and append its response. This is about clean code and object modeling, not complex algorithms. The live OA will reward readable structure and correct command handling. StealthCoder helps here as a sanity check on your command parsing if you second-guess yourself.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill ChatApp with Bots cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass OpenAI's OA.
OpenAI reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
ChatApp with Bots FAQ
Is this a hidden graph or DP problem?+
No. It's pure design and simulation. You're managing state (channels and messages) and dispatching commands. Focus on clear class boundaries, not algorithm tricks. The complexity is in the wiring, not the math.
What happens if a bot responds multiple times in the same channel?+
Each bot check is independent. If two bots both match the same message, both add responses to that channel's history in order. The problem states 'the same bot can respond multiple times inside the same channel,' so append all responses sequentially.
How do I keep bots extensible without modifying core logic?+
Use a common bot interface or base class with a method like 'canRespond(message)' and 'getResponse(message)'. Store bots in a list per channel. When a message arrives, iterate the list and call each bot's methods. New bots inherit the interface without touching the dispatcher.
What's the difference between bot state and channel history?+
Channel history is the log of all messages (user and bot replies) in insertion order. Bot state is internal to the bot (EchoBot is stateless; HelpBot just checks if the message is 'help'). Keep history separate from state to avoid confusion.
How do I handle PRINT commands?+
PRINT outputs the entire message history of a given channel. Store messages as you add them, then return the accumulated list when PRINT is called. Order matters; return them in the order they were added.