Skip to content

[BUG]: supertask not respecting max agents #2497

Description

@jessevz

Version Information

1.0.1

Hashcat

7

Description

Sometimes it happens that a supertask with a max agents for example 10, more agents will jump on it. I suspect that the reason is, is that the function: isSaturatedByOtherAgents() will check how many agents are assigned to a task and compare that to the max agents of that single task. but it does not check if there are already too much agents working on the supertask. this only happens in the getChunk endpoint (when an agent is already assigned to a task), because here it is run like this:

        if (TaskUtils::isSaturatedByOtherAgents($task, $agent)) {

Only on the current assigned task, without checking the taskwrapper.

In the gettaskAction there is a wrapper in the form of getcanidatetasks, which will run this function for every task of a taskwrapper:

  private static function getCandidateTasks(Agent $agent, array $accessGroups, TaskWrapper $taskWrapper): array {
    $totalAssignments = 0;
    $candidateTasks = [];
    
    // load assigned tasks for this TaskWrapper
    $qF = new QueryFilter(Task::TASK_WRAPPER_ID, $taskWrapper->getId(), "=");
    $oF = new OrderFilter(Task::PRIORITY, "DESC");
    $tasks = Factory::getTaskFactory()->filter([Factory::FILTER => $qF, Factory::ORDER => $oF]);
    foreach ($tasks as $task) {
      // count number of other agents already working on the task,
      // no tasks can be candidates if limit is already reached
      $totalAssignments += self::numberOfOtherAssignedAgents($task, $agent);
      if ($taskWrapper->getMaxAgents() > 0 && $totalAssignments >= $taskWrapper->getMaxAgents()) {
        return [];
      }

where is called on every task numberOfOtherAssignedAgents

This is especially a problem since most of the times in a supertask, the max agents of a single sub task are set to zero, which makes the task claim every available agent on that priority

Activity

  1. added
    bugSomething isn't working
    serverHashtopolis API/Server related
    on Sep 16, 2026
  2. self-assigned this
    on Sep 16, 2026
  3. zyronix commented on Sep 17, 2026

    @zyronix
    Member

    I think this should pretty much solved the issue:

    +++ b/src/inc/utils/TaskUtils.class.php
    @@ -1387,6 +1387,34 @@ class TaskUtils {
       public static function isSaturatedByOtherAgents($task, $agent) {
         $numAssignments = self::numberOfOtherAssignedAgents($task, $agent);
         return ($task->getIsSmall() == 1 && $numAssignments > 0) || // at least one agent is already assigned here
    -      ($task->getMaxAgents() > 0 && $numAssignments >= $task->getMaxAgents()); // at least maxAgents agents are already assigned
    +      ($task->getMaxAgents() > 0 && $numAssignments >= $task->getMaxAgents()) || // at least maxAgents agents are already assigned
    +      self::isWrapperSaturatedByOtherAgents($task, $agent); // the TaskWrapper of this task is full
    +  }
    +
    +  /**
    +   * Check if the TaskWrapper has enough agents - apart from the given
    +   *
    +   * Without this check the wrapper limit is only applied in getCandidateTasks(). Thus agents who were already running, are never released. An agent who was already assigned never passes  which is already assigned never passes there
    +   *
    +   * @param Task $task
    +   * @param Agent $agent
    +   * @return boolean true if maxAgents != 0 and number of assigned agents >= maxAgents, false otherwise
    +   */
    +  public static function isWrapperSaturatedByOtherAgents($task, $agent) {
    +    $taskWrapper = Factory::getTaskWrapperFactory()->get($task->getTaskWrapperId());
    +    if ($taskWrapper == null || $taskWrapper->getMaxAgents() <= 0) {
    +      return false; // no wrapper limit configured
    +    }
    +    $qF = new QueryFilter(Task::TASK_WRAPPER_ID, $taskWrapper->getId(), "=");
    +    $tasks = Factory::getTaskFactory()->filter([Factory::FILTER => $qF]);
    +    $numAssignments = 0;
    +    foreach ($tasks as $wrapperTask) {
    +      $numAssignments += self::numberOfOtherAssignedAgents($wrapperTask, $agent);
    +    }
    +    return $numAssignments >= $taskWrapper->getMaxAgents();
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingserverHashtopolis API/Server related

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions