AI 资讯
La biblioteca di Borges:digitale.
La biblioteca di Babele di Borges è diventata un'ossessione o metafora potente per pensare l'intelligenza artificiale contemporanea. Il racconto del 1941 descrive una biblioteca infinita composta da gallerie esagonali, dove ogni libro contiene ogni possibile combinazione di 25 simboli ortografici. In essa risiede "la minuta storia del futuro, le autobiografie degli arcangeli, il catalogo fedele della Biblioteca, migliaia e migliaia di cataloghi falsi, la dimostrazione della fallacia di questi cataloghi, la dimostrazione della fallacia del catalogo vero" — eppure la stragrande maggioranza dei volumi è pura cacofonia senza senso. Questo scenario anticipa con precisione inquietante il problema fondamentale dei Large Language Models (LLM). Come ha notato Léon Bottou, il modello linguistico perfetto permette di navigare una collezione infinita di testi plausibili semplicemente digitando le prime parole, ma "nulla distingue il vero dal falso, l'utile dall'ingannevole, il giusto dallo sbagliato". La risposta di ChatGPT o di un altro modello generativo è, in un certo senso, un libro estratto a caso dalla Biblioteca di Babele: statisticamente plausibile, grammaticalmente corretta, ma non necessariamente ancorata a una verità esterna. Jonathan Basile, creatore del sito libraryofbabel.info , ha esplicitamente distinto la sua creazione dall'intelligenza artificiale: "Babele è tutta espressione nella sua forma più irrazionale e decontestualizzata; preferisco pensarla come unintelligenza artificiale".Eppure, paradossalmente, l'IA contemporanea ci ha portato più vicini che mai a realizzare la Biblioteca di Babele: non più un universo fisico di libri, ma un universo digitale di testi generati all'istante, dove la verità è circondata da infinite variazioni di falsità. La lezione di Borges è duplice. Da un lato, l'IA come strumento di navigazione: usare il Natural Language Processing per estrarre parole inglesi dal "gibberish" della Biblioteca, come dimostra la funzione "Anglishize"
AI 资讯
Understanding Retrieval-Augmented Generation (RAG): The AI Architecture That Makes LLMs Smarter
Introduction Large Language Models (LLMs) like ChatGPT have transformed how we interact with AI. They can write code, answer questions, summarize documents, and generate creative content. However, they have one major limitation - they only know what they were trained on and can sometimes generate incorrect or outdated information. So, how do modern AI applications answer questions about your company's private documents, recent news, or knowledge that wasn't part of the model's training? The answer is Retrieval-Augmented Generation (RAG). In this blog, we'll explore what RAG is, how it works, its architecture, benefits, challenges, and real-world applications. What is RAG? Retrieval-Augmented Generation (RAG) is an AI architecture that combines a retrieval system with a Large Language Model (LLM). Instead of relying only on the model's internal knowledge, RAG first retrieves relevant information from an external knowledge source and then uses that information to generate a more accurate response. Think of it like an open-book exam. Instead of answering from memory, the AI first searches for the most relevant pages and then writes the answer based on those pages. Why Do We Need RAG? Traditional LLMs have several limitations: Knowledge becomes outdated. They cannot access private company data. They may hallucinate (generate incorrect facts). Retraining models is expensive and time-consuming. RAG solves these problems by allowing the model to retrieve fresh and domain-specific information before generating an answer. RAG Architecture A typical RAG pipeline consists of the following components: User Query Embedding Model Vector Database Retriever Prompt Builder Large Language Model Final Response Step-by-Step Workflow * Step 1: * User asks a question Example: "What is our company's leave policy?" Step 2: Convert the question into embeddings The query is transformed into a vector representation using an embedding model. Example: "What is leave policy?" ↓ [0.12, -0.45, 0.7
AI 资讯
RAG Pipeline: The Uncle-Nephew Complete Learning Guide
How to Build Systems That Actually Know Your Data (Not Hallucinate About It) Introduction: The Story Begins 👦 Nephew: Uncle, I keep hearing "RAG this, RAG that" in tech interviews. When I ask what it means, people throw around words like "Retrieval-Augmented Generation" and I just nod like I understand. But honestly? I'm lost. 👨🦳 Uncle: (laughing) That's the best honest question I've heard all week. Let me ask you something first. If I gave you a question right now - "What year did India win the World Cup?" - how would you answer? 👦 Nephew: Well... I'd pull up Google, search for it, read the answer, then tell you. 👨🦳 Uncle: Exactly. You don't answer from memory alone. You go fetch the information first, then answer based on what you found . That's RAG in real life. And that simple idea - fetch first, answer after - fixes almost every problem we face with AI today. 👦 Nephew: But uncle, AI can remember things from its training. Why does it need to fetch? 👨🦳 Uncle: Ah! That's where we land in trouble. Come, sit... SECTION 1: RAG FUNDAMENTALS - The Core Concept The Problem We're Actually Solving 👨🦳 Uncle: Imagine you're hiring for a tech company. You receive 500 resumes for a Senior React Developer role. Now tell me - how would you actually process them? 👦 Nephew: I'd... probably make a spreadsheet? List all the candidates with key skills? 👨🦳 Uncle: Right. But here's the catch - you can't read all 500 resumes deeply. So what do you really do? 👦 Nephew: Skim for keywords like "React", "JavaScript", "5 years"? 👨🦳 Uncle: Exactly. You skim and hope you don't miss anyone good. Now, here's the problem: what if a candidate wrote "React.js" instead of "React"? Your eyes might still catch it. But a dumb computer doing exact string matching? It says "no match". What if someone wrote "Built real-time user interfaces with the React framework"? The candidate clearly knows React, but the word "React" appears nowhere in that sentence. The computer misses them. This is exactly wh
AI 资讯
60–95% fewer tokens in your agent loops, same answers. Meet Headroom.
AI coding agents are expensive — not because models cost too much per token, but because they send too many of them. An SRE debugging session with a raw agent: 65,694 tokens in. With Headroom in the middle: 5,118. Same bug found. Headroom is a new open-source context compression layer that intercepts everything your agent reads — tool outputs, log dumps, RAG chunks, files, conversation history — and compresses it before the LLM ever sees it. It's local, reversible, and available as a drop-in proxy, a library, or an MCP server. The numbers that matter Savings on real agent workloads: Code search (100 results): 17,765 → 1,408 tokens (92% reduction) SRE incident debugging: 65,694 → 5,118 tokens (92%) GitHub issue triage: 54,174 → 14,761 tokens (73%) Codebase exploration: 78,502 → 41,254 tokens (47%) Accuracy on standard benchmarks (GSM8K, TruthfulQA, SQuAD v2, BFCL) is preserved — some scores actually improve slightly, likely because the model sees cleaner signal. What's doing the compression Under the hood, Headroom routes content through a stack of specialised compressors: SmartCrusher — JSON, nested objects, arrays of dicts CodeCompressor — AST-aware for Python, JS, Go, Rust, Java, C++ Kompress-base — a custom HuggingFace model trained on agentic traces, for prose and mixed content CacheAligner — stabilises prompt prefixes so Anthropic/OpenAI KV caches actually hit It also does CCR (reversible compression) — originals are cached locally and the LLM can retrieve them on demand if it needs them. Nothing is destroyed. Why the proxy mode matters The most interesting deployment path: headroom proxy --port 8787 , then point your existing tool at localhost. Zero code changes. Works with any language. Or even simpler: headroom wrap claude wraps Claude Code, routes its traffic through Headroom automatically. One command, savings start immediately. Same for Codex, Cursor, Aider, Copilot CLI. "Library — compress(messages) in Python or TypeScript, inline in any app. Proxy — hea
AI 资讯
Tracking token usage across OpenAI, Anthropic, and Gemini: every streaming gotcha I hit
OpenAI, Anthropic, and Gemini each report token usage differently, and it stops being trivia the moment you track LLM cost. I build Spanlens, an open-source LLM observability tool that sits in front of all three as a proxy and records every call with its model, latency, tokens, and cost. To do the cost part I read the token usage back out of every response, including the streaming ones. I assumed the three providers would report usage in roughly the same way. They send the same kind of data, after all: input tokens, output tokens, maybe a cached count. How different could it be. Pretty different, it turns out. Here is the whole thing in one table, then each gotcha in detail with the real parser code from the repo. Provider Where usage lives (streaming) Cache accounting Field names OpenAI final chunk, needs stream_options: { include_usage: true } prompt_tokens includes cache prompt_tokens / completion_tokens Anthropic split across message_start + message_delta input_tokens excludes cache, so add it input_tokens / output_tokens Gemini usageMetadata , two stream formats not applicable promptTokenCount / candidatesTokenCount Gotcha 1: the usage numbers live in different places in the stream For a non-streaming call this is boring. Every provider hands you a usage object on the response body and you read it. Streaming is where it gets weird, because the token counts are not in the content chunks. They show up somewhere else, and "somewhere else" is different for each provider. OpenAI puts the usage in a final chunk, after all the content, right before [DONE] . You only get it if you ask for it with stream_options: { include_usage: true } . Miss that flag and you stream the whole response and end up with no usage at all. export function parseOpenAIStreamChunk ( line : string ): Partial < ParsedUsage > | null { if ( ! line . startsWith ( ' data: ' )) return null const data = line . slice ( 6 ). trim () if ( data === ' [DONE] ' ) return null const json = JSON . parse ( data
AI 资讯
🚀 I Ran Claude Code on Every New Claude Model. Here's What Actually Ships.
Fable, Mythos, Opus 4.8, Sonnet 4.6, Haiku — Anthropic's 2026 lineup is no longer "one model you talk to." It's a fleet you route between. I spent a month inside Claude Code orchestrating all of them across real codebases. Here's which model to reach for, when, and the routing playbook that quietly doubled my throughput. Why I Went Down This Rabbit Hole (Again) Last time I wrote about Claude Skills and called Claude Code the killer host for them. Since then, two things happened that changed how I work day to day. First, the models got genuinely strange-good . In the span of a few months Anthropic shipped Sonnet 4.6, Opus 4.8, and then an entirely new tier above Opus — the Mythos class — released to the public as Claude Fable 5 . We went from "the AI suggested a decent diff" to Stripe reporting that Fable 5 ran a codebase-wide migration on a 50-million-line Ruby codebase in a single day — work that would've taken a team over two months by hand. Second, Claude Code stopped being a single-model tool. With a fleet of models at different price/speed/intelligence points, the highest-leverage skill in 2026 isn't prompting — it's routing . Knowing which model to put on which task is the difference between burning $200 of tokens on a typo fix and one-shotting a multi-service refactor. So I did the obvious thing: I wired all of them into Claude Code and ran them against real work for a month — bug fixes, migrations, greenfield features, test suites, the boring stuff and the scary stuff. This is what I learned. TL;DR The lineup is now a ladder : Haiku → Sonnet 4.6 → Opus 4.8 → Fable 5 → Mythos 5. Each rung trades cost for capability and patience for long-horizon autonomy. Sonnet 4.6 is your default. Frontier-ish coding at $3/$15 per million tokens with a 1M-token context window . Most of your work should live here. Opus 4.8 is the reliable senior. Better judgment, ~4× less likely to let its own code bugs slide, and it powers dynamic workflows — hundreds of parallel subagents i
AI 资讯
Treat prompt libraries as first-class deliverables for reliable AI code assistance
A working prompt library is the main event, not an appendix. The industry still treats prompts as some half-baked spitball left in a README, or, worse, a plaintext blob stapled to package.json and forgotten. That's a waste of compute and credibility. What powers reliable AI-assisted refactoring, onboarding, or even next-gen code IDEs is not the size of the model but the clarity and context supplied by the actual, shipped prompt set. OTF kits turn this lesson into a repeatable deliverable: every paid template includes 20+ production-tested prompts tied to the real file structure, component API, and product-specific conventions. This is not a suggestion; it's structural. The takeaway: a real prompt library is as important as your component library. Treat it like one. Start with the pain: why blank chat boxes don't scale The web is full of “integrations” that paste a blank chat input over your codebase and call it an “AI coding assistant.” The result: hallucinated function names, invented conventions, broken import paths. Here’s what happens in real life: Dev: "Add a social login button." AI (blank prompt): "Sure! Insert <SocialLoginButton> in your LoginScreen.js." Dev: (There’s no such component. There's not even a LoginScreen.js.) Short: A generic prompt with zero context simply can't know your conventions, files, or patterns. The agent will either fail, hallucinate, or pepper you with clarifying questions you have already answered in your product architecture. Takeaway: Prompting without context is coding without types — fragile guesses instead of structured outcomes. What a first-class prompt library enables When the prompt library ships with the codebase, it looks like this: Every prompt knows the folder structure (e.g., features/auth , screens/Settings/index.tsx ). Conventions are hard-coded: naming, import styles, design token usage. Endpoints and integration points (e.g., “update the Stripe webhook handler in api/webhooks/stripe.ts ”) are spelled out. The promp
AI 资讯
Load late, load little: just-in-time context for conversation history
Most agents drag their entire past into every turn. A better default: keep a thin index of what was said hot, and fetch only the few turns you actually need — intact, on demand. Code: github.com/NirajPandey05/jit_context There is a quiet assumption baked into how most agents handle memory: that more context is safer than less. If the model might need something, put it in the window. The conversation grows, every prior turn rides along on every new request, and we trust the model to find the part that matters. That assumption breaks twice. It breaks on cost , because an agent loop re-sends its whole window on every step — a hundred stale turns aren't paid for once, they're paid for on turn 101, 102, and every step after. And it breaks on quality , because models don't read a long window evenly. Relevant facts buried in the middle get underweighted; irrelevant bulk competes for attention with the thing that actually answers the question. Past a point, a bigger context produces a worse answer, not just a costlier one. So the interesting question isn't "how do we fit more in?" It's "how do we keep the window small and dense without losing the one old turn that matters?" This post is the design we built around that question — for the specific case of long conversation history — plus the benchmark we used to keep ourselves honest. 01 · The mechanism: a hot index over a cold store The design borrows directly from how computers have always managed memory that doesn't fit: a small fast tier that's always present, a large slow tier that holds the bulk, and a rule for moving things between them. Virtual memory pages between RAM and disk. We page between the context window and an external store — for attention instead of address space. Concretely, there are two tiers. The cold store holds every turn at full fidelity, keyed by id — nothing is thrown away. The hot index holds one compact entry per turn: a short summary, a little metadata (entities, whether the turn recorded a dec
AI 资讯
Qwen3.6-27B + vLLM + Hermes on 24GB VRAM: May 2026 Recipe
If you want to reproduce my current local Hermes Agent + Qwen3.6-27B setup, this is the shape I would start from. Target One local coding agent. One 24GB GPU. Long context. Tools enabled. Thinking enabled. No child agents fighting the main request. The goal is not peak tok/s on a short prompt. The goal is: can the same agent session keep working after hours of tool calls without losing prefix locality, timing out during prefill, or getting wrecked by auxiliary requests? Model This setup is intentionally text-only. I am not serving the multimodal GGUF variant here. The working configuration uses groxaxo/Qwen3.6-27B-GPTQ-Pro-4bit through vLLM with --language-model-only . That choice matters. On a 24GB RTX 3090, the text-only GPTQ-Marlin path gave the best balance I found between long context, prefix caching, stable agent behavior and usable decode speed. Vision should be handled by a separate service/model if needed. vLLM The useful shape: CUDA_VISIBLE_DEVICES = 0 vllm serve groxaxo/Qwen3.6-27B-GPTQ-Pro-4Bit \ --served-model-name qwen3.6-27b-gptq-pro-4bit \ --dtype float16 \ --quantization gptq_marlin \ --tensor-parallel-size 1 \ --max-model-len 131072 \ --max-num-seqs 1 \ --kv-cache-dtype fp8_e5m2 \ --enable-prefix-caching \ --reasoning-parser qwen3 \ --enable-auto-tool-choice \ --tool-call-parser qwen3_coder \ --gpu-memory-utilization 0.95 \ --max-cudagraph-capture-size 32 \ --language-model-only I used a recent vLLM nightly, not an old stable image ( 0.20.1rc1.dev16+g7a1eb8ac2 ). The two flags people will want to argue about: --max-num-seqs 1 --max-model-len 131072 I use max_num_seqs=1 deliberately. With an agent, parallelism is not free. Title generation, context compression, retries, browser checks, tool calls and side jobs can all steal KV/cache locality from the main request. On one 24GB GPU I prefer one useful request over two requests sabotaging each other. 131k context is tight, but workable here. If your service OOMs, reduce context before adding MTP or enf
AI 资讯
Your RAG Retrieved the Right Documents but Still Gave the Wrong Answer
Your retriever returned the right documents. The similarity scores look fine. The answer is still wrong. If you've shipped RAG, you've seen this — and it's the failure that survives every retrieval upgrade. What everyone tries Reranker. Higher top-k. Hybrid search. A better embedding model. All of these chase the same goal: documents more similar to the query. They help when the right document wasn't being retrieved. They do nothing when the right document was retrieved and the answer is still wrong. Why it doesn't work Similarity answers "is this chunk about the same topic?" It does not answer "does this chunk contain the facts needed to support the answer?" Those come apart constantly. A chunk can be highly similar — same vocabulary, same subject — and contain nothing that actually grounds the answer. Hand the model a pile of on-topic text and it will produce a fluent, plausible, even cited-looking answer. The grounding is cosmetic: the text was nearby, not load-bearing. High similarity with a wrong answer isn't a contradiction. You asked retrieval to find related text. It did. Nobody asked whether the text was enough. The one shift Stop treating retrieval output as evidence. Treat it as candidate material that has to pass an explicit evidence check before it can support an answer. Put a step between retrieval and generation: does the retrieved set actually contain the facts this answer requires? If not, abstain. When the documents don't contain the facts, the system should return nothing rather than a confident guess. Relevant context in, only sufficient evidence allowed through. That's the line between a RAG demo and a RAG system you can trust in production. I write about the three boundaries where production RAG dies — query, evidence, output — from the angle of shipping under security and model constraints. Read the full version on my blog , where this connects to the practical RAG Failure Diagnosis Kit for teams debugging production RAG.
AI 资讯
Cost Optimization for LLM Systems: Where the Money Actually Goes
LLM costs scale linearly with usage. A system processing 10,000 requests a day at $0.01 per request costs $100 daily — $365 a year. At enterprise scale, that's over $10,000. Cost optimization isn't about cutting corners. It's about spending tokens where they matter. Every token you waste is a token you could have spent on a better answer. Token budgeting The simplest way to control costs is to set limits. Per session, per task, or per day. Strategy 1: Per-Session Budgets Per-session budgets are straightforward: class SessionBudget : def __init__ ( self , budget_tokens : int = 10000 ): self . budget = budget_tokens self . used = 0 def allocate ( self , tokens : int ) -> bool : if self . used + tokens <= self . budget : self . used += tokens return True return False def remaining ( self ) -> int : return self . budget - self . used Strategy 2: Per-Task Budgets Per-task budgets are more useful. Different tasks need different amounts of context: task_budgets : classify : max_tokens : 100 model : qwen2.5-1.5b summarize : max_tokens : 500 model : qwen2.5-7b code_review : max_tokens : 2000 model : qwen2.5-coder-7b reason : max_tokens : 4000 model : qwen2.5-32b Strategy 3: Adaptive Budgets Adaptive budgets adjust based on what actually happens. If classification tasks consistently use 80 tokens, stop allocating 100: class AdaptiveBudget : def __init__ ( self ): self . task_history = {} def allocate ( self , task_type : str ) -> int : if task_type in self . task_history : return int ( self . task_history [ task_type ] * 1.5 ) return 1000 def record ( self , task_type : str , tokens_used : int ): if task_type not in self . task_history : self . task_history [ task_type ] = tokens_used else : self . task_history [ task_type ] = ( 0.9 * self . task_history [ task_type ] + 0.1 * tokens_used ) The exponential moving average (0.9 weight) means recent usage matters more than history. Adjust the weight based on how volatile your workloads are. API vs local inference Local inference
AI 资讯
LLM Guardrails in Practice: What Actually Works
LLMs are unpredictable. They hallucinate, leak data, generate harmful content, or refuse legitimate requests. Guardrails constrain model behavior without sacrificing capability. The key is knowing which guardrails matter and which are just noise. Guardrails aren't about controlling the model. They're about controlling the risk. Input validation The most important guardrail. Bad input gets bad output, and bad input can also prompt-inject your system. Strategy 1: Prompt Sanitization Sanitize dangerous patterns early: import re class PromptSanitizer : def __init__ ( self ): self . dangerous_patterns = [ r " ignore\s+previous\s+instructions " , r " system\s+prompt " , r " you\s+are\s+now\s+free " , r " break\s+out\s+of " , ] def sanitize ( self , prompt : str ) -> str : for pattern in self . dangerous_patterns : prompt = re . sub ( pattern , " [REDACTED] " , prompt , flags = re . IGNORECASE ) return prompt This isn't bulletproof. Adversarial inputs are creative. But it catches the obvious ones, and the obvious ones are the most common. Strategy 2: Input Length Limits Length limits prevent token waste and timeouts: class InputValidator : def __init__ ( self , max_length : int = 10000 ): self . max_length = max_length def validate ( self , prompt : str ) -> tuple [ bool , str ]: if len ( prompt ) > self . max_length : return False , f " Input too long: { len ( prompt ) } > { self . max_length } " return True , " OK " Strategy 3: Content Filtering Content filtering blocks policy violations. The patterns here depend on your domain: class ContentFilter : def __init__ ( self ): self . blocked_topics = [ " violence " , " hate speech " , " self-harm " , " sexual content " , " illegal activities " , ] def filter ( self , prompt : str ) -> tuple [ bool , str ]: prompt_lower = prompt . lower () for topic in self . blocked_topics : if topic in prompt_lower : return False , f " Blocked: { topic } " return True , " OK " Simple string matching is fast but imprecise. For production, us
AI 资讯
Model Routing: Stop Using One Model for Everything
Running a 70B parameter model to summarize a 200-word email is wasteful. Running a 3B model to review production code is reckless. Most systems live somewhere in between — and that's where model routing comes in. It matches task complexity to model capability. The tradeoffs are real, but the savings are too. The routing problem People usually start with one model and stick with it. That works until you notice the cost, or the latency, or both. The alternative is building a router — something that decides which model handles which request. Four strategies work in practice: Capability-based — route by what the model can do Cost-aware — route by what you're willing to spend Latency-aware — route by how fast you need it Hybrid — combine them Each optimizes something different. Picking one is usually a decision about what hurts most. Capability-based routing The simplest approach. Classify the task, send it to the model that handles it. Task Model size Examples Classification, tagging 1-3B Qwen2.5-1.5B, Gemma-2-2B Summarization, extraction 3-7B Qwen2.5-7B, Llama-3.1-8B Code generation 7-14B Qwen2.5-Coder-7B, DeepSeek-Coder-V2 Complex reasoning 14-32B Qwen2.5-32B, Llama-3.1-70B Creative writing, analysis 32B+ Qwen2.5-72B, Claude, GPT-4 If the task doesn't need the bigger model, don't use it. A 1.5B model handles sentiment classification fine. It just won't write a coherent essay. Implementation is straightforward: ROUTING_RULES = { " classify " : { " model " : " qwen2.5-1.5b " , " max_tokens " : 100 }, " summarize " : { " model " : " qwen2.5-7b " , " max_tokens " : 500 }, " code_review " : { " model " : " qwen2.5-coder-7b " , " max_tokens " : 2000 }, " reason " : { " model " : " qwen2.5-32b " , " max_tokens " : 4000 }, " creative " : { " model " : " claude-sonnet-4 " , " max_tokens " : 8000 }, } def route_request ( task_type : str ) -> dict : return ROUTING_RULES . get ( task_type , ROUTING_RULES [ " reason " ]) The catch is classification itself. If you get the task type
AI 资讯
Multi-Model System Design: When One Model Isn't Enough
Single-model systems are simple. Multi-model systems are powerful. The challenge isn't choosing models — it's designing the architecture that orchestrates them. A multi-model system isn't about having more models. It's about having the right model for the right task at the right time. Architecture patterns Five patterns cover most use cases: Pattern Complexity When to use Tradeoff Single Model Lowest Prototyping, simple tasks Limited capability Sequential Low Multi-step workflows Higher latency Parallel Medium Independent tasks Higher cost Hierarchical High Complex reasoning Complex orchestration Ensemble Highest Critical decisions Highest cost Pick the simplest one that works. Complexity is real, and it compounds. Sequential architecture Process tasks through a chain of models, each specializing in a step. Pattern 1: Pipeline Pipeline pattern — each model's output feeds the next: class ModelPipeline : def __init__ ( self ): self . models = [ { " model " : " qwen2.5-1.5b " , " task " : " classify " }, { " model " : " qwen2.5-7b " , " task " : " extract " }, { " model " : " qwen2.5-32b " , " task " : " reason " }, ] def process ( self , input : str ) -> str : current = input for model_config in self . models : current = self . call_model ( model_config [ " model " ], self . create_prompt ( model_config [ " task " ], current ) ) return current Latency adds up. Three models in sequence means three times the latency. Only use this when each step actually needs a different model. Pattern 2: Router Router pattern — classify the task, route to the specialist: class ModelRouter : def __init__ ( self ): self . classifier = " qwen2.5-1.5b " self . specialists = { " code " : " qwen2.5-coder-7b " , " math " : " qwen2.5-32b " , " creative " : " claude-sonnet-4 " , " general " : " qwen2.5-7b " , } def route ( self , prompt : str ) -> str : task_type = self . classify ( prompt ) model = self . specialists . get ( task_type , self . specialists [ " general " ]) return self . call_m
AI 资讯
How to Build a Multi-Step Agent Stress Test: Adversity Sandboxes and Oracle Checks
Building a prototype of an AI agent is fun. Building a production-ready agent is a nightmare. In a perfect world, your agent always gets the perfect context, the API never fails, and the model never gets "lazy." But in the real world, transient errors are a constant, and models love to take shortcuts. If you aren't testing your agent against the messy reality of production, you’re setting yourself up for failure. This is where our Agent Profiler comes in. We’ve designed it to be an "adversity sandbox." It doesn’t just ask your agent a question; it challenges it. We inject transient runtime errors, introduce "lazy-agent traps" that force the model to stay focused, and validate structural AST matches to ensure the agent is actually outputting what it claims to output. It’s an active testing loop designed to stress-test your agent’s self-recovery mechanics. If your agent can’t handle a little chaos in the test suite, it certainly won’t survive your users.
AI 资讯
Dify Agentic Workflow Platform: 5 Hidden Uses of the 145K-Star Open Source AI Stack
What if you could build a production-ready AI agent workflow in 10 lines of YAML — and have it handle retries, observability, and multi-model routing out of the box? Dify is an open-source LLM app development platform with 145,764 GitHub stars, 22,915 forks, and 460+ contributors. It just shipped v1.14.2 (May 2026) with security hardening, agent groundwork, and workflow reliability improvements. Yet most teams only use it as a no-code chatbot builder — completely missing the infrastructure underneath. In 2026, AI workflows have moved from "prompt and pray" to orchestrated multi-step pipelines with memory, tool calling, and observability. Dify sits at the center of this shift, combining visual workflow design, RAG pipelines, agent capabilities, and LLMOps in a single platform that runs on your own infrastructure. Here are 5 hidden uses of Dify that most teams never discover. Hidden Use #1: Visual Workflow as Code — Export, Version Control, and Replay What most people do: Build workflows in the Dify web UI, click "Run," and hope for the best. When something breaks, they debug by clicking through nodes manually. The hidden trick: Every workflow in Dify can be exported as YAML. You can version-control it in Git, diff changes between deployments, and replay any historical execution step-by-step using the built-in tracing API. # dify-workflow.yaml — a production RAG + agent pipeline app : name : " customer-support-agent" mode : " workflow" version : " 1.14.2" nodes : - id : " start" type : " start" variables : - name : " user_query" type : " string" required : true - id : " retriever" type : " knowledge-retrieval" dataset_ids : [ " faq-dataset-v3" ] top_k : 5 score_threshold : 0.7 depends_on : [ " start" ] - id : " llm-agent" type : " llm" model : " gpt-4o" prompt_template : | Context: {{ retriever.documents }} Question: {{ start.user_query }} Answer concisely using only the context above. depends_on : [ " retriever" ] - id : " output" type : " end" output : " {{ llm-agen
AI 资讯
Dify 的 5 个隐藏用法:14.5 万 Star 的开源 AI 工作流平台
如果你能用 10 行 YAML 构建一个生产级的 AI Agent 工作流——并且自带重试、可观测性和多模型路由——你会怎么做? Dify 是一个开源的 LLM 应用开发平台,拥有 145,764 个 GitHub Stars、22,915 个 Fork、460 多位贡献者。它刚刚发布了 v1.14.2(2026 年 5 月),包含安全加固、Agent 基础架构和工作流可靠性改进。但大多数团队只把它当作无代码聊天机器人构建器——完全忽略了底层的基础设施能力。 2026 年,AI 工作流已经从"写个 prompt 然后祈祷"进化到了具备记忆、工具调用和可观测性的多步骤编排管道。Dify 正处于这个转变的中心,将可视化工作流设计、RAG 管道、Agent 能力和 LLMOps 整合在一个可以部署在你自己基础设施上的平台中。 以下是大多数人从未发现的 Dify 的 5 个隐藏用法。 隐藏用法 #1:可视化工作流即代码——导出、版本控制与回放 大多数人的做法: 在 Dify 网页 UI 中构建工作流,点击"运行",然后祈祷一切正常。出了问题就手动点击每个节点来调试。 隐藏技巧: Dify 中的每个工作流都可以导出为 YAML。你可以在 Git 中进行版本控制,对比不同部署之间的差异,并使用内置的追踪 API 逐步回放任何历史执行。 # dify-workflow.yaml — 一个生产级 RAG + Agent 管道 app : name : " customer-support-agent" mode : " workflow" version : " 1.14.2" nodes : - id : " start" type : " start" variables : - name : " user_query" type : " string" required : true - id : " retriever" type : " knowledge-retrieval" dataset_ids : [ " faq-dataset-v3" ] top_k : 5 score_threshold : 0.7 depends_on : [ " start" ] - id : " llm-agent" type : " llm" model : " gpt-4o" prompt_template : | 上下文:{{ retriever.documents }} 问题:{{ start.user_query }} 请仅使用以上上下文简洁回答。 depends_on : [ " retriever" ] - id : " output" type : " end" output : " {{ llm-agent.text }}" depends_on : [ " llm-agent" ] tracing : enabled : true backend : " langfuse" # 或 opik、arize-phoenix sample_rate : 1.0 效果: 你的整个 AI 管道变成了基础设施即代码。你可以 CI 测试工作流变更、回滚到历史版本、审计每次执行追踪——就像管理 Terraform 或 Kubernetes 清单一样。 数据来源: Dify GitHub 145,764 Stars、22,915 Forks(GitHub API,langgenius/dify,2026-06-19 推送)。最新版本 v1.14.2(2026-05-19)包含工作流可靠性修复。460+ 贡献者(GitHub API 确认)。 隐藏用法 #2:多模型路由与自动降级 大多数人的做法: 选一个模型(通常是 GPT-4),硬编码到每个工作流节点中。当这个模型出现故障或限流时,整个管道就崩溃了。 隐藏技巧: Dify 的模型配置支持提供程序级别的自动降级链。你可以配置主模型、备用模型,甚至为非关键路径配置第三级廉价模型——所有这些都无需修改工作流逻辑。 # dify_model_config.py — 通过 Dify API 配置多模型路由 import requests DIFY_API_KEY = " your-api-key " DIFY_BASE = " https://your-dify-instance.com/v1 " def configure_model_fallback (): """ 为生产弹性配置 3 层模型降级链。 """ # 主模型:GPT-4o,高质量推理 # 备用 1:Claude 3.5 Sonnet(不同提供程序,同等级别) # 备用 2:GPT-4o-mini(廉价、快速,简单步骤足够用) config
AI 资讯
How Clioloop's Agentic Fusion Works: A Technical Deep Dive
Architecture Overview Clioloop's Agentic Fusion is not just "run the same prompt 5 times and pick the best." It's a structured pipeline where different models play different roles, with strict security boundaries between them. The Pipeline Step 1: Planning Phase When you run /fusion , up to 5 planner models are dispatched in parallel. Each planner: Receives your original prompt and context Has read-only tool access — they can search the web, read files, but never modify anything Proposes an approach (not an answer — an approach) The planners might suggest different strategies: Planner A: "Search the web for similar problems, then write a script" Planner B: "Read the existing codebase first, then modify in place" Planner C: "Break it into subtasks and use the Kanban system" Step 2: Execution Phase Your main model takes the planners' proposals and does the actual work: Full tool access (file editing, shell, web, browser, image gen, etc.) Fully visible — you watch every file edit, every command, every web search in real time Not a black box — you can intervene at any time This is the key difference from "ensemble" approaches: the main model does real work with real tools, not just text generation. Step 3: Review Phase Up to 5 reviewer models critique the draft: Read-only access — they can see what the main model produced, including generated images They check for errors, suggest improvements, flag problems Each reviewer works independently Step 4: Verdict Loop The draft is revised based on reviewer feedback: If reviewers find issues, the main model gets the feedback and revises The loop continues until reviewers approve You get the final, reviewed answer Step 5: Fusion Everything combines into one answer that has already passed independent review. Security Model The safety comes from schema-level restrictions : Role Can Read Can Write Can Execute Planners ✅ Files, web, images ❌ Nothing ❌ Nothing Main Model ✅ Everything ✅ Files ✅ Commands Reviewers ✅ Draft, files, image
AI 资讯
Clioloop: The Open-Source AI Agent That Thinks in Teams
The Problem Most AI assistants give you one model's answer. If it's wrong, you catch it or you don't. If you use a cheap model, quality drops. If you use a frontier model, you pay frontier prices for everything — even a simple file rename. What is Agentic Fusion? When you run /fusion , a panel of models collaborates on your task: Planners (up to 5): Read-only models that research and propose routes in parallel. They figure out the best approach but can't touch your files or run commands. Main model : Your chosen model does the actual work — full tool access, fully visible. You watch every step. Not a black box. Reviewers (up to 5): Read-only models that critique the draft. They can see images the main model generated. They check for errors, suggest fixes, flag issues. Verdict loop : The draft is revised until reviewers approve. The answer you get has already passed independent review. Fusion : Everything combines into one reviewed, approved answer. The quality comes from synthesis — not from running the same job 5 times. Cheap open models combine into something that rivals a frontier model at a fraction of the cost. Safety by Construction Planners and reviewers are read-only at the schema level. They can research and critique, but they can never touch your files or execute commands. Only your main model has tool access, and you watch it work live. Beyond Fusion Clioloop is also: Self-improving : Keeps MEMORY.md and USER.md , updated automatically Autonomous : Set a standing goal with /goal and it loops until done Everywhere : Terminal, desktop app, web dashboard, Telegram, Slack, Discord, WhatsApp Multi-agent Kanban : Break big work into tasks with worker agents Tools : File editing, shell, web search, browser, image/video gen, TTS, MCP Scheduled jobs : Run on cron for automated workflows Open-source : Self-host everything, own your data The Omni Loop Portal One OAuth login gives you access to 300+ models. No API keys. An OpenAI-compatible proxy means any tool works
AI 资讯
The Cheaper API Was 2.5x Cheaper. It Cost 1.6x More.
AI-disclosure: AI-assisted draft, human-reviewed. The demo numbers are the verbatim stdout of a deterministic, stdlib-only Python script included in full below — re-run it and you get the same bytes. The attempt counts in that script are a SYNTHETIC fixture I chose to exercise the accounting mechanism, calibrated to the retry skew I see in my own scraper logs (run counts from my Apify history). It is NOT a benchmark of any named vendor's API or prices. The one external claim (the cost-per-successful-task formula) is attributed and linked. The cheaper API was 2.5x cheaper per call. The monthly bill came in higher anyway. Not by a rounding error. The "cheap" option cost 1.63x more per successful task than the one with the bigger sticker price. Same workload. The price page never showed me that number, because the price page doesn't know your success rate. You do — after you've already paid. This is the arithmetic the per-call price hides. And it's a decision you make before you spend, not a cap you bolt on after. TL;DR You compare two API tiers by per-call (or per-token) price and pick the cheaper one. That ranking can be wrong. You pay for every attempt — success or fail. The denominator that pays the bills is successful tasks , not calls. True cost = price_per_attempt × attempts ÷ successes . A cheap tier with a low success rate burns its discount on retries. In the run below: cheap tier $0.0020 /call but $0.0096 /success; robust tier $0.0050 /call but $0.0059 /success. The sticker winner loses . For anyone choosing an API, model, or tier for an agent: log attempts and successes for a week, divide, then decide. A 70-line script is at the bottom — drop in your numbers. The price page is a sticker, not a bill Here's the trap, stated plainly. The number on the pricing page is per call . The number on your invoice is per call too — but the value you got is per successful task . Those are different denominators, and the gap between them is exactly the work that failed. E