mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #90] RFC: explicit placement reservation lifecycle and shared ownership #29
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @catyans on GitHub (Jul 31, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/90
Affected component
Gateway / scheduler (cross-cutting with sandbox lifecycle and node heartbeat reporting)
Problem statement
Resource-aware placement needs to account for creates that have been scheduled but are not yet visible in node heartbeats. PR #27 currently does this with scheduler-local, TTL-bounded reservations and aggregate heartbeat deltas.
That closes the immediate concurrent-selection race, but it cannot reliably determine the outcome or ownership of an individual placement:
create_successes,create_fails, and allocated-resource gauges are node-wide aggregates. They cannot identify which reservation completed, especially when requests finish out of order.The result is a choice between under-accounting (possible overcommit) and conservative stale accounting (possible false
ErrNoNodes). A fixed TTL only bounds the duration; it does not provide causal correctness.Related review findings on #27:
Use case
This is needed when AgentENV uses resource-aware placement for concurrent sandbox creation, particularly:
At low concurrency the current TTL fallback is usually sufficient. At higher concurrency or during downstream failure, request-level identity is needed to avoid both overcommit and prolonged false capacity exhaustion.
Current behavior and workarounds
PR #27 records an in-memory reservation immediately after selecting a node. Heartbeat generations and aggregate success/failure/allocation deltas are used as best-effort reconciliation, with a configurable TTL as the final cleanup mechanism.
This is intentionally process-local and heuristic. Making the TTL shorter reduces stale capacity but reopens the concurrent-placement race for slow creates; making it longer protects against overcommit but increases the duration of false exhaustion. Aggregate counters cannot resolve this trade-off because they do not establish causality.
Desired behavior
Proposed approach
1. Return an opaque reservation token
Extend the scheduling response for sandbox creation with an optional
reservation_token. The token is absent for operations and strategies that do not reserve capacity.The reservation record contains at least:
Suggested states:
State transitions use compare-and-set semantics and are idempotent.
2. Add explicit lifecycle operations
Add internal RPCs or equivalent control-plane operations:
ConfirmReservation(token, sandbox_or_assignment_id)after the selected node accepts the create;CancelReservation(token, reason)on endpoint validation failure, proxy/transport failure, client cancellation, node rejection, or exhausted retry;RenewReservation(token)if dispatch can legitimately exceed the initial lease.The Gateway owns these calls because it observes the downstream request outcome. A retry must either reuse the same token for the same node or explicitly cancel it before acquiring another reservation.
3. Use shared ownership for replicated schedulers
For multi-replica deployments, store reservations in the existing shared control-plane store (for example Redis) with atomic state transitions and lease expiry. A single-process in-memory implementation can remain available for development, but it must implement the same interface and semantics.
The store should support:
4. Bind outcomes to sandbox identity
The confirmed reservation should be bound to the resulting sandbox/assignment ID. Reconciliation then operates on identities rather than gauge deltas.
The preferred end state is for node heartbeat/inventory data to include the sandbox/assignment identity already known to the control plane. Once that identity is observed as active, the pending reservation can leave projected capacity without ambiguity. If node protocol changes must be staged later, the shared binding still provides authoritative confirm/cancel behavior, with lease expiry as crash recovery.
5. Carry resolved resources for template creates
Resource-aware scheduling must receive CPU and memory after template resolution. If that cannot be added in the first phase, an unknown resource dimension must not be admitted when observed allocation plus active reservations is already at its known capacity.
6. Add observability
Expose at least:
Logs should include the reservation token in a safe, traceable form and correlate it with the sandbox/assignment ID.
Compatibility and operational impact
API/config changes:
Snapshot or storage format changes:
New host/runtime requirements:
Upgrade and rollback considerations:
Rollout plan
Acceptance criteria
Alternatives considered
Non-goals
Contribution
I can implement it and validate the multi-node behavior.
Pre-submission checklist
@catyans commented on GitHub (Aug 3, 2026):
@LSX-s-Software Following up because PR #27 remains blocked by the four unresolved reservation lifecycle findings linked above. Before expanding the patch across Gateway, scheduler, shared state, and node identity, could maintainers confirm the preferred sequencing: (1) narrow #27 to heartbeat-snapshot least-loaded scoring and implement this RFC separately, or (2) land the reservation-token lifecycle first and keep #27 blocked on it? I can proceed with either path and validate the replica/failure cases on the Lingjun cluster.
@LSX-s-Software commented on GitHub (Aug 4, 2026):
@catyans Thank you for the proposal and for the thoughtful work on improving the scheduler.
The proposed strategy is interesting, and we agree it could bring benefits in certain scenarios. However, implementing it would require substantial changes to the scheduler’s core logic, along with significant validation effort and ongoing maintenance cost.
Given our current priorities, we don’t have the bandwidth to take on this level of work right now. As a result, we’d prefer to put this proposal on hold and revisit it when we have more resources or when the need becomes more pressing.
That said, if you’re able to further refine the design, provide performance data, or experiment with a prototype, we’d be very interested to see those updates — they would be valuable for future evaluation.
Thanks again for your contribution and for engaging with the project!
@catyans commented on GitHub (Aug 5, 2026):
Understood. I will put this design on hold and close the RFC for now, along with the dependent PR #27. The failure model, rollout plan, and acceptance criteria will remain here for future evaluation; if the need becomes pressing, I can refresh the design and rerun the multi-node validation against the then-current control plane.