Repository navigation
Add detail="compact" and a food_id filter to get_food_log - #93
Merged
Merged
Conversation
A busy day in full detail is around 170,000 characters (every entry carries its food's whole nutrient profile), which exceeds the output limit of some clients and fails the call. detail="compact" (default stays "full") replaces each diary entry with a small object: entry_id, type, name, food_id, measure_id, grams, servings, time, order, diary_group, and kcal/protein/carbs/fat/sodium. entry_id is the ID remove_food_entry takes for any entry type (servingId, noteId, exerciseId or biometricId), and notes also carry their text. energy_summary and nutrition_summary are unchanged. food_id narrows the entries to one food, in either detail mode. It filters before the foods are looked up, so only the kept entries are enriched. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Closed
Contributor
|
+1 from real use with ChatGPT. On a day with about eight entries, |
rwestergren
approved these changes
Nov 23, 2026
Contributor
Author
|
Thanks for merging this, and so quickly. |
Owner
|
No problem! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A busy diary day from
get_food_logis about 170,000 characters, because every entry carries its food's whole nutrient profile. That is over the output limit of some clients, so the call fails. This adds an opt-in compact mode and afood_idfilter.What it does
get_food_logtakesdetail="compact". The default stays"full", so existing callers see no change.entry_id,type,name,food_id,measure_id,grams,servings,time,order,diary_group({group, name}, as in full mode), andkcal,protein_g,carbs_g,fat_g,sodium_mg. Values that can't be derived arenull, andgramsis passed through as is.entry_idis the IDremove_food_entrytakes for that entry, whatever its type (servingId,noteId,exerciseIdorbiometricId). Notes also carry theirtext. A compact log can therefore be used to find and remove any entry.food_idnarrows the diary list to one food, in either detail mode. It filters before foods are looked up, so only the kept entries are enriched.energy_summaryandnutrition_summaryare unchanged and still describe the whole day. Both options apply to each day whendays > 1.Not changed: meal groups. Compact uses the
diary_grouplabel thatlabel_diary_groupsalready adds, so it follows whatever the account layout is.Tests: new
tests/test_food_log_compact.py(full stays the default, compact fields, notes and non-food entry IDs, size reduction,food_id, invaliddetail, multi-day). Ruff,ruff format --checkand the full suite pass on top of currentmain.🤖 Generated with Claude Code