Skip to content

Commit

Permalink
✨ Skip validators when we have depth 0 to speed up results (#597)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian von Feilitzsch <fabian@fabianism.us>
  • Loading branch information
fabianvf authored Jan 30, 2025
1 parent de6ca2e commit ac739af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .trunk/configs/custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ tgis
tiiuae
webmvc
prio
analyzerfix
analyzerfix
fabianvf
13 changes: 11 additions & 2 deletions kai/reactive_codeplanner/task_manager/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ def get_next_task(
max_priority: Optional[int] = None,
max_depth: Optional[int] = None,
) -> Generator[Task, Any, None]:
self.initialize_priority_queue()
# If we're being run at depth 0 and seed tasks have been set, don't bother running validators
seed_tasks_only = max_depth == 0 and self.priority_queue.has_tasks_within_depth(
0
)
if not seed_tasks_only:
self.initialize_priority_queue()

while self.priority_queue.has_tasks_within_depth(max_depth):
task = self.priority_queue.pop(max_depth=max_depth)
Expand All @@ -197,7 +202,11 @@ def get_next_task(

logger.info("Yielding task: %s", task)
yield task
self.handle_new_tasks_after_processing(task)
# If our depth is 0, we won't follow up on issues anyway
# We do lose the ability to verify a solution worked, so
# TODO(@fabianvf) we may have to adjust that at some point
if max_depth != 0:
self.handle_new_tasks_after_processing(task)

def initialize_priority_queue(self) -> None:
logger.info("Initializing task stacks.")
Expand Down

0 comments on commit ac739af

Please sign in to comment.