feat(api): advertise contract version via X-Agentex-Version response header#322
Closed
max-parke-scale wants to merge 2 commits into
Closed
feat(api): advertise contract version via X-Agentex-Version response header#322max-parke-scale wants to merge 2 commits into
max-parke-scale wants to merge 2 commits into
Conversation
scale-agentex has no version axis of its own — it floats at head, and the only version concept comes from SGP's platform release. That leaves no way to name an "oldest supported server contract" for downstream consumers. Add release-please (release-type: python; conventional-commit PR titles already enforced) so merges to main cut versioned releases: a vX.Y.Z git tag + GitHub release + CHANGELOG. Make the contract self-describe its version so the tag and spec never drift: - src/_version.py is the single source; the FastAPI app reads it (version=__version__), so generate_openapi_spec.py emits it as info.version. - release-please bumps src/_version.py, agentex/openapi.yaml (info.version), agentex/pyproject.toml, and the root pyproject together with the tag. Each tag is thus an immutable, self-describing snapshot of agentex/openapi.yaml the SDK's cross-version compat suite can pin as min-supported (scaleapi/scale-agentex-python#407), replacing the placeholder commit SHA today. Contract checkpoints, not a deploy gate: the server still floats at head for deploys. Seeded at 0.1.0 with bootstrap-sha at current main HEAD so the changelog starts fresh; the first feat/fix merge (or workflow_dispatch) cuts the first release. Verified gen-openapi emits info.version from _version.py with no spec drift. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…header Adds VersionHeaderMiddleware, which sets X-Agentex-Version: <__version__> on every response (sourced from src/_version.py, the release-managed version), so clients can detect a server whose contract version is incompatible with their build — consumed by the SDK's runtime check (scale-agentex-python#410, AGX1-367). Pure-ASGI middleware (robust for streaming); registered in app.py alongside the existing stack. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Closing as superseded by scaleapi/scale-agentex-python#408. That runtime version guard reads the backend's 🧑💻🤖 — posted via Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
VersionHeaderMiddleware, which setsX-Agentex-Version: <__version__>on every response (sourced fromsrc/_version.py, the release-managed version added in #321).Why
Lets clients detect a server whose contract version is incompatible with their build. This is the server half of the runtime compat warning — consumed by the SDK's check (scale-agentex-python#410, AGX1-367), the runtime complement to the build-time compat suite. The SDK warning stays dormant until servers emit this header.
How
Pure-ASGI middleware (robust for streaming responses), registered in
app.pyalongside the existing middleware stack.Test
tests/unit/api/test_version_header_middleware.py— a wrapped app setsX-Agentex-Version=__version__(mirrors the existing health-interceptor unit-test pattern).ruffclean; test green.Stacking
Stacked on #321 — needs
src/_version.py(added there). PR base is the #321 branch so the diff shows only this change; will retarget tomainonce #321 merges.Server half of AGX1-367.
🧑💻🤖 — posted via Claude Code
Greptile Summary
VersionHeaderMiddlewareto attachX-Agentex-Versionfromsrc._version.__version__to API responses.Confidence Score: 4/5
The version header integration needs fixes before merge because health endpoints and browser-accessible CORS responses do not fully support the advertised compatibility contract.
The changes are narrowly scoped and covered by a unit test, and focused runtime checks reproduced both contract gaps without indicating broader instability.
agentex/src/api/app.pyneeds attention for middleware ordering around health responses and CORS exposure of the version header.What T-Rex did
Comments Outside Diff (2)
agentex/src/api/app.py, line 216 (link)VersionHeaderMiddlewareis installed insidefastapi_app, but the exported ASGI app is later wrapped withHealthCheckInterceptor. For/healthz,/readyz, and/healthcheck, that interceptor sends the response directly and never calls into the FastAPI middleware stack, so those production responses do not includeX-Agentex-Version. Wrap the health interceptor inside the version middleware, or add the same header in the interceptor response helpers so health endpoints also advertise the contract version.Artifacts
Repro: ASGI TestClient script requesting health endpoints from the exported app
Repro: runtime request output showing HTTP status codes and missing X-Agentex-Version headers
Prompt To Fix With AI
agentex/src/api/app.py, line 132-138 (link)X-Agentex-Versionis a custom response header, but the CORS middleware does not expose it. For cross-origin browser requests, the response can include the header on the wire whileresponse.headers.get('X-Agentex-Version')still returns nothing, so web clients cannot run the compatibility check. Add this header toexpose_headersin the CORS config.Artifacts
Repro: ASGI cross-origin request script for X-Agentex-Version exposure
Stack trace captured during the T-Rex run
Prompt To Fix With AI
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!
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "feat(api): advertise contract version vi..." | Re-trigger Greptile