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

推荐订阅源

博客园_首页
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tenable Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
L
LINUX DO - 热门话题
C
Cyber Attacks, Cyber Crime and Cyber Security
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
H
Hacker News: Front Page
C
Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Martin Fowler
Martin Fowler
Help Net Security
Help Net Security
Scott Helme
Scott Helme
U
Unit 42
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyberwarzone
Cyberwarzone
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
Cloudbric
Cloudbric
Simon Willison's Weblog
Simon Willison's Weblog
A
Arctic Wolf
云风的 BLOG
云风的 BLOG
V
Vulnerabilities – Threatpost
Stack Overflow Blog
Stack Overflow Blog
T
Tor Project blog
O
OpenAI News
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Exploit Database - CXSecurity.com
MyScale Blog
MyScale Blog
罗磊的独立博客
美团技术团队
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Apple Machine Learning Research
Apple Machine Learning Research
PCI Perspectives
PCI Perspectives
P
Privacy International News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Recorded Future
Recorded Future
Application and Cybersecurity Blog
Application and Cybersecurity Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - Franky
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Blog — PlanetScale
Blog — PlanetScale

Hacker News - Newest: "AI"

AI can't read an investor deck AI as an attorney? Student uses ChatGPT, Gemini to sue UW over alleged racial discrimination Hacking MCP Servers in AI Systems – The Rug Pull: Tool Changes After Approval GitHub - MeepCastana/KubeezCut: Free Web based video editor GitHub - GenAI-Gurus/awesome-eu-ai-act: Curated tools, official sources, OSS, templates, and guides for EU AI Act compliance. Can AI judge journalism? A Thiel-backed startup says yes, even if it risks chilling whistleblowers Coming soon: 10 Things That Matter in AI Right Now DARPA built an AI to fact-check enemy weapons claims What explains heterogeneity in AI adoption? When AI Meets Muscle: Context-Aware Electrical Stimulation Promises a New Way to Guide Human Movements - Department of Computer Science AI Changed How We Build. It Did Not Change What Matters. Linux rules on using AI-generated code - Copilot is OK, but humans must take 'full responsibility for the… Meta spins up AI version of Mark Zuckerberg to engage with employees Code Mode: Let Your AI Write Programs, Not Just Call Tools | TanStack Blog GitHub - Delavalom/graft: Go framework for building AI agents. Type-safe tools, multi-provider (OpenAI, Anthropic, Gemini, Bedrock), zero vendor SDKs. India's TCS tops estimates, says new AI models did not dent services demand Gen Z's fading AI hype Strong feeling: we are in a folded AI reality GitHub - machinarii/total-recall-catalog: A reference catalog of latest knowledge retrieval, memory & RAG systems GitHub - mensfeld/code-on-incus: Give each AI agent its own isolated machine with root, Docker, and systemd. Active defense detects and stops threats automatically.. Quantization, LoRA, and the 8% Problem: Benchmarking Local LLMs for Production AI Iran war: We spoke to the man making Lego-style AI videos that experts say are powerful propaganda Powell, Bessent discussed Anthropic's Mythos AI cyber threat with major U.S. banks GitHub - immartian/bellamem: Persistent belief-graph memory for AI agents. Retrieves decisive context by importance — not recency, not RAG, not /compact. recursive-mode: The Repo-Native Operating System for AI Engineering After the attack on Sam Altman's home, will AI CEO's go on the offensive? The biggest advance in AI since the LLM Opus 4.6 vs GPT 5.4 One Prompt Unity World Generation Test “AI polls” are fake polls Client Challenge Can AI be a 'child of God'? Inside Anthropic's meeting with Christian leaders How to Switch AI Chatbots and Why You Might Want To GitHub - MattMessinger1/agentic_refund_guardrail: Safe refund policy layer for AI agents — Python + TypeScript. Same behavior, shared tests. Adam/papers/emergent_values_whitepaper.md at master · strangeadvancedmarketing/Adam Ask HN: How do you stop playing 20 questions with your AI coding tools How far can automation and AI support psychotherapy? - @theU GitHub - stagas/rtdiff: realtime git diff gui and AI-assisted commits A Mac Studio for Local AI — 6 Months Later A History of the Early Years of AI at the University of Edinburgh Why AI Coding Tools Still Feel Stuck on Localhost MSN AI Datacenters Are Becoming Strategic Targets twitter.com Penn Researchers Use AI to Surface Unreported GLP-1 Side Effects in Reddit Posts Show HN: MoodSense AI (ML and FastAPI and Gradio, Deployed on Hugging Face) Moodsense Ai - a Hugging Face Space by aman179102 AI models are terrible at betting on soccer—especially xAI Grok GitHub - xialeistudio/echoic GitHub - HimashaHerath/github-dev-wrapped: AI-powered weekly GitHub activity reports deployed to GitHub Pages GitHub - alejandrobalderas/claude-code-from-source: Architecture, patterns & internals of Anthropic's AI coding agent — reverse-engineered from source maps AI and Tech brief: Ireland ascendant GitHub - Titovilal/context0: Context0 - Never Surrender Training for a Marathon with an AI Coach: What Worked and What Didn't Cyber Pulse: Agentic Intel - Apps on Google Play I Built an AI PR Reviewer That Catches Bugs by Not Looking for Bugs Gen Z workers are so fearful AI will take their job they’re intentionally sabotaging their company’s AI rollout | Fortune How AI Is Reimagining the Game of Golf–For Both Players and Courses GitHub - nattergabriel/reseed: A CLI tool for managing and distributing agent skills across projects Is SVG the final frontier? My AI workflow evolved from prompts to a near-autonomous workflow MLSharp Help - 3DGS Viewer & Generator I put my cognitive field based AI's runtime on GitHub Is Numble the first AI-proof game? A3: Kubernetes for autonomous AI agent fleets | Emergent Principles Deepali Vyas ("The Elite Recruiter") GitHub - msmarkgu/RelayFreeLLM: A restful API designed to route user prompts to various AI model providers. Unionized ProPublica staff are on strike over AI, layoffs, and wages Unleashing the Advantage of Quantum AI We're heading for an AI-fueled 'dementia crisis,' brain scientist warns The AI-Assisted Breach of Mexico's Government Infrastructure [pdf] GitHub - stef41/lmscan: 🔍 Detect AI-generated text and fingerprint which LLM wrote it. Open-source GPTZero alternative. Zero dependencies, works offline. MSN GitHub - visionscaper/collabmem: Enabling long-term collaboration with Agentic AI - building up episodic and world model memory over time with in-context awareness We gave an AI a 3 year retail lease in SF and asked it to make a profit | Andon Labs AI Code is Hollowing Out Open Source, and Maintainers are Looking the Other Way What leaked "SteamGPT" files could mean for the PC gaming platform's use of AI AI is the boss at this retail store. What could go wrong? GitHub - Wuzu11517/agentic-proxy: Local proxy meant to help reduce With Drones, Geophysics and ArtificiaI Intelligence, Researchers Prepare to Do Battle Against Land Mines A Single Operator, Two AI Platforms, Nine Government Agencies: The Full Technical Report 在 Steam 上购买 FriedrichAI: Offline AI 立省 10% GitHub - inevolin/resume-cli: Hit Claude usage limits? Resume any AI coding session elsewhere. Switch tools at zero friction. GitHub - atripati/ark: AI Runtime Kernel — a context operating system for AI agents. Eliminates tool bloat, loads only what’s needed, and gives LLMs their reasoning space back. How to Build a Secure AI PR Reviewer with Claude, GitHub Actions, and JavaScript This Startup Wants You to Pay Up to Talk With AI Versions of Human Experts Intel Arc Pro B70 Brings 32GB VRAM to Local AI for $949 WordPress 7.0: The Good, the AI, and the Still Missing AI on the couch: Anthropic gives Claude 20 hours of psychiatry IatroBench: Pre-Registered Evidence of Iatrogenic Harm from AI Safety Measures AI Agents Know About Supabase. They Don't Always Use It Right. The history and future of AI at Google, with Sundar Pichai Inside an AI‑enabled device code phishing campaign How Meta Used AI to Map Tribal Knowledge in Large-Scale Data Pipelines AI for Systems: Using LLMs to Optimize Database Query Execution Forecasting the Economic Effects of AI Introducing Tinker: Play with AI, bring your ideas to life AI sheds light on an ancient gaming mystery People really hate AI but not as much as Iran—or Democrats | Fortune What is an AI Product Engineer? Phoebe Gates wants her $185 million AI startup to succeed with 'no ties to my privilege or my last name': 'I have a chip on my shoulder' | Fortune
Hash anchors + Myers diff + single-token anchors: 60% cheaper AI code edits
GodelNumberi · 2026-04-26 · via Hacker News - Newest: "AI"

TL;DR: This post introduces a novel and efficient code editing mechanism that builds on top of existing Hash Anchored edits, utilizes a stateful backend, single-token hash anchors, and the Myers Diff algorithm to re-anchor selectively. It is currently used in Dirac and found to be well suited for AI Agent tooling.

Premises

Some basic premises to put things into context.

  1. Reading and editing code are the two most frequent operations in agentic coding, with reads outnumbering edits by a significant margin.
  2. Output tokens cost 5-6x more than input tokens, and 50-60x more than cached read tokens (source: Anthropic, Gemini, OpenAI current costs).
  3. Tool call failure penalty grows with context size.

How current tooling handles code edits (Claude Code, GeminiCLI, Codex, etc.)

Pretty much every popular coding agent/harness/scaffolding uses some variant of search and replace for code edits. Claude and Gemini use plain search and replace while OpenAI uses the `apply_patch` tool, which utilizes the V4A diff format.

Consider a file like

# type: ignore
...previous_100_lines
def complex_payment_processor(transaction_data):
    logger.info("Starting processing")
    # ...[46 lines of validations, API calls, and db queries] ...
    logger.info("Payment successful")
    return {"status": "success"}

Suppose the task requires modifying most of the lines of this function. Here's roughly how each of OpenAI, Gemini, and Claude will emit the edit-file tool call (approximated based on specs, for illustration only).

OpenAI

{
  "tool_calls":[
    {
      "type": "function",
      "function": {
        "name": "apply_patch",
        "arguments": "{\n  \"operations\":[\n    {\n      \"type\": \"update_file\",\n      \"path\": \"payments.py\",\n      \"diff\": \"*** Update File: payments.py\\n-def complex_payment_processor(transaction_data):\\n-    # ... [48 lines of ORIGINAL code generated here prefixed with -] ...\\n-    return {\\\"status\\\": \\\"success\\\"}\\n+def complex_payment_processor(transaction_data, strict_mode=True):\\n+    # ... [48 lines of UPDATED code generated here prefixed with +] ...\\n+    return {\\\"status\\\": \\\"success\\\", \\\"strict\\\": True}\\n\"\n    }\n  ]\n}"
      }
    }
  ],
  "usage": {
    "approx_output_tokens": 1150
  }
}

Claude (Gemini uses similar format)

{
  "type": "tool_use",
  "name": "replace_in_file",
  "input": {
    "file_path": "payments.py",
    "old_text": "def complex_payment_processor(transaction_data):\n    logger.info(\"Starting processing\")\n    # ...[46 lines of ORIGINAL code generated here] ...\n    logger.info(\"Payment successful\")\n    return {\"status\": \"success\"}",
    "new_text": "def complex_payment_processor(transaction_data, strict_mode=True):\n    logger.info(\"Starting processing in strict mode\")\n    # ... [46 lines of UPDATED code generated here] ...\n    logger.info(\"Strict payment successful\")\n    return {\"status\": \"success\", \"strict\": True}"
  },
  "usage": {
    "approx_output_tokens": 1080
  }
}

The rule of thumb: each of those will generate the number of output tokens that are proportional to existing code to search (S) + new code to replace with (R). In other words, asymptotic complexity O(S+R). Also, S has a uniqueness constraint, meaning the model has to make sure that the search block it emits matches exactly one place in the target file (or the tool call will fail), which requires the model to include a few lines of context before and after S.

Two obvious shortcomings of this format:

  1. The model has to repeat the entire old code plus before/after lines token-for-token without a mistake even if it just wants to say replace lines X to Y with this.
  2. The larger the 'search' block grows, the higher the probability of the model making mistakes, and any single mistake in the search block causes the entire tool call to fail and the model has to generate the whole thing again.

Enter Hash Anchored Edits

This amazing post, "The Harness Problem" by Can Bölük, explains the mechanism really well. In fact, that was the post where I first learned about this idea.

The key insight: what if we enable the model to pinpoint a specific line or range of lines instead of asking it to write the entire search block?

The obvious thing you'd need for such a mechanism is to add some kind of line identification mechanism as control plane info that your agent adds to the file content each time the LLM asks to read a file. So instead of the example file we showed above, the model will read something like:

# type: ignore
# ...previous_100_lines
101:x9|def complex_payment_processor(transaction_data):
102:b4|    logger.info("Starting processing")
...[46 lines of validations, API calls, and db queries with their 5-token prefixes] ...
149:m2|    logger.info("Payment successful")
150:k3|    return {"status": "success"}

The format the linked article proposed was {line_number}:{2_character_hash}|{code}. Let's see how this will handle the edit above.

{
  "tool_calls":[
    {
      "type": "function",
      "function": {
        "name": "edit_file",
        "arguments": "{\n  \"file_path\": \"payments.py\",\n  \"start_anchor\": \"101:x9|\",\n  \"end_anchor\": \"150:k3|\",\n  \"replacement\": \"def complex_payment_processor(transaction_data, strict_mode=True):\\n    logger.info(\"Starting processing in strict mode\")\\n    # ...[46 lines of UPDATED raw code generated here] ...\\n    logger.info(\"Strict payment successful\")\\n    return {\\\"status\\\": \\\"success\\\"}\"\n}"
      }
    }
  ],
  "usage": {
    "approx_output_tokens": 540
  }
}

The key differentiator here is that the output token size reduces to new code to replace with (R), asymptotic complexity O(R). And since the output costs are a lot higher than input, this reduces the overall cost of edits. The difference is particularly large in cases when the model intends to simply delete hundreds of lines of code.

Issues with this approach

The protocol works like this: for an edit to be validated successfully, the code at the given line number has to match the hash on that line. If it doesn't, that's an error response back to the LLM saying the code has changed since your last read.

There are two issues in particular here:

  1. For every line read, regardless of it ever being edited, this approach has a 4-token overhead (5 tokens when the line number goes beyond 999) - one or two for the line number, one for :, one for 2-character hash, and one for |. This tradeoff is only worth it if the edits are proportionately large.
  2. More importantly, because the protocol is tied to line numbers, a single edit at the top of the file would invalidate the hash of all the subsequent lines. So, if the LLM made a 5 line change at the top of a 2000 line file, the whole file would need to be re-read to make further edits possible.

A new Hash Anchor-based solution

Let's rethink our requirements from the ground up and attempt to improve the Hash Anchoring. What do we need for a functional anchor-based editing tool?

  1. Something that pinpoints any line in any file (Anchor)
  2. Something that separates the Anchor from the corresponding code (Delimiter)
  3. Something that validates the LLM-proposed edits (Validator)
  4. Something that keeps track of which line of which file is associated with which anchor (State Manager)
  5. Something that can reconcile a file after edits are made, allocating new anchors to only changed lines (Reconciler)

Anchor

An anchor is simply a label, and there is nothing in our requirements that forces the line numbers to be part of the anchor. There is nothing stopping us from using plain English words as anchors if we are tracking the state separately. 'Cherry' can serve just as well as '101:ab'.

So, instead of generating hashes or words, I simply asked tiktoken to do it for me tiktoken.get_encoding("o200k_base"); then, through a process of iterative refinements, I ended up with about 1,700+ suitable single-word, single-token anchors. These anchors get shipped as an asset with the agent code.

Delimiter

Any simple symbol that's preferably not used in coding would suffice; I chose § for Dirac.

For the example above, Dirac reads something like

# type: ignore
...previous_100_lines
Moderator§def complex_payment_processor(transaction_data):
Qualifier§    logger.info("Starting processing")
...[46 lines of validations, API calls, and db queries with their 2-token prefixes] ...
Ripple§    logger.info("Payment successful")
Corona§    return {"status": "success"}

Validator

In lieu of the hashes, the tool-call in Dirac asks the model to use the full line as start/end anchors, the backend can simply do a string match to validate.

State Manager

Note that we moved away from the previous architecture in one significant way: the proposed architecture is no longer stateless. For example, 101:x9|def complex_payment_processor(transaction_data): can be validated purely from its content—any file anywhere with the line 101 containing that exact code will always yield the exact same hash.

In the proposed architecture, we need a State Manager to keep track of which line of which file is currently assigned which anchor. This was a deliberate decision because statelessness is not a prized attribute, particularly in AI agents that are already tracking a huge number of state variables for many things.

The State Manager essentially works like a bucket manager. It keeps task-scoped maps of every file that is read (integrated into all read-related tools). It starts with the aforementioned ~1,700 anchor list and starts assigning the anchors to lines. It keeps another list of 'used' anchors to prevent the same anchors from ever being reused for the same files. When it runs out, it starts using 2-token anchors. Everything goes through the Reconciler to keep a 'current' view of every file.

Reconciler

What happens when an edit is successful? Keeping that anchor state coherent in all cases is the Reconciler's job. There is already a well-established algorithm for this called the Myers Diff algorithm. GitHub uses it, so you've likely seen it in action.

The Reconciler applies the Myers Diff algorithm to any changed files to understand which lines now need new anchors and assigns them accordingly. If the user was to manually update the file in between, the Reconciler would fire from a file update hook.

After edits are validated and applied successfully by the tool, we send back the updated anchors in the response to the LLM.

Does it work?

This is already live in Dirac's VS Code extension and CLI (npm install -g dirac-cli) versions and has been working flawlessly.

See it in action with Deepseek-v4-flash here.

Results

In the test tasks, most of which require editing many files, this approach makes a significant difference, as proxied by the cost numbers below.

Task (Repo) Files* Cline Kilo Ohmypi Opencode Pimono Roo Dirac
DynamicCache (transformers) 8 🟢 (diff) [$0.37] 🔴 (diff) [N/A] 🟡 (diff) [$0.24] 🟢 (diff) [$0.20] 🟢 (diff) [$0.34] 🟢 (diff) [$0.49] **🟢 (diff) [$0.13]**
IOverlayWidget (vscode) 21 🟢 (diff) [$0.67] 🟡 (diff) [$0.78] 🟢 (diff) [$0.63] 🟢 (diff) [$0.40] 🟢 (diff) [$0.48] 🟡 (diff) [$0.58] **🟢 (diff) [$0.23]**
addLogging (vscode) 12 🟡 (diff) [$0.42] 🟢 (diff) [$0.70] 🟢 (diff) [$0.64] 🟢 (diff) [$0.32] 🟢 (diff) [$0.25] 🟡 (diff) [$0.45] **🟢 (diff) [$0.16]**
datadict (django) 14 🟢 (diff) [$0.36] 🟢 (diff) [$0.42] 🟡 (diff) [$0.32] 🟢 (diff) [$0.24] 🟡 (diff) [$0.24] 🟢 (diff) [$0.17] **🟢 (diff) [$0.08]**
extensionswb_service (vscode) 3 🔴 (diff) [N/A] 🟢 (diff) [$0.71] 🟢 (diff) [$0.43] 🟢 (diff) [$0.53] 🟢 (diff) [$0.50] 🟢 (diff) [$0.36] **🟢 (diff) [$0.17]**
latency (transformers) 25 🟢 (diff) [$0.87] 🟡 (diff) [$1.51] 🟢 (diff) [$0.94] 🟢 (diff) [$0.90] 🟢 (diff) [$0.52] 🟢 (diff) [$1.44] **🟢 (diff) [$0.34]**
sendRequest (vscode) 13 🟡 (diff) [$0.51] 🟢 (diff) [$0.77] 🟢 (diff) [$0.74] 🟢 (diff) [$0.67] 🟡 (diff) [$0.45] 🟢 (diff) [$1.05] **🟢 (diff) [$0.25]**
stoppingcriteria (transformers) 3 🟢 (diff) [$0.25] 🟢 (diff) [$0.19] 🟢 (diff) [$0.17] 🟢 (diff) [$0.26] 🟢 (diff) [$0.23] 🟢 (diff) [$0.29] **🟢 (diff) [$0.12]**
Total Correct 5/8 5/8 6/8 8/8 6/8 6/8 **8/8**
Avg Cost - $0.49 $0.73 $0.51 $0.44 $0.38 $0.60 $0.18

Full results, including all diffs, are available on the GitHub repository.

Also, Dirac scored 65.2% on the Terminal Bench 2.0 leaderboard using gemini-flash-3-preview (although a lot of that is attributable to other tools as well).

Word on Token Efficiency

This and all the other hard work that went into building Dirac are not about saving a few pennies here and there. I believe improving the token efficiency of AI agents is a rare outcome that's good for everyone involved. Better-curated context means better model capability (as LLM reasoning ability degrades with context length), lower API costs (a win for the user), better capacity utilization (a win for capacity-constrained labs), and the environmental win of lower electricity consumption overall. The individual task savings per session are pennies. Compounded across the industry, it's a meaningful number worth optimizing for.