refactor: centralize concurrency resolution

This commit is contained in:
Peter Steinberger
2026-01-20 10:37:43 +00:00
parent e110cf4fb1
commit 0f9f510dd9
5 changed files with 88 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
import { type RunOptions, run } from "@grammyjs/runner";
import type { ClawdbotConfig } from "../config/config.js";
import { loadConfig } from "../config/config.js";
import { DEFAULT_AGENT_MAX_CONCURRENT } from "../config/agent-limits.js";
import { resolveAgentMaxConcurrent } from "../config/agent-limits.js";
import { computeBackoff, sleepWithAbort } from "../infra/backoff.js";
import { formatDurationMs } from "../infra/format-duration.js";
import type { RuntimeEnv } from "../runtime.js";
@@ -29,7 +29,7 @@ export type MonitorTelegramOpts = {
export function createTelegramRunnerOptions(cfg: ClawdbotConfig): RunOptions<unknown> {
return {
sink: {
concurrency: cfg.agents?.defaults?.maxConcurrent ?? DEFAULT_AGENT_MAX_CONCURRENT,
concurrency: resolveAgentMaxConcurrent(cfg),
},
runner: {
fetch: {