Reported September 2026
OpenAIheap priority queue

Dependency-Aware Agent Task Scheduler

Reported by candidates from OpenAI's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live OpenAI OA. Under 2s to a working solution.
Founder's read

The data structure this OpenAI problem hinges on is a min-heap sitting on top of a topological sort. It was reported in September 2026, and it looks like a scheduler but it's really Kahn's algorithm with a cap per round. You get n unit tasks, explicit prerequisites, and a hidden extra chain per agent that forces input order. Each round you run at most concurrencyLimit ready tasks, smallest IDs first. If you've got the OA in a day or two, this is the shape to recognize. StealthCoder is the invisible backup if your head goes blank mid-assessment.

The problem

You are given n unit-duration tasks numbered from 0 to n - 1. Each task is assigned to one of agentCount agents by taskAgents[i].
A pair [before, after] in prerequisites means that task before must finish before task after can start. In addition, tasks assigned to the same agent must run in their input order: for each agent, every task depends on the previous lower-indexed task assigned to that agent.
Execution proceeds in synchronous rounds. At the start of a round, a task is ready when all of its explicit and same-agent prerequisites finished in earlier rounds. Schedule at most concurrencyLimit ready tasks in a round, choosing the smallest task IDs when more tasks are ready than the limit. All selected tasks finish at the end of that round.
Return the scheduled task IDs for every round. IDs inside each round must be ascending.

Function
scheduleTasks(agentCount: int, concurrencyLimit: int, taskAgents: int[], prerequisites: int[][]) → int[][]

Examples
Example 1
agentCount = 2
concurrencyLimit = 2
taskAgents = [0,1,0,1]
prerequisites = [[0,3]]
return = [[0,1],[2,3]]
Tasks 0 and 1 are initially ready. Their completion unlocks the next task for each agent, so tasks 2 and 3 run together.
Example 2
agentCount = 3
concurrencyLimit = 2
taskAgents = [0,1,2,0,1]
prerequisites = [[0,2],[1,2],[2,3],[2,4]]
return = [[0,1],[2],[3,4]]
The first two tasks run at the limit. Task 2 then becomes ready by itself, and its completion unlocks tasks 3 and 4.
Example 3
agentCount = 2
concurrencyLimit = 1
taskAgents = [0,1,0]
prerequisites = []
return = [[0],[1],[2]]
Only one task may run per round. When tasks 1 and 2 are both ready, the smaller ID runs first.

Constraints
1 <= agentCount <= n <= 2000.
1 <= concurrencyLimit <= agentCount.
taskAgents.length == n.
0 <= taskAgents[i] < agentCount.
0 <= prerequisites.length <= 5000.
Every prerequisite is a distinct pair [before, after] with valid, different task IDs.
The graph formed by explicit prerequisites and same-agent ordering is acyclic.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Build the graph first. Add every explicit [before, after] edge, then add an edge from each task to the next task on the same agent, tracked with a last-seen array per agent. Compute indegrees. Put every indegree-zero task in a min-heap. Each round, pop up to concurrencyLimit tasks, sort them ascending, and record them. Only after the whole round is chosen do you decrement indegrees and push newly freed tasks. That's the classic pitfall: releasing a task mid-round lets it run in the same round, which breaks the synchronous rule. Tasks you didn't pick stay in the heap for the next round. Duplicate edges between the explicit and agent chains are fine since indegree counts both consistently. Complexity is O((n + E) log n). StealthCoder is the hedge on the live OA if the round-boundary detail slips away from you.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Dependency-Aware Agent Task Scheduler cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass OpenAI's OA.

OpenAI reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Dependency-Aware Agent Task Scheduler FAQ

What's the trick in the Dependency-Aware Agent Task Scheduler?+

Treat it as Kahn's topological sort with a min-heap and a per-round cap. The hidden part is the same-agent ordering, which is just extra edges from each task to the next task of that agent. Add those, then simulate rounds.

Why can't I unlock new tasks as I pop them?+

Rounds are synchronous. A task only becomes ready after its prerequisites finished in an earlier round. So pop your batch, record it, and only then decrement indegrees and push the newly ready tasks for the next round.

Do I need a heap or is a plain queue enough?+

You need ordering by smallest ID when more tasks are ready than the limit. A plain FIFO queue can give wrong picks. A min-heap is the clean choice. Sorting the ready list each round also works at n up to 2000, just slower.

How hard is this really?+

Medium. Anyone who knows course-schedule style topological sort can do it. The traps are the implicit agent edges and the round boundary. Run the three examples by hand and you'll catch both.

How do I prepare in 48 hours?+

Write Kahn's algorithm from memory twice. Then add a heap and a per-round limit to it. Test on example 2, where the round has one task, and example 3, where the limit forces smallest-ID ordering. That covers nearly every edge case here.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with OpenAI.

OA at OpenAI?
Invisible during screen share
Get it