Skip to content

fix(openai): keep full multi-message context in input.value - #245

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

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

Conversation

@jjcav84

@jjcav84 jjcav84 commented Oct 7, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes INPUT_VALUE silently dropping all but the first message for conversational inputs (#151).

_process_input_data wrote INPUT_VALUE three times:

  1. JSON dump of the filtered structured messages
  2. Joined text of every message's content (eval_input)
  3. eval_input[0] — the first message's text only ← the bug

Write 3 is dead logic (its if is implied by write 2's) and destroyed the multi-message context write 2 produced. Removed so the joined string survives; image parts still surface as {{input_images.N}} placeholders with INPUT_IMAGES set alongside.

process([{"role": "user", "content": "a"},
         {"role": "assistant", "content": "b"},
         {"role": "user", "content": "c"}], span)
# before: INPUT_VALUE == "a"
# after:  INPUT_VALUE == "a \n b \n c"

Sibling note for reviewers: traceai_litellm carries the identical pattern — _process_messages returns query = eval_input[0] and _instrument_func_type_completion writes it last, overwriting the joined eval_input. Same first-message-only loss. I kept this PR scoped to the reported path; happy to follow up there if you'd like it fixed identically.

Why?

Closes #151 — trace correctness for multi-message inputs: every message after the first was invisible in input.value.

How was it tested?

  • Unit tests added — TestProcessInputData in python/tests/test_framework_openai.py: multi-message preservation, multimodal text+image placeholders, single message, non-list input
  • pytest tests/test_framework_openai.py::TestProcessInputData — 4/4 pass
  • Pre-existing suite failures unchanged: TestOpenAIFramework fails identically on clean main — its httpx.Client.send mock no longer intercepts under openai 3.x (real API call → 401); unrelated to this diff

Checklist

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

_process_input_data ended with a redundant third write that reduced
INPUT_VALUE to eval_input[0] — the first message's text only — after
already writing the joined text of every message. Multi-turn and
multi-part inputs lost all but the first content piece (future-agi#151).

Drop the overwrite so the joined eval_input string survives; image
parts still surface as {{input_images.N}} placeholders alongside
INPUT_IMAGES.

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.

INPUT_VALUE overwritten in _process_input_data leading to loss of multi-message context

1 participant