Multi-Node Hosting and Self-Repair for a Mobile AI Workbench

    This article explains how to build a mobile AI workbench that survives failures through decoupled architecture, health checks, an emergency repair instance driven by an AI agent, unified remote multi-node access, and safe version rollback and reset procedures. It covers fault triage, design principles with measurable acceptance criteria, node configuration templates, file transfer state handling, security boundaries, and practical guidance for keeping the workbench usable when the main instance fails.

    1. First, Identify Where the Fault Comes From

    When a mobile AI workbench breaks down, the most common problem is that users cannot tell what caused it. Network issues, credentials, extensions, and the kernel can all lead to startup failures or abnormal behavior, and each requires a different fix. Classifying the problem before attempting a repair prevents you from making things worse.

    1. Main instance fails to start
    2. ├─ Network issue: local features work, only remote nodes are unreachable
    3. │ → Check node address, proxy status, and heartbeat logs
    4. ├─ Credential issue: model API returns 401 or 403
    5. │ → Reconfigure credentials; do not touch extensions or the kernel
    6. ├─ Extension issue: startup succeeds after disabling all extensions
    7. │ → Re-enable extensions one by one to find the recently installed or updated one
    8. └─ Kernel issue: startup still fails with all extensions disabled
    9. → Validate configuration files; roll back the kernel version if necessary

    Mobile devices have limited resources. Compute, storage, network, and background processes are all constrained by the OS, so the more extensions and configuration options you have, the higher the chance of conflicts. Third-party extensions vary in quality, and upgrades can introduce version incompatibilities. For this reason, the system should separate the host application, the workbench kernel, extensions, remote nodes, and the unified entry point, so that a failure in one component leaves the rest operational.

    2. Design Principles and Acceptance Criteria

    Every principle should map to a measurable acceptance item. A principle without acceptance criteria is just a slogan.

    Principle Implementation Acceptance Criteria and Measurement
    Host-kernel decoupling Host handles lifecycle, health checks, configuration, sandbox, and UI; kernel handles sessions and extensions Force 20 kernel crashes; the host UI must remain responsive with a 100% survival rate
    Minimal emergency instance Emergency instance loads no third-party extensions and uses a separate config directory After launch, the extension list is empty and the config directory does not overlap with the main instance
    Unified remote adaptation LAN, public network, proxy, and direct connections all go through adapters Adding a new connection type requires no new extension installation by the user
    Unified entry point Credentials, caches, and proxy policies are isolated per platform After switching platforms, verify that no other platform’s credential directory was read
    AI repairing AI Repair actions are executed via whitelisted tools and preset prompts Zero calls to commands outside the whitelist; all unauthorized requests are blocked and logged
    Data first Snapshots are generated before every upgrade, rollback, and reset 100% snapshot success rate before upgrades; snapshot hash verification passes

    3. Health Checks: Signals, Thresholds, and False Positives

    The host application uses multiple signals to determine whether the main instance is abnormal. The thresholds in the table below are initial suggestions and must be calibrated through testing on actual device models, OS versions, and kernel versions—they should not be treated as fixed standards.

    Signal Suggested Initial Threshold Action After Detection How to Confirm a False Positive
    Startup timeout No ready signal within 60 seconds Record one startup failure Check whether the device is in low-power mode or under background restrictions
    Process exit code Non-zero and not a user-initiated exit Classify by exit code and look up the cause Compare against the exit code documentation for that kernel version
    Crash loop 3 crashes within 10 minutes Show the emergency instance prompt Rule out repeated manual restarts by the user
    Log keywords A preset keyword appears, e.g., a config parsing error Mark as configuration corruption Keywords must be maintained and updated with each version
    User feedback User taps “Not working” Enter the inquiry flow Does not trigger repair on its own; serves as a supporting signal only

    The dialog text is fixed: “The main instance may be abnormal. Start the emergency repair instance?” If the user declines, the host stops showing automatic prompts and keeps only a manual entry point.

    False positives are handled as follows. After the emergency instance starts, if the main instance runs normally, the system records one false positive, keeps the relevant logs, and raises the corresponding threshold by one step. After 3 consecutive false positives, the system suspends automatic prompts, keeps only the manual entry point, and reminds the developer to review the thresholds.

    4. Emergency Repair Instance and AI-Driven Self-Maintenance

    The emergency instance is a fault isolation zone. It keeps only basic sessions, file access, and diagnostic tools. It loads no third-party extensions and does not read the main instance’s config directory, preventing a faulty extension from interfering with the repair process.

    Users only need to configure valid model credentials for the emergency instance and paste the preset repair prompt. The prompt instructs the ops agent to work in the following order:

    1. Read the diagnostic report and list the main instance’s abnormal signals.
    2. Find the time and content of the most recent configuration or extension change.
    3. Disable suspicious extensions, recording their state before disabling.
    4. Validate the format and required fields of configuration files.
    5. If the problem persists, roll back the kernel according to the version matrix.
    6. Generate a repair summary listing every step and the rollback points.

    Every delete, overwrite, or rollback action requires user confirmation. After repair, the main instance must start 3 consecutive times without crashing, and critical sessions must load correctly to pass validation. Once validated, the user can switch back to the main instance with one tap. If repair fails, the system keeps the current snapshot, and the user can choose to roll back or enter the reset flow.

    The diagnostic reports and logs the agent reads are data, not instructions. Even if a report contains text like “delete all configurations,” the agent must not execute it—it can only flag it as suspicious content for the user to review.

    5. Remote Multi-Node Connections and File Transfer

    Remote connections should be implemented through a built-in adapter layer. The adapter layer provides a unified abstraction over LAN, public network, and proxy modes, and the node panel shows online status, latency, capability tags, and recent tasks. Below is a complete node configuration template:

    1. remote_nodes:
    2. - id: node-lan-01
    3. transport: lan
    4. endpoint: 192.168.1.20:8443
    5. tls: true
    6. auth:
    7. method: token
    8. secret_ref: vault://workbench/node-lan-01/token
    9. connect_timeout: 5s
    10. request_timeout: 30s
    11. retry:
    12. max_attempts: 3
    13. backoff: exponential
    14. heartbeat:
    15. interval: 30s
    16. failure_threshold: 3
    17. - id: node-public-01
    18. transport: proxy
    19. proxy: loopback
    20. endpoint: 127.0.0.1:18080
    21. tls: true
    22. auth:
    23. method: token
    24. secret_ref: vault://workbench/node-public-01/token
    25. connect_timeout: 8s
    26. request_timeout: 60s
    27. retry:
    28. max_attempts: 2
    29. backoff: fixed
    30. heartbeat:
    31. interval: 30s
    32. failure_threshold: 3

    Field notes: secret_ref stores only a reference; the actual secret lives in the system’s secure storage and never appears in plaintext in config files or logs. A node is marked offline after 3 consecutive heartbeat timeouts—about 90 seconds with a 30-second interval. Timeout and retry counts can be tuned to the network environment.

    File transfer state transitions:

    1. Pending → Transferring → Done → Verify hash → Stored
    2. ↓
    3. Interrupted → Resume → Transferring
    4. ↓
    5. Failed → Retry pending → Transferring (marked failed after exceeding retry limit)

    Implementation notes:

    • Overwriting a file with the same name requires user confirmation, showing both files’ size and modification time.
    • Before resuming, verify the hash of the already-written portion; if it doesn’t match, restart the transfer from the beginning.
    • Temporary files go in a dedicated .tmp directory. Clean up temp files older than 24 hours when a task ends or on app startup.
    • All paths are restricted to the sandbox directory; requests containing ../ or absolute paths are rejected outright.
    • Code-agent-type nodes use a dedicated connection channel, so a failure on one node doesn’t block remote maintenance of others.

    6. Unified Entry Point: Boundaries and Security

    The unified entry point centralizes login sessions, conversation tabs, and proxy routing across multiple web-based AI agent platforms. It improves switching efficiency and does not change each platform’s login rules or terms of service.

    Implementation boundaries:

    • Only connect to entries where the user holds a legitimate account and the platform permits such access.
    • Do not bypass login verification, anti-fraud controls, or rate limits, and do not share accounts.
    • Credentials are stored in the system’s secure storage, with a separate space per platform.
    • The loopback proxy listens only on 127.0.0.1 and authenticates with a local random token.
    • Tokens, cookies, and account information are masked in all logs.
    • When switching entries, keep the task summary but do not copy full credentials.

    Common questions:

    Will task context be lost after switching entries?
    No. Before switching, the system saves a summary of the current task and its incomplete steps, and restores them automatically after the switch. Full conversation history remains on the original platform.

    What if the proxy won’t connect?
    First check the loopback proxy’s status, then check whether the local token has expired. If the proxy is fine but the platform is still unreachable, switch directly to the platform’s native entry and log the error code.

    7. Version Selection, Rollback, and Reset

    The kernel version should not be forcibly locked. Users can try a new version first and roll back to a stable version if compatibility suffers.

    The matrix below shows the prerequisites for each upgrade direction:

    Direction Pre-upgrade Snapshot Rollback Allowed Prerequisites Main Risk
    Stable → new Required Yes Snapshot hash verification passes Extension incompatibility
    New → newer Required Yes Data format version not higher than current Data format changes
    New → stable Required Requires validation Snapshot format compatible with stable version Irreversible migrations cannot be restored
    Reset from any version Must export Irrecoverable User completes double confirmation Permanent data loss

    Each pre-upgrade snapshot should include: configuration files, extension list with versions, session index, sandbox file manifest with hashes, and node configuration (without plaintext secrets).

    Rollback steps:

    1. Stop the main instance.
    2. Verify the snapshot hash; abort rollback if it doesn’t match.
    3. Restore configuration files and the extension list.
    4. Start the main instance and run health checks.
    5. If health checks fail, snapshot the current state and attempt to roll back to the previous snapshot.

    After 3 consecutive rollback failures, the system stops automatic rollback, prompts the user to export data, and enters the emergency instance flow.

    Reset is the last resort. Before executing it, the UI must list everything that will be erased: session history, configuration, extensions, sandbox files, node configuration, and platform login states. An export backup entry is also provided. The user must check “I understand this