惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cybersecurity and Infrastructure Security Agency CISA
D
Darknet – Hacking Tools, Hacker News & Cyber Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Schneier on Security
L
Lohrmann on Cybersecurity
S
Securelist
P
Palo Alto Networks Blog
SecWiki News
SecWiki News
T
Troy Hunt's Blog
H
Hacker News: Front Page
AWS News Blog
AWS News Blog
Latest news
Latest news
Hacker News - Newest:
Hacker News - Newest: "LLM"
NISL@THU
NISL@THU
The Hacker News
The Hacker News
F
Full Disclosure
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
O
OpenAI News
P
Proofpoint News Feed
Know Your Adversary
Know Your Adversary
G
GRAHAM CLULEY
博客园_首页
Attack and Defense Labs
Attack and Defense Labs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
WordPress大学
WordPress大学
www.infosecurity-magazine.com
www.infosecurity-magazine.com
宝玉的分享
宝玉的分享
L
LINUX DO - 热门话题
博客园 - 叶小钗
L
LINUX DO - 最新话题
Martin Fowler
Martin Fowler
N
News | PayPal Newsroom
Project Zero
Project Zero
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
PCI Perspectives
PCI Perspectives
月光博客
月光博客
IT之家
IT之家
Recent Announcements
Recent Announcements
T
The Exploit Database - CXSecurity.com
D
DataBreaches.Net
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
Google Online Security Blog
Google Online Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
I read the OpenClaw thread everyone shared — these 5 fixes cut agent costs to one-third and stopped the loops
Lars Winstan · 2026-05-20 · via DEV Community

I read the OpenClaw thread everyone shared — these 5 fixes cut agent costs to one-third and stopped the loops

I clicked into a popular r/openclaw thread expecting the usual advice: tweak the prompt, pick a smarter model, maybe add more context.

Instead, the OP described the exact failure mode a lot of us hit when we move from demos to always-on agents:

  • Claude Opus 4.6 handling cheap background work
  • vague completion criteria
  • retries with no hard stop
  • state living inside prompts instead of durable storage
  • loops burning money while doing almost nothing useful

The useful part was that this wasn’t one silver bullet. It was a stack of practical fixes.

And the biggest one was brutally simple:

stop sending cheap work to expensive models

According to the thread, moving heartbeat checks, cron pings, and other low-value supervision off Claude Opus cut spend to about one-third.

That tracks with what I keep seeing in OpenClaw, n8n, Make, Zapier, and custom worker setups. The expensive part usually isn’t the main reasoning step. It’s the invisible scaffolding around it.

If you’re building long-running agents, these 5 fixes are worth stealing.

The pattern: cost problems start as reliability problems

Agents rarely become expensive because one prompt was huge.

They become expensive because a workflow can’t confidently tell whether it succeeded.

Then it retries.

Then it retries again.

Then it does all of that on Claude Opus 4.6.

That’s how you end up paying premium-model rates for what is basically daemon maintenance.

A rough version of the bad pattern looks like this:

while (!done) {
  const result = await callModel({
    model: "claude-opus-4-6",
    prompt: `Check whether the job completed. If not, decide what to do next. Context: ${hugeContext}`
  })

  if (result.saysDone) {
    done = true
  } else {
    await sleep(30000)
  }
}

Enter fullscreen mode Exit fullscreen mode

This looks fine in testing.

It gets ugly when it runs 24/7.

Fix 1: Stop using Claude Opus for heartbeat checks and cron pings

This was the clearest lesson from the thread.

Claude Opus 4.6 is great for hard reasoning. It is a bad choice for cheap supervision.

Tasks that usually should not hit your most expensive model:

  • heartbeat checks n- cron-trigger validation
  • retry bookkeeping
  • simple routing
  • status classification
  • watchdog logic
  • "did this step finish?" checks

If the task is basically classification or state inspection, use a cheaper layer.

A cleaner architecture looks more like this:

async function routeTask(task: Task) {
  if (task.type === "heartbeat") {
    return lightweightCheck(task)
  }

  if (task.type === "status_check") {
    return gpt54StatusCheck(task)
  }

  if (task.type === "deep_reasoning") {
    return claudeOpusDecision(task)
  }

  if (task.type === "synthesis") {
    return grok420Synthesis(task)
  }
}

Enter fullscreen mode Exit fullscreen mode

That’s the right mental model: model triage.

Not loyalty.

Not “send everything to the smartest model.”

Just match cost to task difficulty.

My take

The loser here is the all-Claude-Opus architecture. It feels elegant until you realize your agent is using a premium model to narrate its own retries.

If a task could be implemented as a boolean check, a rules engine, or a cheap classifier, don’t wrap it in expensive reasoning.

Fix 2: Add explicit success criteria or the agent will loop forever

A lot of agent loops are just weak definitions of done.

Bad:

  • “make sure the sync worked”
  • “confirm the task completed”
  • “retry if needed”

Better:

  • file exists at expected path
  • API returned HTTP 200
  • row count increased by 1
  • webhook delivered with matching job ID
  • CRM record status changed to processed

The thread’s OP improved reliability by making completion verifiable instead of interpretive.

That’s the difference between an agent that finishes and an agent that keeps thinking out loud.

Example:

async function verifyJobComplete(jobId: string) {
  const res = await fetch(`https://api.example.com/jobs/${jobId}`)
  const job = await res.json()

  return job.status === "completed" && job.output_url != null
}

Enter fullscreen mode Exit fullscreen mode

Then your loop becomes:

for (let attempt = 1; attempt <= 5; attempt++) {
  await runStep(jobId)

  const ok = await verifyJobComplete(jobId)
  if (ok) return { success: true }

  await sleep(5000)
}

return { success: false, reason: "verification_failed_after_5_attempts" }

Enter fullscreen mode Exit fullscreen mode

That’s boring code.

Boring is good.

Boring code is cheaper than “agent intuition.”

Fix 3: Put anti-loop rules in code, not just prompts

If your only loop prevention is “please do not retry excessively,” you do not have loop prevention.

You have wishful thinking.

Hard limits matter:

  • max retries per step
  • max retries per job
  • cooldown windows
  • duplicate action detection
  • dead-letter queue for stuck runs
  • escalation path to human review

A practical pattern:

const MAX_STEP_RETRIES = 3
const MAX_JOB_RETRIES = 10

async function shouldRetry(state: WorkflowState) {
  if (state.stepRetries >= MAX_STEP_RETRIES) return false
  if (state.jobRetries >= MAX_JOB_RETRIES) return false
  if (state.lastError === "invalid_input") return false
  return true
}

Enter fullscreen mode Exit fullscreen mode

And log retry reasons explicitly:

{
  "jobId": "job_123",
  "step": "sync_customer",
  "retry": 2,
  "reason": "webhook_timeout",
  "nextAttemptInSeconds": 30
}

Enter fullscreen mode Exit fullscreen mode

This is where a lot of teams get lazy. They let the model decide whether another retry “feels right.”

Don’t do that.

Retries are control flow. Control flow belongs in code.

Fix 4: Store state in Redis or Postgres instead of re-prompting old context

This one matters a lot for long-running OpenClaw jobs.

If an agent made a decision, store it somewhere durable.

Don’t keep shoving the same history back into the prompt and hope compaction preserves the important part.

That approach fails first when your workflow crosses tools.

A realistic automation might look like this:

  1. OpenClaw decides to start a task
  2. n8n waits for a webhook
  3. Make transforms the payload
  4. Zapier updates Salesforce or HubSpot
  5. the agent wakes up six minutes later and needs to resume

If the only memory is inside a shrinking prompt window, drift is inevitable.

If the state is in Redis or Postgres, the agent can resume from facts.

Redis example

import Redis from "ioredis"

const redis = new Redis(process.env.REDIS_URL!)

async function saveWorkflowState(jobId: string, state: object) {
  await redis.set(`workflow:${jobId}`, JSON.stringify(state), "EX", 86400)
}

async function loadWorkflowState(jobId: string) {
  const raw = await redis.get(`workflow:${jobId}`)
  return raw ? JSON.parse(raw) : null
}

Enter fullscreen mode Exit fullscreen mode

Postgres example

create table workflow_state (
  job_id text primary key,
  status text not null,
  last_decision jsonb not null,
  retry_count integer not null default 0,
  updated_at timestamptz not null default now()
);

Enter fullscreen mode Exit fullscreen mode

Then your agent prompt can stay small and focused:

Job status: awaiting_webhook
Last decision: wait for provider callback
Retry count: 1
Next action options: [poll_status, mark_failed, continue_waiting]

Enter fullscreen mode Exit fullscreen mode

That’s much better than pasting 4,000 tokens of historical narration back into every call.

My take

A lot of teams pay premium model costs to compensate for weak state handling.

That’s backwards.

Better state is cheaper than better prompting.

Fix 5: Separate orchestration from reasoning

This is the architectural version of the first four fixes.

Use code for orchestration.
Use models for reasoning.

Not the other way around.

Your worker should own:

  • retries
  • scheduling
  • idempotency
  • state transitions
  • timeout handling
  • webhook correlation
  • rate limiting

Your model should own:

  • ambiguous classification
  • planning when rules are insufficient
  • summarization
  • extraction when structure is messy
  • non-trivial decision-making

A simple split:

async function processJob(job: Job) {
  const state = await loadWorkflowState(job.id)

  switch (state.status) {
    case "awaiting_classification":
      return classifyWithGPT54(job)

    case "awaiting_complex_decision":
      return decideWithClaudeOpus(job)

    case "awaiting_status_check":
      return pollProviderAPI(job)

    case "awaiting_synthesis":
      return synthesizeWithGrok(job)

    default:
      throw new Error(`Unknown state: ${state.status}`)
  }
}

Enter fullscreen mode Exit fullscreen mode

This is less magical than “autonomous agent does everything.”

It’s also much more reliable.

What changed after these fixes

The thread’s reported result was the kind of improvement that actually changes workflow design:

  • spend dropped to about one-third
  • loops were reduced
  • reliability improved
  • long-running jobs stopped losing the plot

That sequence makes sense.

First, move cheap recurring work off expensive models.
Then define what success actually means.
Then stop retries from becoming infinite.
Then give the agent durable state.

Once you do that, you stop paying for confusion.

The practical checklist

If you’re running OpenClaw agents or similar automations, here’s the checklist I’d use:

Fix What to do
Model triage Keep Claude Opus 4.6 for hard reasoning. Use GPT-5.4 or cheaper logic for status checks, routing, and supervision.
Verifiable completion End every important step with a testable success condition.
Anti-loop controls Set max retries, cooldowns, duplicate detection, and dead-letter handling in code.
Durable state Store decisions in Redis, Postgres, or OpenClaw memory features instead of bloating prompts.
Orchestration split Let code manage workflow control flow; let models handle actual reasoning.

Why this matters more under per-token billing

This is the part people notice late.

Per-token pricing punishes exactly the kind of behavior serious automations need:

  • watchdog checks
  • retries
  • polling
  • long-running supervision
  • cross-tool coordination

In a chat app, one bad retry is annoying.

In OpenClaw, n8n, Make, Zapier, or a custom queue, one bad retry pattern can run every few minutes forever.

That’s why predictable pricing matters more as agents get more useful.

The more background calls your system needs, the worse token anxiety gets.

If you’re running agents continuously, a flat-cost API setup is often a better fit than metering every tiny supervision call. Standard Compute is interesting here because it keeps the OpenAI-compatible API shape developers already use, but swaps per-token pricing for a predictable monthly cost. That makes a lot more sense for always-on automations than staring at usage charts and hoping your watchdog logic behaves.

Final thought

The best part of that OpenClaw thread was that it didn’t pretend the answer was “just use a smarter model.”

It was the opposite.

Use Claude Opus 4.6 when the task deserves Claude Opus 4.6.
Use GPT-5.4 for lighter decisions.
Use Grok 4.20 when synthesis is the actual job.
And don’t ask premium models to babysit your infrastructure.

If a workflow can’t prove it finished, it will eventually loop.
If state only lives in prompts, it will eventually drift.
If retries are controlled by vibes, they will eventually get expensive.

That’s not just an OpenClaw lesson.

That’s the operating manual for any long-running AI automation.

If you’re building one right now, start by auditing every model call that happens when nothing interesting is happening.

That’s usually where the money is going.