LLM Context Length Exceeded in Node.js: Count, Trim, Recover

LLM context length exceeded errors in Node.js: detect OpenAI and Claude overflows, count tokens correctly, and trim history without breaking tool calls.

LLM context length exceeded errors in Node.js: detect OpenAI and Claude overflows, count tokens correctly, and trim history without breaking tool calls.