feat: Add ReporterAgent_2, a dynamic frame-rate reporter #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ✨
asyncio.Queueand sends them in a single batch per frame.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.deltaEventswill 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:
How to Test 🧪
The agent can be tested by running it alongside the server and one or more chat clients.
Start the Server:
Start
ReporterAgent_2:Start one or more
ChatAgent_0clients:Test Scenario:
From a
ChatAgent_0terminal, send several messages in quick succession (e.g., within the same ~16ms time slice). You should observe that they are batched into a singledeltaEventsarray 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.