Skip to content

[2848 by Claude Opus 5.5] Agents: unattended concurrency cap and local-time window in the run cost gate - #2875

Merged
integry merged 1 commit into
mainfrom
2848/claude-opus-5-5-agents-unattended-concurr-20261007-2226-r44
Oct 8, 2026
Merged

integry merged 1 commit into
mainfrom
2848/claude-opus-5-5-agents-unattended-concurr-20261007-2226-r44

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #2848

Branch: 2848/claude-opus-5-5-agents-unattended-concurr-20261007-2226-r44
Commits: ✅ Changes committed (d3d3396)


AI Processing Completed

Execution Details:

Summary:
I'll wait for that notification.

Detailed Logs:

  • Conversation: 245 messages
  • Session: 514e39bf-cfe2-41be-bde8-f86411998ccb

Log files stored at:

  • conversation: /tmp/claude-logs/issue-2848-2026-10-07T22-53-08-481Z-conversation.json
  • output: /tmp/claude-logs/issue-2848-2026-10-07T22-53-08-481Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: I'll wait for that notification.


This PR was created automatically by ProPR after processing issue #2848.


💡 Need changes?

Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!

@integry

integry commented Oct 8, 2026

Copy link
Copy Markdown
Owner

/review

@propr-dev

propr-dev Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR adds unattended admission controls across the core gate, settings, CLI, MCP, and UI. It needs significant correctness fixes before merge: concurrent admissions can exceed the cap, automatic acting can reacquire an unreserved slot, and successful settings saves can erase another field’s draft.

✅ Window handling — Shared parsing supports overnight windows and timezone-aware boundaries, with tests covering DST transitions.

✅ Uncounted window waits — Initial deferrals and deferred retries both preserve the deferral budget for pure window waits.

✅ Cross-surface configuration — Settings validation, CLI parsing, MCP configuration, and malformed-window warnings are implemented consistently.

The supplied current-head status reports 41 passed checks and no failures or pending checks. This review uses static analysis; no commands were run.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 Make concurrency admission atomic

  • Required behavior: The instance-wide unattended concurrency cap must prevent simultaneous admissions from exceeding the configured maximum.

  • Evidence: packages/core/src/services/agents/agentRunUnattendedLimits.ts, evaluateUnattendedLimits; packages/core/src/services/agents/agentRunTrigger.ts, triggerAgentRun; packages/core/src/services/agents/agentRunDeferredRetry.ts, retryDeferredRun.

    1. Set the cap to 1 with no active runs, then send two unattended API requests with distinct idempotency keys.
    2. Both requests enter the gate and await countActiveUnattendedRuns() inside Promise.all. Both count queries can complete with zero before either request inserts its run.
    3. Both gates return proceed; their subsequent createAgentRun calls independently insert queued runs.
    4. Both runs are dispatched, leaving two active unattended runs under a cap of 1.

    The count and insertion are separate operations without a shared admission lock or atomic capacity reservation. Idempotency protects duplicate keys, not these distinct requests. Deferred retries have the same separation between gate evaluation and transition to queued; their compare-and-set protects an individual deferred row, not instance capacity. The new integration test admits runs sequentially, so it does not exercise this sequence.

    static trace: The supplied gate, trigger, and retry implementations establish this interleaving; no concurrency test was executed.

  • Minimum fix: Serialize capacity checking and slot acquisition through a database-backed admission operation shared by new triggers and deferred retries. Add a regression covering simultaneous distinct admissions and a retry competing with a new trigger.

F2: 🔴 Preserve capacity across automatic acting

  • Required behavior: Runs whose trigger is not manual must remain within the cap while queued, running, or acting.

  • Evidence: packages/core/src/services/agents/agentRunCostGate.ts, isAdmission and the !isAdmission(context.run) bypass; packages/core/src/services/agents/agentRunStore.ts, ACTIVE_AGENT_RUN_STATES.

    1. With cap 1, unattended auto run A finishes reporting and enters report_ready.
    2. A’s advanceAfterReport call awaits the cost gate’s usage evaluation. During that await, an API request triggers unattended run B.
    3. The new counter excludes A because report_ready is absent from ACTIVE_AGENT_RUN_STATES; B therefore sees zero active runs and becomes queued.
    4. A’s usage evaluation permits continuation. Since A is report_ready, isAdmission bypasses the new limits, and the existing autonomy caller transitions A to acting.
    5. A and B now both occupy counted states under cap 1.

    A’s state transition guards only its own row. The acting worker’s subsequent gate check also bypasses these limits because A is already acting. Making initial admission atomic alone does not prevent this sequence: A has already disappeared from the capacity count before B is admitted.

    static trace: Verified against the changed gate and counter plus the supplied advanceAfterReport and capacityHold callers. No runtime reproduction was executed.

  • Minimum fix: Preserve a capacity reservation through automatic report-to-action transitions, or atomically reacquire capacity before automatic acting. Ensure the accounting and transition rules cannot admit B into a slot A can subsequently reclaim without checking.

F3: 🔴 Preserve unrelated settings drafts

  • Required behavior: Saving one independently editable setting must not discard unsaved edits in another field.

  • Evidence: propr-ui/src/pages/SettingsPage/UnattendedAgentRunsSettingsSection.tsx, the effect depending on [pause, cap, window]; propr-ui/src/pages/SettingsPage/useUnattendedSettingSave.ts, the post-response setSettings.

    1. Change the concurrency cap and blur it, starting its asynchronous save.
    2. While updateSettings is pending, focus the window field and begin typing a new window. The inputs remain editable.
    3. The cap save succeeds and updates the parent’s saved cap.
    4. The section’s effect responds to that cap change by replacing all drafts with saved values and clearing all validation errors.
    5. The window text being entered disappears before it can be committed.

    The effect’s dependency list prevents resets on ordinary renders, but does not protect an unrelated dirty field when another save completes. The component test uses a mocked onCommit without this asynchronous parent update.

    static trace: Verified from the save hook’s awaited response and the section’s unconditional whole-draft replacement; no UI test was executed.

  • Minimum fix: Synchronize drafts per field, preserving unrelated dirty inputs and their validation state when another saved value changes.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Refresh displayed admission status

useUnattendedNotice fetches only when the definition ID or schedule-enabled flag changes, and the settings window status has no clock-driven refresh. An open page can consequently retain a closed-window or reached-cap message after conditions change. Consider refreshing at window boundaries and on relevant run updates. This is optional because server admission remains authoritative.

Score

The implementation has broad integration and passing checks, but the central concurrency guarantee is not enforced across competing admissions or automatic phase transitions. The settings draft-loss regression also needs correction.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 41s
  • Tokens: 81,971 (79,895 in / 2,076 out)
  • Cost: $0.79

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F1 F2 F3 S1

🤖 Review by ProPR

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agents: unattended concurrency cap and local-time window in the run cost gate

1 participant