Skip to content

fix(openai-official): tolerate omitted output text annotations - #4633

Draft
breezeFur wants to merge 2 commits into
agentscope-ai:mainfrom
breezeFur:fix/4629-optional-output-text-annotations
Draft

breezeFur wants to merge 2 commits into
agentscope-ai:mainfrom
breezeFur:fix/4629-optional-output-text-annotations

Conversation

@breezeFur

Copy link
Copy Markdown

Summary

Fixes #4629.

OpenAI-compatible Responses endpoints such as Bailian may omit output_text.annotations. The OpenAI SDK defines this field as required, so calling ResponseOutputText.annotations() throws OpenAIInvalidDataException: annotations is not set even when usable text was returned.

This change reads the generated optional JSON-field accessor instead and treats an omitted annotation list as no citations. It does not suppress unrelated parse failures.

Changes

  • Use _annotations().asKnown().orElse(List.of()) in ResponsesHelper.extractCitations.
  • Add an SDK fixture representing a message with absent annotations.
  • Add non-streaming parser coverage.
  • Add streaming response.completed coverage after text deltas.

Reproduction

The two new tests fail on the original code with:

  • ResponsesResponseParserTest: OpenAIInvalidDataException: annotations is not set
  • ResponsesStreamingAssemblerTest: OpenAIOfficialModelException: annotations is not set

Both pass after the fix. Existing annotation mappings for URL, container-file, file, and file-path citations remain unchanged.

Validation

  • Red: 2 tests, 2 errors before the production change.
  • Focused green: 2 tests, 0 failures, 0 errors.
  • OpenAI Official module regression: 397 tests, 0 failures, 0 errors, 2 skipped. The skipped tests are pre-existing environment-gated provider tests.
  • spotless:apply, spotless:check, and git diff --check pass.

No dependency, public API, storage, or permission-policy changes. No live provider credentials were used.

This branch has not been deployed

No deployments
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]:百炼 Responses API 省略 output_text.annotations 时,已返回文本的调用仍因解析异常失败

1 participant