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•1h 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.

TSMC in a tight spot: demand for high-end chips exceeds capacity by factor of 3

https://www.igorslab.de/en/tsmc-in-a-tight-spot-demand-for-high-end-chips-exceeds-capacities-by-a...
1•speckx•1m ago•0 comments

Show HN: I made an AI SEO tool for people who hate writing content

https://scribepilotai.com/
1•lastFitStanding•2m ago•0 comments

Big attack on NPM – Shai-Hulud 2.0

https://about.gitlab.com/blog/gitlab-discovers-widespread-npm-supply-chain-attack/
1•thomasfl•2m ago•0 comments

Cryptology firm cancels elections after losing encryption key

https://www.bbc.com/news/articles/c62vl05rz0ko
3•tagawa•3m ago•0 comments

Show HN: A terminal based voice over IP service

https://github.com/THE-TARS-PROJECT/tars-comm
1•cooper258•4m ago•0 comments

Show HN: Open-Source Email Verifier

https://github.com/yolodex-ai/email-verifier
2•marcushyett•4m ago•0 comments

My Experience Using Tinker

https://www.rajan.sh/tinker
1•gmays•4m ago•0 comments

Show HN: A browser tool that tracks your hands in real-time

https://webinterac.vercel.app/
2•warrowarro•7m ago•0 comments

Idempotency Keys

https://www.morling.dev/blog/on-idempotency-keys/
3•furkansahin•7m ago•0 comments

OpenTransit – A MassTransit Fork

1•Nakib•7m ago•0 comments

A Software Language That Vibe Coding Kids Deserve

https://github.com/MatthiasKainer/matthiashihic
2•mat_the_k•8m ago•0 comments

Show HN: I built a "Hot or Not" for startups to get the feedback YC doesn't give

https://yci.vercel.app/vote
1•alielroby•9m ago•0 comments

A Power Grid-Aware Website

https://fershad.com/grid-aware-site/
1•vintagedave•9m ago•1 comments

A We-Free December

https://hollisrobbinsanecdotal.substack.com/p/a-we-free-december
1•HR01•9m ago•0 comments

Show HN: Product Loop – Automated AI customer interviews

https://productloop.io
1•satssehgal•11m ago•0 comments

Show HN: Tree Dangler

https://www.jasonthorsness.com/34
1•jasonthorsness•11m ago•0 comments

Show HN: Smart Bill Splitter: Split bills in browser without login, ads, cookies

https://smartbillsplitter.com
1•truetotosse•11m ago•0 comments

Getting Started with Claude Code

https://realpython.com/courses/getting-started-claude-code/
1•meysamazad•12m ago•0 comments

Browserbench.ai is launched to evaluate browser runtimes for AI Agents

https://www.browserbench.ai
2•idanraman•13m ago•1 comments

Ruthless prioritization while the dog pees on the floor

https://longform.asmartbear.com/prioritization/
2•gk1•16m ago•0 comments

Alphabet (Googl) Gains on Report Meta to Use Its AI Chips

https://www.bloomberg.com/news/articles/2025-11-25/alphabet-gains-on-report-that-meta-will-use-it...
1•mgh2•17m ago•0 comments

Ageing Populations Will Lead to Lower Living Standards, Warns Study

https://www.ft.com/content/3a675f7f-ff46-4b8d-9744-08dfed18d23a
2•skx001•17m ago•2 comments

Show HN: A seeded, deterministic chaos simulation runtime for async Rust

https://github.com/ZA1815/fracture
1•Crroak•18m ago•1 comments

The State of AI: don't share your secrets with a chatbot

https://www.ft.com/content/9cdd07b0-567e-4715-9ebd-435b1d685e4b
1•1vuio0pswjnm7•18m ago•0 comments

Questioning an Interface: From Parquet to Vortex

https://www.polarsignals.com/blog/posts/2025/11/25/interface-parquet-vortex
2•asubiotto•19m ago•0 comments

Show HN: Fractalbits – S3 compatibe store,1M iops p99~5ms,using Rust and Zig

https://github.com/fractalbits-labs/fractalbits-main
5•thomas_fa•20m ago•0 comments

Ask HN: Is There a Market for a "Phone-Only" VA Proxy?

2•ibogunov•21m ago•1 comments

Literary Philosophy and Philosophical Literature

https://countercraft.substack.com/p/literary-philosophy-and-philosophical
2•crescit_eundo•21m ago•0 comments

What Happens to Kids' Brains After Hours Staring at Screens?

https://studyfinds.org/kids-brains-after-thousands-of-hours-staring-at-screens/
1•Noaidi•22m ago•0 comments

Optique 0.7.0: Smarter error messages and validation library integrations

https://hackers.pub/@hongminhee/2025/optique-070
1•todsacerdoti•23m ago•0 comments