Skip to content

Conversation

@tofarr
Copy link
Collaborator

@tofarr tofarr commented Jan 2, 2026

Summary

After PR #1555, the discriminator field was removed from the generated JSON schema for discriminated unions. This caused the OpenAPI documentation tests (tests/agent_server/test_openapi_discriminator.py::test_action_schema_has_discriminator) to fail because Swagger UI needs the discriminator field to properly display discriminated unions instead of showing them as "object | object | object...".

This PR re-adds the discriminator field with the proper mapping in the __get_pydantic_json_schema__ method of DiscriminatedUnionMixin. The test expectation was also updated to include the discriminator field.

Changes:

  1. openhands-sdk/openhands/sdk/utils/models.py: Added code to build a discriminator mapping from the $ref schemas and include the discriminator field in the generated JSON schema
  2. tests/sdk/utils/test_discriminated_union.py: Updated the test_json_schema_expected test to verify the discriminator field is present

Checklist

  • If the PR is changing/adding functionality, are there tests to reflect this?
  • If there is an example, have you run the example to make sure that it works?
  • If there are instructions on how to run the code, have you followed the instructions and made sure that it works?
  • If the feature is significant enough to require documentation, is there a PR open on the OpenHands/docs repository with the same branch name?
  • Is the github CI passing?

@tofarr can click here to continue refining the PR


Agent Server images for this PR

GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python amd64, arm64 nikolaik/python-nodejs:python3.12-nodejs22 Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:472e283-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-472e283-python \
  ghcr.io/openhands/agent-server:472e283-python

All tags pushed for this build

ghcr.io/openhands/agent-server:472e283-golang-amd64
ghcr.io/openhands/agent-server:472e283-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:472e283-golang-arm64
ghcr.io/openhands/agent-server:472e283-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:472e283-java-amd64
ghcr.io/openhands/agent-server:472e283-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:472e283-java-arm64
ghcr.io/openhands/agent-server:472e283-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:472e283-python-amd64
ghcr.io/openhands/agent-server:472e283-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-amd64
ghcr.io/openhands/agent-server:472e283-python-arm64
ghcr.io/openhands/agent-server:472e283-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-arm64
ghcr.io/openhands/agent-server:472e283-golang
ghcr.io/openhands/agent-server:472e283-java
ghcr.io/openhands/agent-server:472e283-python

About Multi-Architecture Support

  • Each variant tag (e.g., 472e283-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 472e283-python-amd64) are also available if needed

After a recent change in PR #1555, the discriminator field was removed
from the generated JSON schema for discriminated unions. This caused
the OpenAPI documentation tests to fail since Swagger UI needs the
discriminator field to properly display discriminated unions.

This commit re-adds the discriminator field with the proper mapping
in the __get_pydantic_json_schema__ method. The test expectation was
also updated to include the discriminator field.

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/utils
   models.py1334466%42–43, 49, 51, 59–63, 86, 92, 134–136, 138, 202, 208–211, 213–214, 217, 220–224, 227–231, 233, 255, 268–269, 271–273, 275, 279, 281, 285
TOTAL14452684052% 

@tofarr tofarr marked this pull request as ready for review January 2, 2026 21:00
Copy link
Collaborator

@malhotra5 malhotra5 left a comment

Choose a reason for hiding this comment

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

LGTM!

@tofarr tofarr merged commit 31a233b into main Jan 2, 2026
21 checks passed
@tofarr tofarr deleted the fix/re-add-discriminator-field branch January 2, 2026 21:57
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.

4 participants