Desktop Agent Multi Model Loop
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
Works with the AI Agents you already use
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
baseUrldetection 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
- Implement the adapter contract by creating a single function that maps provider-specific responses to a standard tool-call shape.
- Configure unified endpoints using protocol auto-detection that identifies engine types from the base URL.
- Deploy skill folders into standard root paths for automatic discovery and loading by the agent runtime.
- 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.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.
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
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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
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