Skip to content

fix(litellm): keep full multi-message context in input.value - #246

Open
jjcav84 wants to merge 1 commit into
future-agi:mainfrom
jjcav84:fix/litellm-input-value-context
Open

jjcav84 wants to merge 1 commit into
future-agi:mainfrom
jjcav84:fix/litellm-input-value-context

Conversation

@jjcav84

@jjcav84 jjcav84 commented Oct 7, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes the litellm sibling of #151 (flagged in #245). _instrument_func_type_completion wrote INPUT_VALUE three times:

  1. safe_json_dumps(kwargs) — the full request
  2. json.dumps(filtered_messages) — structured messages
  3. query = eval_input[0] — first message's text only ← the bug

Same mechanism as the openai handler: multi-turn conversations lost every message after the first in input.value. Removed the query overwrite and the now-unused query key from _process_messages (private helper; no other consumers). Image parts still surface as {{input_images.N}} placeholders with INPUT_IMAGES set.

Also repairs three stale assertions in the same test file — FI_SPAN_KIND → GEN_AI_SPAN_KIND and LLM_MODEL_NAME → GEN_AI_REQUEST_MODEL (attribute names from the OTEL GenAI migration that the test file never picked up). Without this the file was red regardless of any change, which would have hidden the regression tests.

Why?

Completes the fix for the bug family reported in #151 — the reporter scoped it to the openai handler, but litellm carried the identical overwrite.

How was it tested?

  • Unit tests added — TestInputValueMultiMessage in python/tests/test_framework_litellm.py: multi-message preservation through _instrument_func_type_completion, multimodal text+image placeholders, query key absence
  • pytest tests/test_framework_litellm.py — 43/43 pass (3 pre-existing FI_SPAN_KIND/LLM_MODEL_NAME failures repaired as part of this diff)

Checklist

  • Branch is off main
  • Conventional Commits (fix(litellm): …)
  • No TODOs or commented-out code
  • No secrets in the diff

Same defect as future-agi#151 (fixed for openai in future-agi#245): the completion
instrumentation wrote INPUT_VALUE three times, ending with
"query" = eval_input[0] — the first message's text only — after
already writing the joined text of every message. Multi-turn inputs
lost all but the first content piece.

Drop the query write and the now-unused "query" key from
_process_messages so the joined eval_input survives; image parts still
surface as {{input_images.N}} placeholders alongside INPUT_IMAGES.

Also repairs three stale attribute assertions in the litellm test file
that referenced pre-migration names (FI_SPAN_KIND -> GEN_AI_SPAN_KIND,
LLM_MODEL_NAME -> GEN_AI_REQUEST_MODEL) so the file actually runs green.

Generated with Devin
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant