fix(items): coerce None refusal to empty string in extract_last_content#3747
Closed
comp wants to merge 1 commit into
Closed
fix(items): coerce None refusal to empty string in extract_last_content#3747comp wants to merge 1 commit into
comp wants to merge 1 commit into
Conversation
Member
|
Can you share the repro steps of this issue? Otherwise, we'll close it for the same reason with #3427 (comment) |
Contributor
Author
|
Thanks @seratch — you're right, and I couldn't find a real path either. Tracing every
So |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ItemHelpers.extract_last_contentis annotated-> str, and its text-content branch already coerces aNonetextto""— with a comment noting that provider gateways (e.g. LiteLLM) andmodel_constructstreaming paths can surfaceNoneeven though the schema types the field asstr. The refusal branch had the identical exposure but returnedlast_content.refusalbare, so for a refusal message whoserefusalisNone,extract_last_contentreturnedNone, violating its own-> strcontract.This coerces the refusal branch the same way, matching both the text branch above it and the sibling
extract_refusal(which already usesrefusal or "").Test plan
Added
test_extract_last_content_of_refusal_message_with_null_refusal, which reproduces theNone-refusal case viamodel_construct(the documented provider-gateway path). Change-relevant checks:uv run ruff format --check src/agents/items.py tests/test_items_helpers.py— passuv run ruff check src/agents/items.py tests/test_items_helpers.py— passuv run mypy src/agents/items.py—Success: no issues founduv run pytest tests/test_items_helpers.py— 35 passedI also ran the full
.agents/skills/code-change-verification/scripts/run.sh:make formatandmake lintpass.make typecheckfails only on ~22 pre-existing errors in files unrelated to this change (e.g.tests/sandbox/test_unix_local.pyreferencessignal.SIGQUIT, unavailable on Windows; plus tool-version/stub issues inextensions/memory/redis_session.py,sandbox/util/tar_utils.py,models/openai_responses.py, etc.). I verified there are no typecheck errors in the changed files (items.py,test_items_helpers.py). This is a local Windows/tool-version environment issue, not a regression from this PR, so I've left the "all steps pass" box unchecked.Issue number
N/A
Checks
.agents/skills/code-change-verification/scripts/run.sh(format + lint pass; typecheck blocked only by pre-existing, unrelated Windows errors — none in the changed files; see test plan)/reviewbefore submitting this PR — N/A