DEDUPED Hot AI repos, turned into use cases Get the Monday 5

How to stream an LLM agent's reply token by token into chat with Octop Gateway

Use DELTA events and a final COMPLETED event so users see the answer as it is generated.

Short answer: Run pip install octop-gateway in a Python 3.12+ environment; then 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. All steps.

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

  1. Run pip install octop-gateway in a Python 3.12+ environment.
  2. Write an async generator processor that takes InboundMessage and yields MessageEvent objects.
  3. Inside the processor, yield a DELTA event for each token from your model, then yield a COMPLETED event when the stream ends.
  4. Wrap the processor in a ChannelManager and attach one channel, such as Telegram, using its config class.
  5. 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

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer