Skip to content

Conversation

@definenoob
Copy link

This is an agent designed for high-frequency, event-based "games." Its primary job is to keep track of time with respect to events and also their relative ordering.


This pull request introduces ReporterAgent_2, a high-performance, frame-based agent that aggregates incoming messages and emits them in a consolidated JSON payload.

The primary feature of this agent is its dynamic frame rate. It maintains a steady "heartbeat" at a target FPS (e.g., 60 FPS) when idle. However, when messages are being actively received, it processes and sends frames as quickly as possible to minimize latency. This hybrid approach makes it ideal for applications that require both a consistent state update and low-latency handling of event bursts.


Key Features ✨

  • Frame-Based Aggregation: Buffers all incoming messages using an internal asyncio.Queue and sends them in a single batch per frame.
  • Dynamic FPS:
    • Targets a configured FPS (e.g., 60) when no messages are being received, providing a consistent heartbeat.
    • Runs at maximum possible speed when the message buffer is not empty, ensuring high-frequency events are processed with minimal delay.
  • Structured JSON Payload: Emits a standard JSON object on every frame, containing:
    • frameNumber: A monotonically increasing integer for frame identification.
    • deltaEvents: A list of string messages collected during the frame.
    • deltaTiming: The elapsed time for the frame in nanoseconds.
  • Continuous Heartbeat: Sends a payload even on frames with no new messages (deltaEvents will be an empty list), which is useful for confirming system liveness and for downstream clients that expect a continuous data stream.

Use Cases 🎯

This agent is particularly well-suited for:

  • Real-time game state synchronization.
  • Aggregating high-frequency sensor data or user inputs.
  • Monitoring systems that require both regular status updates and rapid alert propagation.
  • Any scenario where individual message latency is critical, but batching is desirable for network efficiency.

How to Test 🧪

The agent can be tested by running it alongside the server and one or more chat clients.

  1. Start the Server:

    python server.py
  2. Start ReporterAgent_2:

    python agents/agent_ReportAgent_2/agent.py
  3. Start one or more ChatAgent_0 clients:

    python agents/agent_ChatAgent_0/agent.py

Test Scenario:
From a ChatAgent_0 terminal, send several messages in quick succession (e.g., within the same ~16ms time slice). You should observe that they are batched into a single deltaEvents array in the JSON payload received back by the chat clients. If you wait for a second and send another message, it will arrive in a subsequent frame's payload. This demonstrates the agent's ability to group temporally close events.

@definenoob definenoob requested a review from remytuyeras October 7, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants