Tool Run Manager
OpenFrame Documentation
Get the most out of OpenFrame · Book 30 minutes with Conrad, 25 years in IT. He'll show you what Mingo and Fae can take off your list.
OpenFrame Documentation
Tool Run Manager supervises installed endpoint tools in the Rust OpenFrame client. It starts eligible tools, prevents duplicate supervisors, stops stale processes before relaunching them, waits around tool updates, and applies bounded retry behavior when a process cannot be started or exits too early.
The implementation is supplied by the openframe_agent_lib dependency from OpenFrame OSS Library and is executed by this repository’s OpenFrame client. The authoritative implementation is Tool Run Manager source.
Tool Run Manager provides these lifecycle guarantees:
The manager is an in-process coordinator. It does not download or install assets itself; surrounding services persist the installed-tool record, resolve command arguments, hold update locks, and stop existing processes. The manager converts that state into supervised processes.
flowchart LR
Registry["Installed tools registry"] -->|"tool records"| Manager["Tool Run Manager"]
Resolver["Command parameter resolver"] -->|"resolved launch arguments"| Manager
Operations["Tool operation coordinator"] -->|"busy and release state"| Manager
Killer["Tool stop service"] -->|"stop leftovers"| Manager
Manager -->|"spawn and supervise"| Standard["Standard tool process"]
Manager -->|"start through operating system"| Service["Service installation"]
Manager -->|"launch for logged-in user"| Gui["Graphical application"]
| Collaborator | Contribution to Tool Run Manager |
|---|---|
| Installed Tools Service | Persists tool records and exposes the complete registry or a record by tool identifier. The manager also changes a recoverable record from installing to installed. |
| Tool Command Parameters Resolver | Resolves persisted launch arguments and exposes the directory manager used to locate executables and verify artifact presence. |
| Tool Stop Service | Stops a managed installation before a standard process is launched and reports whether a graphical application is already running. |
| Tool Operations | Exposes per-tool busy state and a release signal. A busy tool is not relaunched until its operation completes. |
| Operating-system service support | Starts service installations during a full restart; the normal supervisor deliberately does not own these processes. |
| Failure Log Backoff | Limits repetitive failure logging while retaining a failure streak for retry timing. |
The persisted installation describes how Tool Run Manager should handle the tool.
| Installation form | Manager behavior |
|---|---|
| Standard | Stops leftover processes, resolves arguments, spawns the executable with piped output, observes the child, then relaunches it after termination. |
| Graphical application | Uses graphical-session rules. On Windows, a new installation can be launched into a user session while later logon launches are owned by the autorun entry. On macOS, the manager waits for a console user and ready graphical session, writes bundle preferences when a bundle identifier is configured, then launches as that user. |
| Service | Is not spawned by a supervisor loop. A full restart attempts to start its named operating-system service. |
At startup, the manager inspects records still marked as installing. It only changes a record to installed when the executable is present for a non-service installation. Missing artifacts remain awaiting reinstallation; service records remain installing because file presence cannot verify service registration.
A shared asynchronous read-write lock protects the set of currently supervised tool identifiers. A tool is entered into this set before its loop is created. Any later request for the same identifier is ignored until the loop removes it. This is also the synchronization boundary for shutdown and recovery decisions.
stateDiagram-v2
[*] --> Registered
Registered --> Supervised: "manager accepts tool"
Supervised --> Waiting: "tool operation is busy"
Waiting --> Supervised: "operation is released"
Supervised --> Launching: "standard or graphical launch"
Launching --> Running: "process stays up"
Launching --> Retrying: "launch fails or exits quickly"
Running --> Retrying: "process exits"
Retrying --> Launching: "delay expires"
Supervised --> Stopped: "shutdown or unsupervised"
Waiting --> Stopped: "shutdown or unsupervised"
Running --> Stopped: "shutdown or unsupervised"
Stopped --> [*]
A process that exits within the first minute is considered a failed start unless a tool operation is active. Failed starts use an escalating delay sequence of 5, 30, 120, 300, and then 900 seconds. Other restart paths use a five-second delay. Long waits are evaluated in one-second slices so shutdown, removal from supervision, or a tool-operation release can interrupt the wait promptly.
Before a fresh standard launch, the manager attempts to stop leftovers. Failures to stop leftovers defer the launch and use an escalating delay capped at 300 seconds. After a successful stop, it also reaps orphaned helper processes. On Windows, graphical applications are excluded from this leftover-kill behavior because the autorun mechanism owns them.
sequenceDiagram
participant Manager as Tool Run Manager
participant Ops as Tool Operations
participant Registry as Installed Tools Registry
participant Killer as Tool Stop Service
participant Resolver as Parameter Resolver
participant Process as Tool Process
Manager->>Ops: Check whether the tool is busy
alt Tool operation is active
Manager->>Manager: Wait until the operation releases the tool
else Tool is available
Manager->>Registry: Refresh installation and stored arguments
Manager->>Killer: Stop leftover processes
Manager->>Resolver: Resolve command arguments
Manager->>Process: Spawn executable with arguments
Manager->>Process: Read standard output and error output
alt Process exits within one minute
Manager->>Manager: Record failed start and delay retry
else Process remains running
Manager->>Manager: Clear failed-start streak
Process-->>Manager: Eventually exits
Manager->>Manager: Delay then supervise again
end
end
Child standard output and error output are consumed asynchronously. During a failure streak, output forwarding follows the logging backoff decision. Once a process survives the quick-exit window, output forwarding is enabled and a prior failure streak is recorded as recovered.
Tool Run Manager uses separate state for lifecycle intent:
flowchart TD
UpdateStart["Client update begins"] --> Signal["Signal supervisor shutdown"]
Signal --> Pending["Mark client update pending"]
Pending --> Outcome{"Update outcome?"}
Outcome -->|"service stops"| Restart["New client instance starts supervision"]
Outcome -->|"update aborts"| Resume["Clear shutdown signal"]
Resume --> Deactivated{"Tools stopped by deactivation?"}
Deactivated -->|"yes"| KeepStopped["Keep tools stopped"]
Deactivated -->|"no"| Relaunch["Relaunch missing non-service supervisors"]
Outcome -->|"tenant deactivation"| StopAll["Stop every installed tool"]
StopAll --> KeepStopped
A reversible full stop first takes the supervision lock, sets the stopped state, signals shutdown, and clears the running set. It then requests the Tool Stop Service to stop every installed tool without uninstalling it. A later full restart clears both flags, clears the running set, starts registered operating-system services, and runs the normal launch path for non-service tools.
If a client update aborts while the client process is still alive, recovery clears only the shutdown signal. It does not resume after a deactivation stop. Otherwise, it reloads the registry and creates supervisors for non-service tools that are not already represented in the running set.
Graphical applications are intentionally not treated exactly like ordinary daemon processes.
The optional background flag is only selected for the client’s designated chat tool on Windows and macOS.
Changes to Tool Run Manager should preserve these invariants:
The core behaviors are implemented by the ToolRunManager type and its constructor, registry startup, single-tool startup, graphical-app assurance, all-tool stop and restart, update-abort recovery, and client-update-pending operations in the linked OpenFrame OSS Library source.