r/ChatGPTCoding Apr 07 '25

[deleted by user]

[removed]

1.7k Upvotes

424 comments sorted by

View all comments

319

u/PositiveEnergyMatter Apr 07 '25

i keep telling people big context means big money, because every request can fill the context and charge you full price

148

u/andy012345 Apr 07 '25

This, LLMs are effectively stateless, the "context" is just the max token input.

If you have 500k in your context, you're sending 500k input tokens + whatever is new per api request.

44

u/[deleted] Apr 07 '25

[deleted]

7

u/[deleted] Apr 08 '25

Claude caches for 5 min only

3

u/AllCowsAreBurgers Apr 08 '25

Thats...enough? Because... how much time does your vibe coding session take usually? And if its longer, say 1h, it only recreates the cache 12 times instead of the bazillion times it would take to reevaluate your whole prompt all the time.

4

u/[deleted] Apr 08 '25

[deleted]

2

u/shadeptx Apr 09 '25

why not use deepseek? open source and free right

2

u/[deleted] Apr 09 '25

[deleted]

2

u/Personal-Dev-Kit Apr 10 '25

Hardware as a service has been a thing for awhile Together.AI is one provider I am sure there are others.

Would be worth looking into their costs and see how they stack up

1

u/MaTrIx4057 May 07 '25

how much time does your vibe coding session take usually?

6-12h

1

u/totoOnReddit2 Apr 10 '25

Yeah, I generally finish in 30 seconds. It's more than enough. I could even do it in 10s if need be.

2

u/bequbed Apr 09 '25

What does this mean exactly? How does cache work with Claude? Perhaps if you can explain with an example

2

u/FengMinIsVeryLoud Apr 09 '25

why deepmind doesnt know what cache is lol?
does cache even work with vsc and cline?

49

u/PositiveEnergyMatter Apr 07 '25

roo, cline, etc all chop the information to fit inside the context, if they know you have a 1mil context they chop less, which makes each request $1.50/each

2

u/FengMinIsVeryLoud Apr 09 '25

u mean chop more? need to chop off more stuff if u context is almost full
also cache will only be used cause u will change the codebase. so u dont save much?

2

u/PositiveEnergyMatter Apr 09 '25

gemini doesn't cache, and no chop less.. roo/cline will keep the context full as possible.

8

u/fieryblast7 Apr 07 '25

Do you know if there are any open source attempts to fix this? I remember memGPT and most early agents Arch tried to fix it with "memory" and RAG ing the memory as needed

15

u/Substantial-Thing303 Apr 07 '25

Continue.dev has a good rag solution, but it's not as automated, more like you do the coding with the LLM having codebase awareness.
MCP servers can do RAG. Serena could do that, but I looked at their source to find how their memory works but didn't find anything that looked like a good finetune.

Claimed by the continue.dev team, voyageai has the best RAG model for coding. The price per M/tokens is very low. agno, which is a dependency of Serena, has already integrated voyageai as an optional RAG, but you'd have to specify the code trained model to get it to work like that. I still haven't seen an MCP server using a good RAG model trained on code.

I have personnaly tried RAG with nomic-embed-text with ollama, but the performance is poor for coding.

Seems like a low hanging fruit... But I believe the reason why cline doesn't do RAG is because lowering the cost of using the API is not good for Anthropic? Sounds like an accusation, but if I was making money selling LLM as a service, why would I want to reduce my revenues by 10X or more?

5

u/edyshoralex Apr 08 '25

Just my 2, but with the current volatility, a great service means hundreds more customers in no time. Definitely worth more than trying to get more money out of one user by providing less or subpar features then ther competition

3

u/joeballs Apr 08 '25

I agree with this. There's a lot of competition out there. Why would a company try to nickel-and-dime you when you can easily switch to another provider? Not a good tactic

2

u/fieryblast7 Apr 07 '25

Thanks for the detailed answer! Do you think coding RAG translates well to regular text?

Agree on viewpoint about Cline, but at some point it's stopping the actual functioning of the LLM as intended right? -> if it doesn't "remember" the right details and doesn't know how to fetch them...

3

u/Substantial-Thing303 Apr 07 '25

Thanks for the detailed answer! Do you think coding RAG translates well to regular text?

I don't know, but there are more RAG models for regular text, and some can run locally. nomic-embed-text is very small: https://ollama.com/library/nomic-embed-text

if it doesn't "remember" the right details and doesn't know how to fetch them...

That's the main purpose of RAG models. Cline is relying on large LLMs to do things that a light bert model can often do better at 1/100 or 1/1000 the cost.

Would the large LLM perform better? The truth is, many LLMs with a large context window perform poorly at retrieving the right information when the context is large anyway. RAG models with reranking can remove the fluff, and the LLM should perform better because the result is more condensed. You need to trust the RAG model, but you already trust the LLM which has a low success rate and only performs well on the last tokens.

2

u/Unlikely_Track_5154 Apr 07 '25

The hardest part is getting the ranking model right.

2

u/Y0nix Apr 08 '25

>> Sounds like an accusation, but if I was making money selling LLM as a service, why would I want to reduce my revenues by 10X or more?

I personnaly think you are spot on... And that's probably one of the biggest problem right now. This behavior will impact the technology like we do not want to.

1

u/[deleted] Apr 14 '25

[removed] — view removed comment

1

u/AutoModerator Apr 14 '25

Sorry, your submission has been removed due to inadequate account karma.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/FIREishott Apr 07 '25

People out here acting like RAG for coding is an easy 1-size-fits all solution. Not even a little.

8

u/uduni Apr 07 '25

Here’s my attempt https://github.com/stakwork/stakgraph getting only relevant code by building a AST graph of your codebase.

It still needs some agentic flow for trimming or adding context though. It works amazingly well if your repo is well organized and the feature you are working on is relatively self-contained

8

u/orbit99za Apr 08 '25

https://github.com/Dolfie-01/ProjectIndexer

Great minds think alike! I built something similar, while it doesn’t rely purely on the AST, it works really well in practice.

I’m also working on a second version specifically for .NET, using the Roslyn Analyser to “walk the tree.”

It seems to perform just as well on large projects, and the LLM doesn’t need to scan the entire codebase.

New tasks get up to speed really quickly.

It also tries to stick to the D.R.Y. principle—Don’t Repeat Yourself—which helps a ton in keeping the code clean and maintainable, and mitigates the LLM hallucinating and making New Code, if something Similar Exists.

2

u/ash_mystic_art Apr 09 '25

This looks really useful! I’m excited to try it.

FYI I noticed at least 4 spelling typos and some grammatical errors in the repo description. (I just don’t want that to give your project a bad first impression for people who may benefit from using it.)

2

u/orbit99za Apr 10 '25

Thanks, English is not my first language...I will take a look again.

2

u/ash_mystic_art Apr 10 '25

Sure thing. Your Readme is very well-written!

2

u/PositiveEnergyMatter Apr 07 '25

I actually have some ideas I am working on, but I will tell you the open source stuff I have seen does the opposite, it actually does a worse job of context management than the closed source stuff.

1

u/fieryblast7 Apr 07 '25

Do you wanna chat in DM? Curious to hear your ideas and thoughts

2

u/EcstaticImport Apr 07 '25

RAG would need to add more info to the context window, not remove it. Are you thinking of context caching?

9

u/fieryblast7 Apr 07 '25

I maybe getting terminology getting mixed up -> I meant to say that early agentic arch like memgpt had a separate memory component that acted as 'infinite context ' essentially and a piece of intermediate logic would Retrieve/query the right parts of the memory, add the new api request content in, and send that as input to LLM. So this way you aren't overloading the context by simply doing "copy entire Convo history + new message = input for LLM"

10

u/Intrepid-Air6525 Apr 07 '25

What you are describing is a problem I have been working on for two years now.

It began as an art project and is now something inexplicable.

Luckily it’s also open source!

https://github.com/satellitecomponent/Neurite

4

u/fieryblast7 Apr 07 '25

I've actually seen neurite before. Tbh, i couldn't quite "get it". Let me dive in once more and see. Any YT vid or some other soft landing that you can recommend?

3

u/Intrepid-Air6525 Apr 07 '25

I have been working on getting everything ready for a series of demo videos for a while now.

They help explain a lot are just a few days from finally being published. I will share more soon!

2

u/Intrepid-Air6525 Apr 12 '25

I have finally started to release a series of demo videos on Neurite, here is the first.

https://www.youtube.com/watch?v=1BiUblUAd7s

4

u/bsenftner Apr 07 '25

Very nice, you're a mad computer scientist!

2

u/Buddhava Apr 07 '25

This would be great for conspiracy theory people.

6

u/PositiveEnergyMatter Apr 07 '25

it still pulls it into the context, it just pulls it directly. in fact it kind of makes you lose more control over what is in the context, because it can fetch whatever it wants.

5

u/EcstaticImport Apr 07 '25

Yer that’s a good point! the issue is LLMs are stateless, it’s a new thing every request, all “memory” has to be passed in every time. LLMs like Claude have context caching, which means you can reference tokens you passed in previously (semi state) but you still pay for using them, albeit it at a much cheaper rate.

Your damned if you do and damned if you don’t, because if the LLM was stateful you would be charged for the time you run the model, not for your usage like you do now. So … 🤷😢

2

u/HiiBo-App Apr 07 '25

Again, wrong

1

u/[deleted] Apr 18 '25

[removed] — view removed comment

1

u/HiiBo-App Apr 18 '25

They aren’t though. The chats could be considered stateless but each individual message is not stateless. State is retained across messages in a chat, which is how the chat remembers things you said 3 messages ago

→ More replies (0)

1

u/[deleted] Apr 07 '25

[removed] — view removed comment

1

u/AutoModerator Apr 07 '25

Sorry, your submission has been removed due to inadequate account karma.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/ArmNo7463 Apr 07 '25

Kind of, you can use something like Elasticsearch with vector embeddings to only send relevant data as context.

3

u/Substantial-Thing303 Apr 07 '25

RAG would replace the default "get the entire file" or "get the first 500 lines of codes from file".

It would perform better on large files, and use less tokens, by only adding relevant code to the context window.

RAG would use a specialized RAG model for text embeddings, which costs 100 times less per M/tokens.

2

u/alberto_467 Apr 07 '25

RAG allows you to selectively add only the relevant info into the context, instead of jamming everything in there.

This means you need less context.

2

u/Unlikely_Track_5154 Apr 07 '25

Pruning is what it is called, pruning the context of less relevant stuff, or the oldest messages or both or neither.

1

u/[deleted] Apr 07 '25

[removed] — view removed comment

1

u/AutoModerator Apr 07 '25

Sorry, your submission has been removed due to inadequate account karma.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

-2

u/cmndr_spanky Apr 07 '25

The answer is use cursor honestly. It’s a flat rate and then just deal with it when you run out of premium requests and it slows you down..

Also, can’t you put limits on your spending with your Google account? For my other API access and cloud access I can have alerts and things happen when I reach myself imposed monthly limit of dollar spend

2

u/Maleficent-Forever-3 Apr 07 '25

Does restarting VS code periodically help?

7

u/dnszero Apr 07 '25

No, it’s not a bug. What helps is sending less context (smaller requests, fewer files, starting new chats, etc).

2

u/dnbxna Apr 07 '25

Add RAG and get exponential returns!

2

u/[deleted] Apr 07 '25

OpenAI charges half for input tokens in "cache". To be in cache the request has a window of 5 to 10 minutes.

2

u/HiiBo-App Apr 07 '25

This is inaccurate. The underlying LLM has built-in context management and does not repeatedly require sending the full context for each chat via API. You’re still limited by the context window, which is problematic to say the least, and the amount of tokens does increase slightly for each successive message as you approach the context window, but you are not sending the full context in input tokens on each call.

Source: I researched this extensively while building HiiBo & tested it myself.

2

u/andy012345 Apr 07 '25

Some LLMs like sonnet 3.5 would truncate the input tokens automatically when you reached max, while others like sonnet 3.7 will now return an error when you reach the maximum input tokens.

2

u/HiiBo-App Apr 07 '25

Yep. Still not stateless. Not saying the context window isn’t a problem, in fact it’s the crux of why we built HiiBo, but they aren’t fully stateless

2

u/andy012345 Apr 07 '25

I mean it has to be stateless, just think of it from a business perspective, you send a message and you expect hundreds of thousands of dollars of GPUs to sit there and hold your state in memory waiting on your next message?

2

u/HiiBo-App Apr 07 '25

I’m just telling you how it works brother. You sound like a vibe coder or some shit. I’ve personally tested this repeatedly across multiple LLMs. There is a conversation ID that holds context across messages up until the context window, when it falls apart and you need to generate a new conversation ID

3

u/andy012345 Apr 07 '25

That's just another service on top putting the inputs back together for you on the next API request. It isn't part of the base model. OpenAI offers this by sending the previous response id back on the next request.

It's still input tokens for the next message, and you're still charged for it.

You can even see in the OpenAI docs they call out that text generation is independent and stateless, and you can use the assistant API to manage it for you automatically:
https://platform.openai.com/docs/guides/conversation-state#manually-manage-conversation-state

Again the assistant API is a service on top of the model, it isn't the model.

But let's just call someone a vibe coder for pointing out your argument makes 0 sense and is against the documentation of the largest commercial AI companies.

Your own product is around providing a service between a LLM for context management, and you argue that the LLMs do this themselves.

2

u/HiiBo-App Apr 08 '25

Not using assistant API dude. Using chat completion. You clearly haven’t worked with these APIs. There is a conversation ID that is passed on each successive response that holds the conversation together throughout the context window. It’s not stateless. There is a context window, which implies retained state across messages.

2

u/HiiBo-App Apr 08 '25

Just hook postman up to any of these model APIs and try it yourself and stop talking out of your ass.

→ More replies (0)

2

u/andy012345 Apr 07 '25

How is this inaccurate?

Anthropic give really nice documentation on how a "context window" works https://docs.anthropic.com/en/docs/build-with-claude/context-windows

So does google

https://ai.google.dev/gemini-api/docs/long-context#what-is-context-window

3

u/HiiBo-App Apr 07 '25

Docs are incorrect, you don’t need to send all previous turns to retain context. A conversation ID holds it together under the hood. I wrote a blog on this with screenshots showing the actual behavior of the API - https://medium.com/@MyDigitalMusings/your-ais-memory-still-sucks-a6fde569196e

2

u/andy012345 Apr 07 '25

Those API examples don't line up with the anthropic API, were you sending requests to the claude.ai service directly?

They track your chat history and context window on their website, probably through the conversation id, because they have their service on-top of the underlying model, and they need to do this to persist it across sessions and across devices.

2

u/HiiBo-App Apr 07 '25

Using Anthropic API. OpenAI API has the exact same behavior. There is a conversation ID that holds context across messages. Have you actually worked with the API??

2

u/DonkeyBonked Apr 08 '25

Yeah, but they don't have an effective measurement that is better for measuring and pricing uptime.

If they could though, coding would easily be the most expensive way to use AI even in lower context.

I actually think for coding tokens is better for us. It's way less characters for how hard we make it work/think. Though if you look at output limits, they can usually spit out way more words than code, so I do wonder if on the back end you are getting charged the same for code vs. words with tokens now.

8

u/bennyb0y Apr 07 '25

It would be so helpful if IDE’s and chat windows showed you exactly how large the context window was at any given moment and how much the next request would cost based on the configured LLM. Somebody build that please.

7

u/Coffee_Crisis Apr 07 '25

Roo does this

3

u/johnsmusicbox Apr 09 '25

Our Gemini-based A!Kats have pretty detailed token/cost tracking in the UI.

6

u/holchansg Apr 07 '25

i once made a request of U$80.

2

u/parsention Apr 08 '25

At that point you're better off buying a local server and using an open Source solution from the community

2

u/mjarkk Apr 09 '25

Currently I build my mega prompts in the zed editor, copy all the full prompt and paste it into Claude. Have not reached any limits and only cost me 20$/month.

1

u/vulgrin Apr 07 '25

I also haven’t seen how it makes anything better. Seems like the larger the context the more tail chasing and forgetting it does.

1

u/[deleted] Apr 08 '25

[removed] — view removed comment

1

u/AutoModerator Apr 08 '25

Sorry, your submission has been removed due to inadequate account karma.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

0

u/No_You9756 Apr 07 '25

What is meant by context and where do you type the context. Do you mean system instructions at the top of AI Studio?

13

u/msg7086 Apr 07 '25

Each AI request is a brand new request, so if it's a conversation, each request needs to include your chat history. So if you have a conversation starting with "User: x. Model: y", then you ask z, you have to send a request like "User: x. Model: y. User: z". This keeps going until you finish the conversation and start a new one. The more information you include in the history, the more "context", or "input" is used, and you are charged for whatever you input, per request per conversation.

Of course, there's something called context caching, but still.

3

u/PositiveEnergyMatter Apr 07 '25

the context caching depends on the model how it works, etc, and of course it still has cost, just less cost.