Skip to content

Add optional per-agent concurrency ceilings alongside the global admission limit #3386

Closed

Description

@DanielLemoine

Problem

When an instance uses several configured agents, their available capacity can differ substantially. A local inference server might need to run one job at a time, while cloud-backed agents can handle several.

ProPR already has instance-wide physical agent admission, as well as worker and repository-workflow limits. I’d like to limit individual configured agents without lowering the entire instance’s capacity or reserving slots that other agents could use.

For example, with a global limit of six, an operator might allow up to three executions for one Claude agent, two for a Codex agent, and one for a local agent. These would be ceilings, not reserved shares.

Proposed behavior

  • Allow optional limits keyed by configured direct-agent alias. Models using the same alias share its limit; different configured aliases have independent limits.
  • Preserve the global limit and hosted entitlement as hard ceilings. An agent without its own limit remains subject to the global limit.
  • Extend the existing admission boundary so global and per-agent capacity are acquired atomically. Account for reservations and recovery as well as running containers, and do not reuse capacity while the old execution can still run.
  • Charge the actual selected direct agent across normal jobs, follow-ups, goals, analysis, synthetic selection and fallback. Invalid or ambiguous identities should fail clearly rather than silently bypass a cap.
  • If a queued agent is at capacity, defer the existing job without consuming its failure budget or indefinitely occupying a worker. Other eligible agents should still progress. Capacity exhaustion should not be treated as a provider failure or trigger fallback.
  • Preserve cancellation, deadlines and cleanup. Nested analysis should not deadlock behind a reservation held by its parent.
  • Provide diagnostics for global versus agent-specific waits and document safe configuration changes and rollback. Preserve existing behavior when no per-agent policy is configured.
    An initial operator-owned setting such as PROPR_AGENT_RUN_ALIAS_LIMITS would be sufficient. A UI could be a later enhancement.

Acceptance criteria

  • Real Redis contention tests across multiple execution processes enforce both ceilings.
  • A saturated agent does not prevent another eligible agent from progressing, including when capacity is held by an API-launched execution.
  • Cancellation, setup failure, crashes, lease loss and repeated delivery do not leak capacity or reuse it prematurely.
  • Synthetic selection and fallback charge the actual direct agent.
  • Docker-backed tests exercise launch, cleanup and recovery through the production wrappers. Required integration tests do not silently skip.
  • Diagnostics distinguish waiting, reserved, running and recovering work without exposing secrets.
    Current work

I have an AI-assisted local prototype based on the existing admission implementation. Independent review found correctness and integration issues that are still being addressed. It is not merge-ready or operationally qualified. I’m opening this issue to discuss the scope and upstream approach; I intend to propose a PR after the implementation and tests are ready.

Related: #2990 and #2992 for physical admission; #2987 and #2989 for worker and repository scheduling; and #2848, #2875 and #2879 for earlier unattended-run cap work.

Activity

  1. integry commented on Nov 2, 2026

    @integry
    Owner

    Thanks, Dan. Yes, we'd like this upstream. Per-agent capacity is a core primitive, and it's the per-agent part of the capacity work we described in #3385. Anyone mixing a local inference server with cloud agents hits this. Your acceptance criteria are the right bar, especially the real Redis contention tests and making sure a saturated agent can't starve the others.

    Some guidance before you take the prototype further:

    1. Extend the existing admission, don't add a second limiter.
    Global and per-agent capacity should be taken in a single atomic step in the admission script in packages/core/src/agents/agentRunAdmission.ts. Each holder record can store its agent alias, and acquire checks the alias count next to the existing total-count check, inside the same script. That way the reserve/attach/fence/recover lifecycle and its "never reuse until removal is confirmed" guarantee apply to the per-agent ceilings unchanged.

    2. Keep per-alias limits out of the admission configuration identity.
    The configuration identity is fenced today: changing it needs a generation bump and a drain. Per-alias ceilings shouldn't be part of it. Pass them with each acquire instead. Raising a ceiling is always safe, and lowering one only stops new admissions without stranding running work. Operators should be able to adjust these without draining. The global limit and the hosted entitlement keep their current fencing.

    3. Defer at job level; treat the container-create check as the backstop.
    Admission currently waits by polling at the container-create step, deep in execution and while holding a worker. That's acceptable for a global limit, but with per-agent ceilings it would let one saturated agent tie up workers other agents could use. Please split it into two layers:

    • Right after the actual direct agent is resolved (after synthetic selection and fallback), check that alias's capacity. If it's full, defer the job using the same pattern as repository-workflow deferral in src/jobs/repositoryWorkflow.ts: move the job to delayed with backoff, record one "waiting" row on the task timeline, and don't consume the failure budget. That pattern already gives the "not a provider failure, no fallback" behaviour you described.
    • The atomic acquire at container create stays the authoritative check. Losing a race there should be rare, so a short wait is acceptable.

    4. Nested analysis.
    Please define this explicitly. If a parent run holds an alias's only slot and starts nested analysis on the same alias, the nested run must not wait for the parent's slot. Either nested runs are charged under the parent's reservation, or the configuration is rejected with a clear error. We'd lean towards the first; tell us what you find.

    5. Identity and charging.
    Agreed that the charge goes to the actual selected direct agent, and that an invalid or ambiguous alias fails rather than bypassing the cap. Please validate PROPR_AGENT_RUN_ALIAS_LIMITS at startup against the configured aliases, so a typo doesn't silently leave an agent uncapped.

    6. Diagnostics and the capacity interface.
    Please report per-alias waiting/reserved/running/recovering counts through the existing admission metrics, and expose them through the capacity API and MCP tools. Goals and the dependency-aware scheduler from #3385 will build on that. Never expose secrets in them, as you noted.

    7. Scope and PRs.
    An env var with no UI is fine to start with. Configuring this from the UI can come later. Smaller PRs would be easier to review, for example:

    1. The atomic per-alias ceiling in the admission script, with real Redis contention tests.
    2. Job-level deferral and charging across the job types.
    3. Diagnostics and capacity reporting, plus docs on safe configuration changes and rollback.

    With no per-agent policy configured, behaviour must stay identical to today. Thanks for linking the earlier admission and scheduling issues, and for being upfront that the prototype isn't merge-ready yet.

  2. integry commented on Nov 20, 2026

    @integry
    Owner

    Hi Dan, an update: this shipped in 0.9.2 (current release is 0.9.3). We ended up building it ourselves while doing the scheduler work from #3385, along the lines discussed above.

    • Configuration: PROPR_AGENT_RUN_ALIAS_LIMITS=local-llama=1,claude-prod=3 on the API and every worker. Entries are direct agent aliases; an invalid value stops the process at startup, so a typo can't leave an agent uncapped. Without it, behaviour is unchanged.
    • Enforcement: global and per-agent capacity are taken in one atomic step in the existing admission script. Ceilings are not part of the fenced configuration identity, so raising, lowering or removing one needs no drain.
    • Waiting: a job whose agent is full is delayed in the queue and releases its worker. It consumes no retry, is not a provider failure and triggers no fallback. It shows one "Waiting for Agent Capacity" row on its timeline and is woken oldest first.
    • Charging: the actual direct agent is charged, including after synthetic selection. A synthetic agent skips a saturated member for another of the same priority tier.
    • Nested runs: a run started by a running parent on the same agent is charged under the parent, so a ceiling of one cannot deadlock. A nested run on another agent counts against that agent's ceiling. PROPR_AGENT_RUN_NESTED_LIMIT (default 4) bounds runs per parent.
    • Diagnostics: GET /api/agent-run-admission, MCP get_agent_run_admission and propr admission report per-agent ceiling, in-use and deferred counts.

    The operations guide is "Agent-run capacity" in the docs. A settings UI for ceilings is not there yet. If you had a prototype running, we'd be glad to hear where this behaves differently from what you needed, especially with a local inference server at a ceiling of one. I'll close this as implemented; please reopen or file a new issue for anything missing.

  3. DanielLemoine commented on Nov 20, 2026

    @DanielLemoine
    Author

    Thanks, Rinalds. I stopped working on my private implementation once I saw you were building this upstream, and shifted to a separate Coordinator that uses ProPR. I’ll use the native caps rather than maintain a second implementation.

    My target is two Claude runs, two Codex runs, and one local Qwen run. The cross-provider pilots ran sequentially, so I haven’t proven that mix under load yet. The local case I want to check is what happens when a second task queues behind the one Qwen slot while the cloud agents still have room, and how same-agent nested work behaves with that cap. I’ll report back if I find a difference from what you described.

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