frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Built an AI Agent from Scratch to Measure Token Costs. Here's What I Found

1•harsharanga•2mo ago
I’ve been measuring token costs in multi-tool AI agents. To understand where tokens actually go, I built an agent framework from scratch with no libraries or abstractions. Frameworks hide cost mechanics; I needed bare-metal visibility.

The goal was simple: measure how token usage grows as you introduce more tools and more conversation turns.

THE SETUP 6 tools (metrics, alerts, topology, neighbors, etc.) gpt-4o-mini Token instrumentation across four phases No caching, no prompt tricks, no compression

THE FOUR PHASES Phase 1: Single tool. One LLM call, one tool schema. Baseline. Phase 2: Six tools. Same query, but the agent exposes six tools. Token growth comes entirely from additional tool definitions. Phase 3: Chained calls. Three sequential tool calls, each feeding into the next. No conversation history yet. Phase 4: Multi-turn conversation. Three turns with full replay of every prior message, tool request, and tool response.

RESULTS Phase 1: 590 tokens Phase 2: 1,250 tokens (2.1x increase) Phase 3: 4,500 tokens (7.6x increase) Phase 4: 7,166 tokens (12.1x increase)

Two non-obvious findings stood out. First, adding 5 more tools roughly doubled token cost. Second, adding two more conversation turns tripled it. Conversation depth drove more token growth than tool count.

WHY THIS HAPPENS LLMs are stateless. Every call must replay full context: tool definitions, conversation history, and previous tool outputs. Adding tools increases context size linearly. Adding conversation turns increases it multiplicatively because each turn resends everything that came before it.

IMPLICATIONS Real systems often have dozens of tools across domains, multi-turn conversations during incidents, and power users issuing many queries per day. Token costs don’t scale linearly. They compound. This isn’t a prompt-engineering issue. It’s an architectural issue. If you get the architecture wrong, you pay for it on every query.

NEXT STEPS I’m measuring the effects of parallel tool execution, conversation history truncation, semantic routing, structured output constraints, and OpenAI’s new prompt caching (which claims large cost reductions on cache hits). Each of these targets a different part of the token-growth pattern.

Happy to share those results as I gather them. Curious how others are managing token expansion in multi-turn, multi-tool agents.

Tech Edge: A Living Playbook for America's Technology Long Game

https://csis-website-prod.s3.amazonaws.com/s3fs-public/2026-01/260120_EST_Tech_Edge_0.pdf?Version...
1•hunglee2•3m ago•0 comments

Golden Cross vs. Death Cross: Crypto Trading Guide

https://chartscout.io/golden-cross-vs-death-cross-crypto-trading-guide
1•chartscout•5m ago•0 comments

Hoot: Scheme on WebAssembly

https://www.spritely.institute/hoot/
2•AlexeyBrin•8m ago•0 comments

What the longevity experts don't tell you

https://machielreyneke.com/blog/longevity-lessons/
1•machielrey•9m ago•1 comments

Monzo wrongly denied refunds to fraud and scam victims

https://www.theguardian.com/money/2026/feb/07/monzo-natwest-hsbc-refunds-fraud-scam-fos-ombudsman
2•tablets•14m ago•0 comments

They were drawn to Korea with dreams of K-pop stardom – but then let down

https://www.bbc.com/news/articles/cvgnq9rwyqno
2•breve•16m ago•0 comments

Show HN: AI-Powered Merchant Intelligence

https://nodee.co
1•jjkirsch•19m ago•0 comments

Bash parallel tasks and error handling

https://github.com/themattrix/bash-concurrent
2•pastage•19m ago•0 comments

Let's compile Quake like it's 1997

https://fabiensanglard.net/compile_like_1997/index.html
2•billiob•20m ago•0 comments

Reverse Engineering Medium.com's Editor: How Copy, Paste, and Images Work

https://app.writtte.com/read/gP0H6W5
2•birdculture•25m ago•0 comments

Go 1.22, SQLite, and Next.js: The "Boring" Back End

https://mohammedeabdelaziz.github.io/articles/go-next-pt-2
1•mohammede•31m ago•0 comments

Laibach the Whistleblowers [video]

https://www.youtube.com/watch?v=c6Mx2mxpaCY
1•KnuthIsGod•32m ago•1 comments

Slop News - HN front page right now as AI slop

https://slop-news.pages.dev/slop-news
1•keepamovin•37m ago•1 comments

Economists vs. Technologists on AI

https://ideasindevelopment.substack.com/p/economists-vs-technologists-on-ai
1•econlmics•39m ago•0 comments

Life at the Edge

https://asadk.com/p/edge
3•tosh•45m ago•0 comments

RISC-V Vector Primer

https://github.com/simplex-micro/riscv-vector-primer/blob/main/index.md
4•oxxoxoxooo•48m ago•1 comments

Show HN: Invoxo – Invoicing with automatic EU VAT for cross-border services

2•InvoxoEU•49m ago•0 comments

A Tale of Two Standards, POSIX and Win32 (2005)

https://www.samba.org/samba/news/articles/low_point/tale_two_stds_os2.html
3•goranmoomin•53m ago•0 comments

Ask HN: Is the Downfall of SaaS Started?

3•throwaw12•54m ago•0 comments

Flirt: The Native Backend

https://blog.buenzli.dev/flirt-native-backend/
2•senekor•55m ago•0 comments

OpenAI's Latest Platform Targets Enterprise Customers

https://aibusiness.com/agentic-ai/openai-s-latest-platform-targets-enterprise-customers
1•myk-e•58m ago•0 comments

Goldman Sachs taps Anthropic's Claude to automate accounting, compliance roles

https://www.cnbc.com/2026/02/06/anthropic-goldman-sachs-ai-model-accounting.html
4•myk-e•1h ago•5 comments

Ai.com bought by Crypto.com founder for $70M in biggest-ever website name deal

https://www.ft.com/content/83488628-8dfd-4060-a7b0-71b1bb012785
1•1vuio0pswjnm7•1h ago•1 comments

Big Tech's AI Push Is Costing More Than the Moon Landing

https://www.wsj.com/tech/ai/ai-spending-tech-companies-compared-02b90046
5•1vuio0pswjnm7•1h ago•0 comments

The AI boom is causing shortages everywhere else

https://www.washingtonpost.com/technology/2026/02/07/ai-spending-economy-shortages/
3•1vuio0pswjnm7•1h ago•0 comments

Suno, AI Music, and the Bad Future [video]

https://www.youtube.com/watch?v=U8dcFhF0Dlk
1•askl•1h ago•2 comments

Ask HN: How are researchers using AlphaFold in 2026?

1•jocho12•1h ago•0 comments

Running the "Reflections on Trusting Trust" Compiler

https://spawn-queue.acm.org/doi/10.1145/3786614
1•devooops•1h ago•0 comments

Watermark API – $0.01/image, 10x cheaper than Cloudinary

https://api-production-caa8.up.railway.app/docs
2•lembergs•1h ago•2 comments

Now send your marketing campaigns directly from ChatGPT

https://www.mail-o-mail.com/
1•avallark•1h ago•1 comments