DA

    Desktop Agent Multi Model Loop

    1

    Run one desktop AI agent across cloud and local models behind a single unified agent loop — one loop, pluggable model adapters, auto skill discovery, and context compression that keeps long sessions alive.

    $15

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more
    DA

    desktop-agent-multi-model-loop

    Example session with this skill installed

    Explain how to implement the adapter contract for a new local model provider and handle tool normalization.

    • Read your context and instructions
    • Compiled the desktop-agent-multi-model-loop

    To implement a new provider, you must adhere to the standard adapter contract. The loop expects a specific output shape regardless of whether the model is running locally via Ollama or through a cloud API.

    Adapter Implementation and Normalization

    // Example Adapter Implementation
    async function sendRequest(messages: Message[]): Promise<AgentResponse> {
      const rawResponse = await callLocalModel(messages);
      
      // 1. Normalize Tool Calls
      // Use the shared alias table to map provider-specific names
      const toolCalls = rawResponse.choices[0].message.tool_calls.map(tc => ({
        name: normalizeToolName(tc.function.name),
        arguments: JSON.parse(tc.function.arguments)
      }));
    
      // 2. Return standard shape
      return {
        text: rawResponse.choices[0].message.content,
        toolCalls: toolCalls,
        raw: rawResponse // Kept for debugging only
      };
    }
    
    // Tool Alias Mapping
    const TOOL_ALIASES = {
      "write_file": "file_writer",
      "save": "file_writer",
      "terminal": "shell_execute"
    };
    
    function normalizeToolName(name: string): string {
      return TOOL_ALIASES[name] || name;
    }
    

    Next steps

    • Register the new engine ID in the baseUrl detection logic.
    • Add the model's token limit to the context budget table to enable compression.
    • Test the adapter using a multi-step session to verify tool-call normalization.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Developing a desktop AI agent often leads to fragmented codebases where execution logic is duplicated across different model providers. This architecture solves the "multiple run loop" problem by providing a unified execution framework that treats cloud APIs, local servers, and custom endpoints as pluggable adapters.

    What it does

    • Unified agent loop manages tool execution, retries, and error handling through a single shared logic path.
    • Pluggable adapters implement a standard contract for cloud, local, and custom OpenAI-compatible models.
    • Budget-based compression summarizes history at 90% context capacity to keep long-running sessions alive.
    • Skill auto-discovery scans local directories for markdown-based skill definitions without manual registry.
    • Safety controls provide built-in loop detection, step caps, and mandatory permission gates for destructive tools.

    How it works

    1. Implement the adapter contract by creating a single function that maps provider-specific responses to a standard tool-call shape.
    2. Configure unified endpoints using protocol auto-detection that identifies engine types from the base URL.
    3. Deploy skill folders into standard root paths for automatic discovery and loading by the agent runtime.
    4. Monitor execution through the shared loop which handles tool normalization, retries, and session logging.

    Frameworks & tools

    This architecture is designed for desktop agent workspaces using TypeScript or similar high-level languages. It integrates with Ollama-style local servers, OpenAI-compatible APIs, and markdown-based tool definitions.

    Why this beats prompting it yourself

    Building a reliable agent loop requires solving complex edge cases like race conditions during user aborts and token budget management. This skill provides a field-tested blueprint that prevents ghost outputs and infinite tool loops that simple prompts cannot control.

    Use cases

    • Build a desktop agent that switches between GPT-4 and local Llama-3 without code changes.
    • Add new model providers by writing a thin 20-line adapter instead of a new runtime.
    • Prevent agent sessions from crashing during long coding tasks using rolling summaries.
    • Enable users to extend agent capabilities by dropping files into a skills folder.

    Known limitations

    This is a single-user desktop architecture, not a multi-tenant server system. Performance and output quality are dependent on the hardware running local models.

    Single-user desktop focus, not for multi-tenant servers. Requires manual updates to model budget tables as provider limits change. Local model quality depends on user hardware.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 14 days ago

    Permissions

    No special permissions declared or detected

    Listed14 days ago

    What's inside

    Frequently Asked Questions

    This architecture provides a single, unified execution loop that handles tool calling, retries, and error logic consistently across different providers like OpenAI, Ollama, or custom endpoints, preventing fragmented codebases.

    The skill is designed for TypeScript-based desktop environments and is compatible with any LLM provider that offers an OpenAI-compliant API or allows for custom adapter mapping.

    The system includes a 'budget-based compression' feature that automatically summarizes conversation history when you hit 90% context capacity, allowing for indefinite operation without manual resets.

    The purchase includes the complete architecture blueprint, the standardized adapter contracts, the auto-discovery engine for skills, and documentation on implementing safety gates.

    Safety is managed through built-in loop detection to prevent infinite tool calls, hard step caps, and a mandatory permission gate system for any tools flagged as destructive.

    This architecture uses a 'Skill Auto-Discovery' system that scans local directories for markdown definitions, meaning you can add new capabilities by simply dropping a file into a folder without reconfiguring the core registry.