Who it is forA developer whose agent produces long answers and who wants users to see text appear live in IM.
The problemWaiting for a full answer before sending makes chat feel slow, especially for long responses.
The outcomeA processor that yields DELTA events as tokens arrive and a COMPLETED event at the end, with the reply appearing progressively in the IM client.
What you need first
- Python 3.12+
- Credentials for each platform you connect, such as a Telegram bot token, Feishu app ID and secret, or a Discord bot token
- Access to the developer portal of each platform you use
- A processor function that reads InboundMessage and yields MessageEvent objects
Steps
- Run
pip install octop-gatewayin a Python 3.12+ environment. - Write an async generator processor that takes InboundMessage and yields MessageEvent objects.
- Inside the processor, yield a DELTA event for each token from your model, then yield a COMPLETED event when the stream ends.
- Wrap the processor in a ChannelManager and attach one channel, such as Telegram, using its config class.
- Send a prompt that asks for a long answer and confirm the reply updates while it is generated.
Prompt for your agent
Using the octop-gateway repo, write an async processor that streams tokens from <model client> as MessageEvent DELTA events and ends with COMPLETED, then attach it to a Telegram channel. Expected output: a chat reply that grows over time for a long prompt. Verify that an ERROR event is never yielded for a normal run.
Caveat. The README says DELTA streams tokens, but whether each platform shows partial text live depends on that platform's behavior, so test on your target channel.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for TencentCloud/octop-gateway and "Stream an LLM agent's reply token by token into chat"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer