Repository navigation
fix(fabric): stop a failed agent runtime before starting another - #14587
Merged
Merged
Conversation
After provider errors, Fabric marks a runtime failed but leaves its processes running. Refresh then finds the runtime not running, and the plan gives the agent an unknown runtime_id, so apply had no ID to stop and started another runtime next to the failed one. Fabric refused that start: state_in_use while the failed runtime held the agent's kept state, or start_failed while OpenClaw's Gateway still held its ports, after which Fabric refused every start until the sandbox was replaced. Apply now takes the stopped runtime's ID from the prior state and stops it before starting another in the same sandbox. Stopping a runtime that Fabric no longer has still succeeds. If the stop fails, the agent keeps the old ID and the next apply stops it again. Signed-off-by: Carlos Villela <[email protected]>
Signed-off-by: Carlos Villela <[email protected]>
Contributor
Collaborator
Author
Authoring session — opening
|
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apply now stops a Fabric agent's failed runtime before it starts another in the same sandbox, so an agent recovers on the next apply after provider errors instead of failing every apply until someone stops the runtime by hand or replaces the sandbox.
Problem
After provider errors, such as a model endpoint that answers 500, Fabric can mark a runtime failed while its adapter host and native processes keep running (NVIDIA/NeMo-Fabric#670).
Refresh then finds the runtime not running, and the plan gives
fabric_agentan unknownruntime_id.Apply received no runtime ID, skipped
fabric-agent-ctl stop, and started another runtime beside the failed one, which Fabric refused:runtime.keep_state, the failed runtime still held the agent's state lock:start (state_in_use)on every apply until someone ranfabric-agent-ctl stop.start (start_failed), with unknown effects, after which Fabric refused every start until the sandbox was replaced.The comment in
configuration::ensuresaid a stopped runtime is stopped in Fabric first, and the provider reference and usage guide said the same, but only the backend tests passed a runtime ID that a real plan never carries.Change
fabric_agent's backend implementsupdate: when the plannedruntime_idis unknown, it takes the prior state's ID, soensurestops that runtime before it starts another. Stopping a runtime Fabric no longer has already counts as stopped. If the stop fails, apply keeps the prior state, and the next apply stops the runtime again.fabricprovider's backend passesupdatethrough to it; before, the trait's default dropped the prior state.fail_agent_runtime) as Fabric at the pinned revision does: checks and invokes find it unavailable, a stop ends it, and until then a start in its sandbox fails withstate_in_usewhen the agent keeps state, orstart_failedwith unknown effects otherwise.failed_runtimecontract scenario applies through OpenTofu after the runtime fails without kept state, and a backend test covers kept state. The existing restart backend test now passes the row a real plan produces. Each new test failed before the fix.state_in_usetroubleshooting row, and the release notes.Stopping the failed runtime is the caller's step under Fabric's current contract; #670 asks whether Fabric should stop the host itself. This change stays correct either way, since a stop of a runtime that's already gone succeeds.
Beyond CI
The provider-500 case isn't verified live with this change. #670 records the failure live, with kept state on the pending Fabric pin bump and without kept state at Fabric
135147a0. A rerun on this branch, with OpenClaw at135147a0and no kept state, didn't reach it: six invocations against a model stub that answered 500 or hung each returned a failed result, and Fabric kept the runtime active, so apply had nothing to recover.