The agent-hub application, built in Rust, manages AI agents on local machines and facilitates communication via Telegram groups. To address delivery failures when Telegram is unreachable, the developer implemented a dedicated response queue.

The system separates result generation from message delivery. Once an agent finishes a task, the hub saves the final text to a local file named topics.results.json. A background task then handles the delivery, allowing the process to resume after a restart without re-running the AI model.

The queue tracks progress using specific structures that store the result, message chunks, retry counts, and timestamps. To prevent infinite growth, the queue is limited to 50 pending responses and 8 MiB of content. Data is stored with 0600 permissions on Unix systems.

The system includes manual controls via Telegram commands. The /last command retrieves the most recent response, while /outbox allows users to view pending items and manually trigger retries or deletions. The hub also handles specific Telegram errors, such as RetryAfter, by respecting requested wait times.

The developer notes that the system does not guarantee exactly-once delivery, as network confirmation losses can lead to duplicate messages. The implementation includes automated tests covering scenarios like network outages, application restarts, and HTML formatting errors.