Skip to content

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

Description

@rite7sh

Summary

SpanAttributes.INPUT_VALUE is overwritten multiple times in _process_input_data, resulting in loss of context for multi-message inputs.

In the current implementation, the final assignment reduces the input to only the first message, which breaks trace correctness for conversational inputs.


Affected Code

In _span_io_handler.py:

if eval_input:
    eval_input_str = " \n ".join(map(str, eval_input))
    span.set_attribute(SpanAttributes.INPUT_VALUE, eval_input_str)

if eval_input and len(eval_input) > 0:
    span.set_attribute(SpanAttributes.INPUT_VALUE, eval_input[0])

Activity

  1. pmady commented on May 1, 2026

    @pmady
    Contributor

    ran into this while reviewing the codebase for #164. the issue is in _span_io_handler.py lines 55-63 -- INPUT_VALUE gets set three times in sequence:

    1. line 55: full json of input_content (correct, has all messages)
    2. line 61: joined eval_input strings (loses structure but keeps all messages)
    3. line 63: eval_input[0] only (drops everything except the first message)

    line 63 always wins and you lose multi-turn context. looks like lines 62-63 are redundant with the block at 59-61 anyway (both check if eval_input). removing 62-63 should fix it without changing behavior for the eval path.

    happy to open a PR if that approach makes sense.

  2. gh-raju commented on Jul 26, 2026

    @gh-raju

    Thanks @pmady for the precise diagnosis agreed. In _span_io_handler.py, the eval_input[0] assignment (around line 63) overwrites the full multi-message value set earlier at line 55, so everything after the first message is dropped, and lines 62–63 are redundant with the if eval_input block just above.

    If you are not already working on it, I would like to pick this up.

    Plan:

    • Remove the redundant eval_input[0] assignment so the structured/full-context value set earlier is preserved (matches your analysis), keeping the eval path behavior unchanged.
    • Add a regression test that asserts INPUT_VALUE retains all messages for a multi-turn input — the exact case that's silently lost today.

    Could a maintainer assign this to me? Happy to step back if @pmady wants to carry their own fix.

  3. pmady commented on Jul 26, 2026

    @pmady
    Contributor

    Sure go for it, @gh-raju , happy that the diagnosis was helpful. This is precisely what I had in mind, remove the unnecessary assignment of eval_input[0] and include the multiple message regression test. Looking forward to reviewing the pull request.

  4. gh-raju commented on Jul 27, 2026

    @gh-raju

    Working on it, @pmady I will open a PR against dev shortly with the fix and a multi message regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions