Skip to content

fix(dashscope): preserve message outputs without tool calls - #185

Merged
sipercai merged 1 commit into
alibaba:mainfrom
sipercai:fix/dashscope-output-messages
May 14, 2026
Merged

fix(dashscope): preserve message outputs without tool calls#185
sipercai merged 1 commit into
alibaba:mainfrom
sipercai:fix/dashscope-output-messages

Conversation

@sipercai

@sipercai sipercai commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR fixes DashScope message-format response parsing when the assistant returns
plain text without a tool_calls field.

DashScope response entities are dict-like objects whose attribute access can raise
KeyError for missing optional fields. The previous parser used
getattr(message, "tool_calls", None), so a result_format="message" text response
without tool_calls could discard the already parsed message.content and omit
gen_ai.output.messages.

This change adds safe field access for DashScope response objects, preserves
assistant text output in this response shape, adds a VCR regression cassette, and
updates the DashScope changelog.

Fixes # (N/A)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • tox -e precommit
  • OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_ONLY tox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-dashscope-latest -- instrumentation-loongsuite/loongsuite-instrumentation-dashscope/tests/test_generation.py::test_generation_call_message_result_without_tool_calls_content_capture -q

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@sipercai
sipercai force-pushed the fix/dashscope-output-messages branch from db4895d to 40e3711 Compare May 8, 2026 11:38
@ralf0131
ralf0131 requested a review from Copilot May 8, 2026 11:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR fixes DashScope message-format response parsing so assistant text output is preserved when the response omits the optional tool_calls field.

Changes:

  • Add a safe field accessor to avoid KeyError from DashScope’s dict-like response objects and use it throughout generation parsing.
  • Add a VCR-based regression test (and cassette) covering result_format="message" responses without tool_calls.
  • Update DashScope instrumentation changelog and adjust dependency / tooling configs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
instrumentation-loongsuite/loongsuite-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/utils/generation.py Introduces _safe_get and applies it across response parsing to preserve message output without tool_calls.
instrumentation-loongsuite/loongsuite-instrumentation-dashscope/tests/test_generation.py Adds a regression test validating gen_ai.output.messages is emitted for message-format responses without tool_calls.
instrumentation-loongsuite/loongsuite-instrumentation-dashscope/tests/cassettes/test_generation_call_message_result_without_tool_calls_content_capture.yaml Adds recorded HTTP interaction for the new regression test.
instrumentation-loongsuite/loongsuite-instrumentation-dashscope/pyproject.toml Removes version constraints for opentelemetry-util-genai.
instrumentation-loongsuite/loongsuite-instrumentation-dashscope/CHANGELOG.md Adds an Unreleased “Fixed” entry documenting the parsing fix.
.pre-commit-config.yaml Excludes _template/ from the rstcheck hook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sipercai
sipercai force-pushed the fix/dashscope-output-messages branch 2 times, most recently from 34fd69e to b85e025 Compare May 9, 2026 04:57
@sipercai
sipercai force-pushed the fix/dashscope-output-messages branch from b85e025 to f25f64a Compare May 14, 2026 11:20
@sipercai
sipercai merged commit 49f501b into alibaba:main May 14, 2026
122 checks passed
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.

5 participants