Skip to content

fix(apigee): send structured output schemas - #7920

Closed
Samecho wants to merge 1 commit into
google:mainfrom
Samecho:codex/apigee-structured-output
Closed

Samecho wants to merge 1 commit into
google:mainfrom
Samecho:codex/apigee-structured-output

Conversation

@Samecho

@Samecho Samecho commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

Closes #7864

Problem: On the Apigee Chat Completions path, output_schema is reduced to JSON object mode, and a raw response_json_schema is sent without the required name and schema wrapper.

Solution: Convert either schema input to a named JSON schema for the request. Keep already wrapped schemas and JSON-only mode working, and normalize schema types without changing the caller's input.

Testing Plan

Unit Tests:

  • Added and updated tests for model, GenAI, dictionary, generic, and already wrapped schemas, precedence, and JSON-only mode.
  • python -m pytest -p pytest_asyncio.plugin tests/unittests/models/test_completions_http_client.py tests/unittests/models/test_apigee_llm.py tests/unittests/models/test_llm_request.py -q --disable-warnings, with PYTHONPATH=src and plugin autoload disabled: 207 passed.
  • Project pre-commit checks and a focused mypy check passed locally.
  • Fork validation: pre-commit and baseline-compared mypy checks passed; the full tox suite ran on Python 3.11 through 3.14. Each version had 14 failures: one A2A test and 13 telemetry tests. The same test IDs and error messages were reproduced on unchanged upstream commit 95d8610ea3445ce9c6d0cf70aed1a0071ddc1e2f in each environment. The full suite therefore did not pass.

Manual End-to-End (E2E) Tests:

Used httpx.MockTransport with ApigeeLlm to inspect the requests and consume mock responses. The validation script covers six configurations with streaming on and off. It reported 12 simulated end-to-end requests passed. The same check passed against an installed wheel without the OpenAI SDK. No live model endpoint was used.

Checklist

  • I have read the contributing guide.
  • The changes were reviewed and tests were added for the fix.
  • The relevant unit tests and simulated end-to-end checks pass locally.

Additional context

PR #7626 separately updates the shared schema conversion helper for a workflow issue; this change does not depend on it.

AI assistance was used to implement and review this change.

copybara-service Bot pushed a commit that referenced this pull request Nov 5, 2026
Merge #7920

ApigeeLlm's Chat Completions path now sends `output_schema`
(`response_schema`) as a named `json_schema` response format instead of
`json_object`, and wraps a raw `response_json_schema` in the required
`{"name": ..., "schema": ...}` object. A `response_json_schema` that is
already wrapped is sent unchanged. An empty `response_json_schema` (`{}`) now
sends a `json_schema` format with an empty schema instead of falling back to
`json_object`.

Fixes #7864

PiperOrigin-RevId: 1014541065
@adk-bot

adk-bot commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Thank you @Samecho for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit e648b71.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Nov 5, 2026
@adk-bot adk-bot closed this Nov 5, 2026
1828703450qqcom-ux pushed a commit to 1828703450qqcom-ux/adk-python that referenced this pull request Nov 5, 2026
Merge google#7920

ApigeeLlm's Chat Completions path now sends `output_schema`
(`response_schema`) as a named `json_schema` response format instead of
`json_object`, and wraps a raw `response_json_schema` in the required
`{"name": ..., "schema": ...}` object. A `response_json_schema` that is
already wrapped is sent unchanged. An empty `response_json_schema` (`{}`) now
sends a `json_schema` format with an empty schema instead of falling back to
`json_object`.

Fixes google#7864

PiperOrigin-RevId: 1014541065
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ApigeeLlm Chat Completions drops output_schema and leaves json_schema unnamed

3 participants