Repository navigation
Conversation
tests/unit/interactions/test_openapi_compliance.py compares the SDK to the live
spec at ai.google.dev, and Google has reshaped that spec. Four tests now fail on
every PR: the request schema CreateModelInteractionParams no longer exists
(KeyError), and the item path parameter was renamed from {id} to
{interactionsId}, so GET and DELETE /interactions/{id} were not found.
The create body is now read off POST /interactions, where the spec wraps an
agent variant and a model variant in a oneOf, and the model one is picked by
carrying `model`. The GET and DELETE lookups match `/interactions/{param}` by
shape, since the parameter's name is cosmetic. Each helper raises if the
endpoint disappears, so real drift still fails the test.
`input` is no longer listed as required on the model variant, so the test now
asserts it is a property. `model` is still asserted required.
Signed-off-by: Ankit Jha <ankit.jha@tradomate.one>
|
| # `model` is required; `input` is optional now that a call can resume via previous_interaction_id | ||
| assert "model" in schema["required"] | ||
| assert "input" in schema["required"] | ||
| assert "input" in schema["properties"] |
| return spec_dict["components"]["schemas"][ref.split("/")[-1]] | ||
|
|
||
|
|
||
| def _create_request_schema(spec_dict: dict[str, Any]) -> dict[str, Any]: |
There was a problem hiding this comment.
New helpers use coarse types This signature and the other new helpers use
Any or dict[str, Any]. The repository requires strongly typed parameters in new code; address these before merging
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| schema = _create_request_schema(spec_dict) | ||
|
|
||
| # Required fields per spec | ||
| # `model` is required; `input` is optional now that a call can resume via previous_interaction_id |
There was a problem hiding this comment.
Explanatory comment violates guide This comment restates the assertion’s intent. The repository permits comments only for complex logic, tool input, or TODOs; remove it before merging
| # `model` is required; `input` is optional now that a call can resume via previous_interaction_id |
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| for path, methods in spec_dict["paths"].items(): | ||
| if path.endswith("/interactions") and "post" in methods: | ||
| body = methods["post"]["requestBody"]["content"]["application/json"]["schema"] | ||
| candidates = body.get("oneOf") or [body] |
There was a problem hiding this comment.
New helpers lack offline tests Both new helpers run only through a live-spec fixture that skips when loading fails. The repository requires in-process unit tests; cover their behavior offline before merging
Context Used: AGENTS.md (source)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Closing this as superseded: #43958 (merged yesterday) repairs the same four Interactions compliance tests the same way, by reading the create body from |
TLDR
Problem this solves:
How it solves it:
POST /interactions, not a schema nameGETandDELETE/interactions/{param}by shape, not by{id}User Flow
Before: a contributor opens an unrelated PR and
misc / Run testsgoes red on tests they never touchedmainthat does not touch the Interactions codemisc / Run testsrunstests/unit/interactions/test_openapi_compliance.pyKeyError: 'CreateModelInteractionParams'orGET /interactions/{id} endpoint not foundAfter: the same PR gets a green check, and the tests still fail if the spec loses an endpoint
misc / Run testsruns the same filePre-Submission checklist
uv run pytest tests/unit/<your_test_file>.py -vScreenshots / Proof of Fix
The suite compares the SDK to Google's live spec at
https://ai.google.dev/static/api/interactions.openapi.json, so a plainpytestrun against it is the end-to-end proof. There is no LLM call in this change. I ran it in a minimal environment (pytest,httpx,openapi-core) with--noconftest, because the repoconftest.pyimportsboto3.Before (684a1ed)
pytest tests/unit/interactions/test_openapi_compliance.py -q4 failed, 9 passedTestRequestCompliance::test_create_model_interaction_request_schemaTestRequestCompliance::test_input_types_match_specTestEndpointCompliance::test_get_endpoint_existsTestEndpointCompliance::test_delete_endpoint_existsAfter (a3c8a5f)
pytest tests/unit/interactions/test_openapi_compliance.py --noconftest -v13 passedPOST /interactionsoperation removed from a copy of the spec,_create_request_schemaraisesno model-interaction request body found on POST /interactionsType
✅ Test
Caveats (if any)
Medium
inputis no longerrequiredon the model variant, so the test asserts it is a propertyLow
ruff formatand 32 ruff rulesFinal Attestation