llm-runtime
/llm-runtime
Integruje, strumieniuje i orkiestruje API wiodących LLM ze schematami narzędzi, ustrukturyzowanymi wyjściami, prompt cachingiem i odpornym backoffem, dla runtime'ów agentów, pętli wywołań narzędzi i endpointów SSE.
- Autor
- wrongstack ↗
- Repozytorium
- wrongstack ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 27.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Integruje, strumieniuje i orkiestruje API wiodących LLM ze schematami narzędzi, ustrukturyzowanymi wyjściami, prompt cachingiem i odpornym backoffem, dla runtime'ów agentów, pętli wywołań narzędzi i endpointów SSE.
Oryginalny opis (EN)
Integrate, stream, and orchestrate frontier LLM APIs with robust structured outputs, tool call schemas, prompt caching, and resilient backoff handling. Use when implementing AI agent runtimes, tool-calling loops, streaming SSE endpoints, or optimizing token usage and model latency.
Jak działa
- Selection card
- Overview
- Core Architecture Principles
- Implementation Pattern (TypeScript ESM)
- Skills in scope
- Acceptance checks
Podgląd SKILL.md
---
name: llm-runtime
description: "Integrate, stream, and orchestrate frontier LLM APIs with robust structured outputs, tool call schemas, prompt caching, and resilient backoff handling. Use when implementing AI agent runtimes, tool-calling loops, streaming SSE endpoints, or optimizing token usage and model latency."
version: 1.1.0
required-capabilities: [filesystem.read, filesystem.write]
required-tools: []
optional-capabilities: [verification.run, web.research]
trigger: "implementing AI agent runtimes, tool-calling loops, streaming SSE endpoints, or optimizing token usage and model latency."
metadata:
routing-group: integration
---
# LLM Runtime Engineering — WrongStack
## Selection card
- Task: Implement frontier LLM integration, tool calling, and streaming pipelines.
- Start: Define model choice, schema definitions (Zod/JSON Schema), and streaming protocol.
- Finish: apply the acceptance checks below; report observed results and unresolved constraints.
## Overview
Frontier LLM integrations require production reliability: structured tool contracts,
deterministic schema validation, streaming Server-Sent Events (SSE), prompt caching optimization,
and graceful degradation during rate limits (HTTP 429) or transient gateway timeouts (HTTP 502/529). Checked 2026-10-23 stable SDK targets: openai 7.43.0, @anthropic-ai/sdk 1.2.0, @google/genai 2.31.0, Vercel AI SDK (ai) 7.0.152, and zod 4.6.7.
## Core Architecture Principles
1. **Strict Type-Safe Schema Contracts**:
- Define all tool inputs and structured responses using Zod schemas converted to standard JSON Schema.
- Set `additionalProperties: false` to force model compliance and eliminate hallucinated parameters.
2. **Streaming & Asynchronous Lifecycle**:
- Stream model responses via standard `ReadableStream` or Server-Sent Events (`text/event-stream`).
- Parse tool calls incrementally and emit status events to avoid user-perceived latency.
- Wire `AbortSignal` through all fetch calls so user cancellations abort upstream API billing immediately.
3. **Prompt Caching & Token Economics**:
- Place stable system prompts and large reference documents at the beginning of the context window.
- Place ephemeral user inputs, dynamic turn logs, and real-time tool results at the end.
- Monitor cache-read vs. cache-write token counts in response usage headers.
4. **Resilient Rate-Limit Backoff**:
- Implement exponential backoff with full jitter on HTTP 429, 500, 502, and 503 errors.
- Respect `retry-after` header values when provided by the provider gateway.
## Implementation Pattern (TypeScript ESM)
```typescript
import { z } from 'zod';
export const SearchToolSchema = z.object({
query: z.string().describe('The search query term'),
limit: z.number().int().min(1).max(20).default(5)
});
export type SearchToolInput = z.infer<typeof SearchToolSchema>;
export async function fetchWithBackoff(url: string, init: RequestInit, maxRetries = 3): Promise<Response> {
let attempt = 0;
while (attempt < maxRetries) {
try {
const response = await globalThis.fetch(url, init);
if (response.status === 429 || response.status >= 500) {
const retryAfter = Number(response.headers.get('retry-after')) || Math.pow(2, attempt) + Math.random();
await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
attempt++;
continue;
}
return response;
} catch (err) {
if (attempt >= maxRetries - 1) throw err;
attempt++;
}
}
throw new Error('LLM gateway request exceeded retry budget');
}
```
## Skills in scope
- `prompt-engineering` — system prompt architecture, few-shot calibration, and eval rubrics
- `mcp-development` — Model Context Protocol servers, tool schemas, and transport security
- `realtime-systems` — SSE and WebSocket streaming backpressure and reconnection contracts
## Acceptance checks
- [ ] Tool definitions and structured outputs enforce strict JSON Schema contracts (`additionalProperties: false`) validated at the boundary.
- [ ] Streaming pipelines handle backpressure, partial tool-call deltas, and upstream cancellation via `AbortSignal`.
- [ ] Rate-limiting (HTTP 429) and transient gateway errors (502/503/529) trigger bounded exponential backoff with jitter and `retry-after` support.
- [ ] Context window ordering keeps static instructions and reference blocks prefix-stable to maximize prompt cache hits.
Wersje
W bazie nie ma innych skilli o nazwie llm-runtime.
Migawka bazy z 13.11.2026 · wersja paczki ec7b8fbe311c (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100liter-llm-tool-calling
Pomaga definiować funkcje i narzędzia dla modelu wywoływane przez liter-llm oraz żądać ustrukturyzowanych odpowiedzi JSON, ze schematami narzędzi, obsługą tool_calls i formatami odpowiedzi. - 84liter-llm-streaming-responses
Strumieniuje tokeny LLM w liter-llm przez SSE lub iteratory asynchroniczne i obsługuje puste fragmenty. - 100llm-integration
Buduje produkcyjne funkcje oparte na API LLM: strukturę promptów, walidowane dane wyjściowe, strumieniowanie i obronę przed wstrzyknięciami. - 100llm-cost-and-latency-optimization
Prowadzi przez obniżanie kosztu tokenów i czasu odpowiedzi agentów LLM bez utraty jakości: wybór tańszego modelu, prompt caching, streaming, batching i budżet kosztu oraz opóźnień przed skalowaniem. - 100tool-calling-principles
Projektuje interfejsy narzędzi dla agentów LLM: nazwy, opisy, ścisłe schematy, kontrakty błędów i poziomy uprawnień. - 100llm
Pomaga budować funkcje AI dla użytkowników: ustrukturyzowane wyjście, schematy narzędzi, ochrona przed prompt injection i ewaluacje, w tym idempotentne wywołania narzędzi i bramki potwierdzeń.