Long context items are skipped instead of truncated when max token limit is reached
Found this while testing: #3586160 **Description:** When a selected AI Context item is longer than the configured max token budget, the renderer may exclude the item entirely instead of truncating its guidance content to fit. This happens because token limiting is applied before the item metadata wrapper is added, and the full rendered block can still exceed the budget after wrapping. Expected behavior: oversized context item content should be truncated when possible so the item can still be injected within the token limit. The item should only be skipped if its required metadata wrapper cannot fit within the remaining token budget. **Steps to reproduce:** - Set up ai_context per the project page including adding ai_agents_debugger (D11 install is fine) - Add 1 context item and make it global (scope settings) - Make sure the context item has minimal content (just a few words) - Update the general settings and set max tokens to 100 - Clear cache - Check the taxonomy agent settings and it should show up as global - Use the agents debugger and add a prompt "Show all vocabularies" - Check the input and the global context should show up - Update the context item so it has many paragraphs of text (300+ words) - Clear cache - Use the debugger again (reload it) and use a slightly different prompt to avoid LLM caching - Check the input and the context will not be injected at all - Expected: it should be injected based on the token limit so it will be truncated
issue