Skip to content

test(interactions): follow Google's redesigned Interactions OpenAPI spec - #43729

Closed
ankit373 wants to merge 1 commit into
BerriAI:mainfrom
ankit373:fix/interactions-openapi-spec-drift
Closed

ankit373 wants to merge 1 commit into
BerriAI:mainfrom
ankit373:fix/interactions-openapi-spec-drift

Conversation

@ankit373

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • 4 Google Interactions compliance tests fail on every PR
  • Google redesigned its OpenAPI spec, so hard-coded lookups went stale

How it solves it:

  • Finds the create body from POST /interactions, not a schema name
  • Matches GET and DELETE /interactions/{param} by shape, not by {id}
  • Helpers raise if an endpoint vanishes, so real drift still fails

User Flow

Before: a contributor opens an unrelated PR and misc / Run tests goes red on tests they never touched

  1. They open a PR against main that does not touch the Interactions code
  2. misc / Run tests runs tests/unit/interactions/test_openapi_compliance.py
  3. 4 tests fail with KeyError: 'CreateModelInteractionParams' or GET /interactions/{id} endpoint not found
  4. The PR shows a red required check with nothing they can fix

After: the same PR gets a green check, and the tests still fail if the spec loses an endpoint

  1. They open the same PR
  2. misc / Run tests runs the same file
  3. All 13 tests pass against the current spec

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / 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 plain pytest run 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 repo conftest.py imports boto3.

Before (684a1ed)

  1. pytest tests/unit/interactions/test_openapi_compliance.py -q
  2. Output: 4 failed, 9 passed
    • TestRequestCompliance::test_create_model_interaction_request_schema
    • TestRequestCompliance::test_input_types_match_spec
    • TestEndpointCompliance::test_get_endpoint_exists
    • TestEndpointCompliance::test_delete_endpoint_exists

After (a3c8a5f)

  1. pytest tests/unit/interactions/test_openapi_compliance.py --noconftest -v
  2. Output: 13 passed
  3. Drift is still caught: with the POST /interactions operation removed from a copy of the spec, _create_request_schema raises no model-interaction request body found on POST /interactions

Type

✅ Test

Caveats (if any)

Medium

  • Still reads the live spec, so the next Google redesign will fail it again
  • input is no longer required on the model variant, so the test asserts it is a property

Low

  • Older lines in this file already fail ruff format and 32 ruff rules
  • Left untouched; my added lines add no new findings under the pinned ruff 0.15.3

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

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>
@ankit373
ankit373 requested a review from a team September 29, 2026 15:36
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Low risk] Updates test helpers for OpenAPI spec validation.

The PR should not merge until the exported request type accepts the no-input continuation that the revised compliance test allows, and the repository guide violations are addressed

Findings

  1. P1 Continuation type still requires input ▶
  2. P2 New helpers use coarse types ▶
  3. P2 Explanatory comment violates guide ▶
  4. P2 New helpers lack offline tests ▶

Summary

The PR updates Interactions compliance tests to locate the model request schema through POST /interactions and to recognize item endpoints regardless of parameter name

  • The relaxed input assertion leaves a mismatch with the exported request type
  • The new helpers need typed signatures and offline regression coverage

Reviews (1) · Last reviewed commit: "test(interactions): follow Google's rede..."

# `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"]

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.

P1 Continuation type still requires input A continuation can omit input, but CreateModelInteractionParams still requires it. This assertion passes while the exported type rejects that valid request

return spec_dict["components"]["schemas"][ref.split("/")[-1]]


def _create_request_schema(spec_dict: dict[str, Any]) -> dict[str, Any]:

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.

P2 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

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.

P2 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

Suggested change
# `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]

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.

P2 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

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ankit373

ankit373 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing this as superseded: #43958 (merged yesterday) repairs the same four Interactions compliance tests the same way, by reading the create body from POST /interactions and matching the item path by shape. I ran main's version of test_openapi_compliance.py against Google's live spec and all 13 tests pass, so nothing is left for this PR to add. Thanks for the quick fix.

@ankit373 ankit373 closed this Oct 1, 2026
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.

1 participant