Skip to content

TaskManager: タスクに weight を持たせて concurrency を「重みの合計」で制御したい #1312

Description

@isamu

Background

現在の concurrency は「同時実行 数」を制限する。だが実用上、タスクの重さは大きく異なる:

  • 軽い string 処理(数ミリ秒、CPU 数%)
  • 重い LLM 呼び出し(数秒〜数十秒、メモリ大)

「同時実行数3」で揃えると、軽いタスクが詰まれば余裕、重いタスクが詰まれば過負荷、という不均衡が起きる。

Proposal

各 node に weight?: number(デフォルト 1)を追加。TaskManager は実行中タスクの重みの合計が concurrency を超えないようにする。

nodes:
  heavy_llm:
    agent: openaiAgent
    weight: 5    # 重い処理として5枠を消費
  light_template:
    agent: stringTemplateAgent
    weight: 1    # (省略可、デフォルト 1)

concurrency: 10  # = 重み合計の上限

Why

Scope

  • ComputedNodeData に weight?: number 追加(type.ts)
  • TaskManager の runningNodes.size チェックを runningWeight チェックに変更
  • 後方互換(weight 未指定なら従来通り 1)
  • ユニットテスト追加(重い weight が他をブロックすること、weight 合計が limit を超えないこと)

Out of scope

  • 動的 weight(agent 実行結果から weight を計算)
  • weight に応じたタイムアウト調整

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions