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

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
InfoQ
D
DataBreaches.Net
Simon Willison's Weblog
Simon Willison's Weblog
F
Fortinet All Blogs
Help Net Security
Help Net Security
P
Proofpoint News Feed
F
Full Disclosure
G
GRAHAM CLULEY
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
Google Developers Blog
T
The Blog of Author Tim Ferriss
P
Palo Alto Networks Blog
T
Threat Research - Cisco Blogs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Microsoft Azure Blog
Microsoft Azure Blog
T
Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Register - Security
The Register - Security
The Hacker News
The Hacker News
Scott Helme
Scott Helme
T
Tor Project blog
Recorded Future
Recorded Future
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
Vercel News
Vercel News
L
Lohrmann on Cybersecurity
Know Your Adversary
Know Your Adversary
T
The Exploit Database - CXSecurity.com
IT之家
IT之家
C
Check Point Blog
NISL@THU
NISL@THU
Engineering at Meta
Engineering at Meta
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LangChain Blog
S
Schneier on Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
博客园 - 三生石上(FineUI控件)
Spread Privacy
Spread Privacy
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
The Cloudflare Blog

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. Amazon AI Cancelling Webcomics 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? 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
GitHub - Wuzu11517/agentic-proxy: Local proxy meant to help reduce
2026-04-10 · via Hacker News - Newest: "AI"

Python Version License Status FastAPI

A lightweight, drop-in proxy for the Anthropic API that reduces token usage and cost for AI agents — with zero changes to your agent code.


What it does

When you build an agent using the Anthropic API, every call costs tokens. Repeated calls, over-specified models, and bloated context all add up. agentic-proxy sits between your agent and the Anthropic API and optimizes each request transparently:

  • Caching — identical requests are served from a local cache instead of hitting the API. Cache hits cost nothing.
  • Model routing — each prompt is classified as simple, moderate, or complex. Simple prompts are automatically downgraded to a cheaper model (Haiku) instead of burning Sonnet or Opus.
  • Live dashboard — a real-time view of every call, token usage, cost, cache hit rate, and savings broken down by module — across sessions.

Your agent makes the same API calls it always did. It just points at localhost:8000 instead of api.anthropic.com.


How it works

Agent → agentic-proxy → Anthropic API
              ↓
    [cache check]         → cache hit: return immediately, $0 cost
    [model router]        → classify prompt, downgrade model if appropriate
    [forward request]     → send to Anthropic, stream response back
    [store in cache]      → save for future identical requests
    [log]                 → record tokens, cost, latency, routing decision

All of this is transparent to the agent. It sends a request and gets a response back — it has no idea any of this happened.


Quickstart

1. Clone and install

git clone https://github.com/yourname/agentic-proxy.git
cd agentic-proxy
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

2. Configure

cp .env.example .env

Open .env and add your Anthropic API key:

ANTHROPIC_API_KEY=your_api_key_here

3. Start the proxy

python main.py

The proxy starts on http://localhost:8000.

4. Point your agent at the proxy

The only change you need to make to your agent is the base URL:

import anthropic

client = anthropic.Anthropic(
    api_key="any-value",   # proxy handles auth from your .env
    base_url="http://localhost:8000"
)

That's it. All your existing agent code works unchanged.

5. Open the dashboard

While the proxy is running, open:

http://localhost:8000/dashboard

You'll see live stats, cache hit rate, cost savings, complexity distribution, and a full call log — updated every 2 seconds.


Configuration

All settings are controlled via .env. Copy .env.example to get started.

Variable Default Description
ANTHROPIC_API_KEY Required. Your Anthropic API key.
CACHE_ENABLED true Enable or disable the cache module.
ROUTER_ENABLED true Enable or disable model routing.
LOGGER_ENABLED true Enable or disable the session logger.
CACHE_TTL_HOURS 24 How long cache entries live before expiring.
CACHE_MAX_ENTRIES 1000 Maximum cache entries before LRU eviction kicks in.

Modules

Cache

Stores responses in a local SQLite database keyed by a SHA-256 hash of the full request body. On a cache hit the response is returned immediately with no API call.

  • TTL expiry — entries expire after CACHE_TTL_HOURS hours
  • LRU eviction — when the cache hits CACHE_MAX_ENTRIES, the least recently used entries are evicted first
  • Streaming support — cached responses are replayed as proper SSE events so streaming agents receive a correctly formatted stream

Model Router

Before forwarding a request, the router sends the prompt to a Haiku classifier that returns one of three complexity tiers:

Tier Examples Model
SIMPLE Summarize, translate, format, extract claude-haiku-4-5
MODERATE Write, explain, review, general coding claude-sonnet-4-6
COMPLEX Debug, architect, deep reasoning claude-opus-4-6

The router only downgrades — it never upgrades a model beyond what your agent specified. If your agent already uses Haiku, routing is skipped entirely.

The classifier prompt is truncated to 500 characters before being sent to keep classification cost minimal.

Logger

Every request is logged to SQLite with:

  • Timestamp, cache hit/miss, complexity, routing decision
  • Input/output token counts
  • Actual cost vs what it would have cost without the proxy
  • API latency and router latency

Logs persist across server restarts. The dashboard lets you view individual sessions or aggregate everything under Overall.


Streaming

agentic-proxy fully supports streaming requests (stream: true). Chunks are forwarded to the agent immediately as they arrive — the proxy buffers in the background to cache and log the response after the stream completes.

Cache hits for streaming requests are replayed as proper SSE events so the agent receives a correctly formatted stream regardless of whether the response came from cache or the API.


Dashboard

Open http://localhost:8000/dashboard while the proxy is running.

Summary stats

  • Total calls, cache hit rate, API calls
  • Total saved, cache savings, routing savings
  • Average API latency, average router latency
  • Current cache size vs maximum

Charts

  • Cache distribution (hits vs misses)
  • Savings breakdown (cache savings vs routing savings)
  • Complexity distribution (simple / moderate / complex)
  • Routing decisions (downgraded / kept / skipped)

Call log Every request with full detail — model, routing decision, complexity, latency, cost, and per-call savings.

Session selector Switch between individual sessions or view aggregated stats across all sessions under Overall.

Clear cache A button in the topbar wipes the cache without restarting the server.


Project structure

agentic-proxy/
├── main.py           # FastAPI app, routes
├── proxy.py          # Forwards requests to Anthropic, handles streaming
├── pipeline.py       # Orchestrates modules in order per request
├── config.py         # Loads and validates settings from .env
├── requirements.txt
├── .env.example
├── modules/
│   ├── cache.py      # SQLite cache with TTL and LRU eviction
│   ├── router.py     # Prompt classifier and model routing
│   ├── logger.py     # Persistent session log and stats
│   └── dashboard.py  # Live HTML dashboard
└── demo/
    ├── agent.py           # Standard demo agent (non-streaming)
    └── streaming_agent.py # Streaming demo agent

Running the demo agents

Make sure the proxy is running first, then in a separate terminal:

# Standard agent — 43 calls with a mix of simple, moderate, complex, and duplicate prompts
python demo/agent.py

# Streaming agent — demonstrates streaming support and cache replay
python demo/streaming_agent.py

Known limitations

  • Router accuracy — the classifier is good but not perfect. A misclassified prompt may be downgraded to a model that produces a lower quality response. You can set ROUTER_ENABLED=false in .env to disable routing if reliability is a concern.
  • Router overhead — every non-cached request incurs a small Haiku call to classify the prompt. This is visible in the dashboard as router latency. For very short-lived agents this overhead may outweigh the routing savings.
  • Single instance — the proxy is designed to run locally for a single developer. It is not designed for multi-user or production deployments.
  • In-memory session ID — the current session ID resets on server restart, though all logged data persists in SQLite.
  • Hard-Coded Prices — the current price calculation for tokens is hard-coded so it's possible it may become stale in the future but it likely won't have an extremely large difference.

Planned improvements

  • Semantic caching — cache near-identical prompts using embedding similarity, not just exact match
  • Context trimming — summarize and compress long conversation histories before forwarding
  • Router confidence threshold — only downgrade when the classifier is above a configurable confidence level
  • Docker support — single command setup with docker-compose up

License

MIT