fix: tolerate null response content joins#5298
fix: tolerate null response content joins#5298giulio-leone wants to merge 2 commits intollamastack:mainfrom
Conversation
|
This pull request has merge conflicts that must be resolved before it can be merged. @giulio-leone please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork |
|
This PR is out of date, please rebase. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
27375df to
7c177ad
Compare
|
@cdoern rebased this PR onto current Notes:
This should clear the out-of-date/conflict blocker from the earlier review. |
|
@cdoern quick follow-up: the earlier out-of-date/rebase blocker should now be cleared on the current head. The PR was rebased onto current If you have a moment, I would appreciate a fresh look to confirm there are no remaining blockers. Thanks! |
Summary
TextContentItem(text=None)when flattening interleaved contentNoneentries when joiningChatCompletionResult.content_textWhy
Current
mainstill reproduces the null-content crash from #4996:interleaved_content_as_str([TextContentItem.model_construct(text=None)])ChatCompletionResult(..., content=[None, "tool result"], ...).content_textBoth currently raise:
The earlier closed attempt in #5029 fixed the same underlying issue, but it targeted the older
meta_referenceresponses layout. After the currentbuiltin/responsesrefactor, the same bug is still present onmainunder the new path.Validation
.venv/bin/ruff check src/llama_stack/providers/utils/inference/prompt_adapter.py src/llama_stack/providers/inline/agents/builtin/responses/types.py tests/unit/providers/utils/inference/test_prompt_adapter_none_safety.py tests/unit/providers/inline/agents/builtin/responses/test_types.py.venv/bin/python -m pytest tests/unit/providers/utils/inference/test_prompt_adapter_none_safety.py tests/unit/providers/inline/agents/builtin/responses/test_types.py tests/unit/providers/inline/agents/builtin/responses/test_streaming.py -qorigin/mainvs this branch showingmainstill raisesTypeErrorin both paths while this branch returns""/"tool result"Closes #4996
Supersedes #5029