Your question is Rate Limit Agent Tool Calls. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
In a Databricks Agent Framework deployment, tool calls from multiple agents are logged as a time-ordered stream. Implement an algorithm that returns the first timestamp when any agent exceeds a sliding-window limit, using standard data structures efficiently.
Given a list of events events, where each event is [timestamp, agent_id], and integers window_size and max_calls, return the earliest timestamp at which some agent_id has made more than max_calls calls within the inclusive window [timestamp - window_size + 1, timestamp]. If no agent violates the limit, return -1.
def first_rate_limit_violation(events, window_size, max_calls):