Skip to content

fix(attempt): omit reverse_translation_outputs from report when not used#1826

Open
nuthalapativarun wants to merge 1 commit into
NVIDIA:mainfrom
nuthalapativarun:fix/1201-reverse-translation-outputs
Open

fix(attempt): omit reverse_translation_outputs from report when not used#1826
nuthalapativarun wants to merge 1 commit into
NVIDIA:mainfrom
nuthalapativarun:fix/1201-reverse-translation-outputs

Conversation

@nuthalapativarun
Copy link
Copy Markdown

Fixes #1201

Problem

Attempt.as_dict() unconditionally included a reverse_translation_outputs key in every serialized attempt entry in report.jsonl, even when no translation was configured. This polluted reports with a spurious empty list (or in some cases actual output values) for all non-translation runs.

Fix

The key is now only emitted when self.reverse_translation_outputs is non-empty, using conditional dict unpacking:

**(
    {"reverse_translation_outputs": [...]}
    if self.reverse_translation_outputs
    else {}
),

This keeps reports clean for the common non-translation case, while preserving full output for translation runs where the field is actually populated.

Verification

  • python -m pytest tests/test_attempt.py -x -q — all 23 tests pass
  • Updated test_json_serialize to not expect the key in non-translation serialization

Copy link
Copy Markdown
Collaborator

@jmartin-tech jmartin-tech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A serialized object should not omit a key that was empty. The issue this references did not fully describe what was considered to be the bug, the example entry was meant to offer more context. When no translation is active during a run the reverse_translation_outputs should always be empty, in the example in the issue it was found to have been set when it was not expected to.

Note that #1254 may have actually address this issue, the bug needs to be reproduced to determine if the run logic is still placing values in reverse_translation_outputs when no translation is being used in the run.

…chema

Fixes NVIDIA#1201

The original issue reported `reverse_translation_outputs` appearing with
unexpected values when no translation was active. Investigation confirms
that `_postprocess_attempt()` already gates population behind
`this_attempt.lang != self.lang`, so the field is correctly empty (`[]`)
in non-translation runs.

`as_dict()` always serializes the key (even when empty) to give consumers
a stable schema. These two tests make that contract explicit:

- `test_asdict_always_includes_reverse_translation_outputs`: the key is
  always present in the serialized dict, never absent.
- `test_asdict_reverse_translation_outputs_empty_when_no_translation`:
  the value is `[]` when no translation is configured.

Signed-off-by: Varun Nuthalapati <nuthalapativarun@gmail.com>
@nuthalapativarun nuthalapativarun force-pushed the fix/1201-reverse-translation-outputs branch from ee32a39 to 5e53b65 Compare June 2, 2026 15:18
@nuthalapativarun
Copy link
Copy Markdown
Author

Thanks for the review, @jmartin-tech.

After investigating:

  1. Schema stability: I've reverted the as_dict() change — reverse_translation_outputs is now always serialized (even as []), matching the original behavior. You're right that omitting a key breaks consumers relying on a stable schema.

  2. Underlying bug already fixed: The actual issue (values appearing when no translation is active) is already addressed: _postprocess_attempt() only populates reverse_translation_outputs when this_attempt.lang != self.lang, so the field stays empty in non-translation runs. This gate was introduced in Feature: conversation support #1254.

  3. What this PR now does: Instead of a code change, I've added two regression tests that make the intended contract explicit:

    • test_asdict_always_includes_reverse_translation_outputs: the key is always present in as_dict() output
    • test_asdict_reverse_translation_outputs_empty_when_no_translation: the value is [] when no translation is configured

Happy to close this in favor of a documentation note if you'd prefer, or adjust the test coverage in any direction.

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.

bug: reverse translation outputs in report.jsonl when no translation used

2 participants