-
Notifications
You must be signed in to change notification settings - Fork 10
chore: release main #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: release main #520
Changes from all commits
94335d7
53ab900
d88fac6
687ebfb
a90f622
066105f
bd2a3ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| ".": "0.26.0", | ||
| "adk": "0.26.0" | ||
| ".": "0.27.0", | ||
| "adk": "0.27.0" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
|
||
| __title__ = "agentex" | ||
| __version__ = "0.26.0" # x-release-please-version | ||
| __version__ = "0.27.0" # x-release-please-version |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| """Opt-in stamping of the agent's source commit onto its spans. | ||
| """Stamping of the agent's source commit onto its spans. | ||
|
|
||
| Nothing is stamped until the agent calls :func:`enable`, mirroring the | ||
| ``lineage`` registry next door: a process-wide switch the agent sets once at | ||
| import, rather than automatic behaviour every agent inherits. When enabled the | ||
| resolved commit lands in span data under ``__commit_sha__`` and is searchable in | ||
| the SGP Traces UI as ``__commit_sha__:<sha>``. | ||
| Stamping turns on when the process starts with ``AGENT_COMMIT_SHA`` set, which | ||
| the SGP cloud deploy does from the build record's attested commit, or when the | ||
| agent calls :func:`enable` itself. Nothing is stamped otherwise: upgrading the | ||
| SDK alone never starts emitting the field. When on, the resolved commit lands in | ||
| span data under ``__commit_sha__`` and is searchable in the SGP Traces UI as | ||
| ``__commit_sha__:<sha>``. | ||
|
|
||
| This is deliberately separate from ``__agent_version__``, which is automatic and | ||
| carries the deployed image tag verbatim ("image tag or git sha"). That tag is a | ||
|
|
@@ -21,7 +22,7 @@ | |
|
|
||
| from agentex.lib.utils.logging import make_logger | ||
|
|
||
| __all__ = ("COMMIT_SHA_KEY", "enable", "disable", "is_enabled", "commit_sha") | ||
| __all__ = ("COMMIT_SHA_KEY", "enable", "disable", "is_enabled", "commit_sha", "is_git_object_name") | ||
|
|
||
| logger = make_logger(__name__) | ||
|
|
||
|
|
@@ -31,6 +32,12 @@ | |
| # git's own 7-character minimum. | ||
| _GIT_SHA_RE = re.compile(r"[0-9a-fA-F]{7,64}") | ||
|
|
||
|
|
||
| def is_git_object_name(value: str) -> bool: | ||
| """Whether ``value`` is a full or abbreviated git SHA-1/SHA-256 object name.""" | ||
| return _GIT_SHA_RE.fullmatch(value.strip()) is not None | ||
|
|
||
|
|
||
| _COMMIT_SHA_ENV = "AGENT_COMMIT_SHA" | ||
| # Fallback only: automatic, and only usable when it happens to be SHA-shaped. | ||
| _AGENT_VERSION_ENV = "AGENT_VERSION" | ||
|
|
@@ -42,13 +49,16 @@ | |
|
|
||
|
|
||
| def enable(commit_sha: str | None = None) -> None: | ||
| """Opt this process in to stamping ``__commit_sha__`` onto every span. | ||
| """Turn on stamping ``__commit_sha__`` onto every span from this process. | ||
|
|
||
| Value precedence: the explicit ``commit_sha`` argument, else | ||
| ``AGENT_COMMIT_SHA``, else ``AGENT_VERSION`` when the deployment happened to | ||
| set it to a bare commit SHA. A value that is not a git object name is | ||
| refused with a warning and leaves stamping off -- better an absent field | ||
| than one named for a commit that holds an image tag. | ||
|
|
||
| Called once at import when ``AGENT_COMMIT_SHA`` is set, so a deployment that | ||
| supplies the commit needs no code change in the agent. | ||
| """ | ||
| global _commit_sha | ||
|
|
||
|
|
@@ -103,3 +113,12 @@ def is_enabled() -> bool: | |
| def commit_sha() -> str | None: | ||
| """The resolved commit SHA, or ``None`` when stamping is not enabled.""" | ||
| return _commit_sha | ||
|
|
||
|
|
||
| def _enable_from_environment() -> None: | ||
| """Auto-enable on ``AGENT_COMMIT_SHA`` only; ``AGENT_VERSION`` stays an explicit fallback.""" | ||
| if os.environ.get(_COMMIT_SHA_ENV, "").strip(): | ||
| enable() | ||
|
|
||
|
|
||
| _enable_from_environment() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Knowledge Base Used: Prompt To Fix With AIThis is a comment left during a code review.
Path: src/agentex/lib/core/tracing/code_revision.py
Line: 124
Comment:
`_enable_from_environment()` runs once when `code_revision` is imported. Normal worker startup imports `register_agent` before `EnvironmentVariables.refresh()` loads supported `.env` and `.env.local` files. A valid `AGENT_COMMIT_SHA` from those files reaches registration but never enables tracing. Run the hook after refresh, or read the value lazily.
**Knowledge Base Used:**
- [Observability](https://app.greptile.com/scale-ai/-/custom-context/knowledge-base/scaleapi/scale-agentex-python/-/docs/observability.md)
- [Agent runtime](https://app.greptile.com/scale-ai/-/custom-context/knowledge-base/scaleapi/scale-agentex-python/-/docs/agent-runtime.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @max-parke-scale if applies, can you follow up on this comment in the next release? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| """Tests for the helm values merge_deployment_configs assembles for `agentex agents deploy`.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from agentex.config.agent_config import AgentConfig | ||
| from agentex.config.build_config import BuildConfig, BuildContext | ||
| from agentex.config.agent_manifest import AgentManifest | ||
| from agentex.config.deployment_config import ImageConfig, DeploymentConfig | ||
| from agentex.config.environment_config import AgentAuthConfig, AgentEnvironmentConfig | ||
| from agentex.lib.cli.handlers.deploy_handlers import InputDeployOverrides, merge_deployment_configs | ||
|
|
||
| MANIFEST_TAG = "sha-manifest" | ||
|
|
||
|
|
||
| def _manifest(env: dict[str, str] | None = None) -> AgentManifest: | ||
| return AgentManifest( | ||
| build=BuildConfig(context=BuildContext(root=".", dockerfile="Dockerfile", dockerignore=None)), | ||
| agent=AgentConfig(name="emu-tax", description="Files emu taxes", acp_type="async", env=env), | ||
| deployment=DeploymentConfig(image=ImageConfig(repository="registry.example.com/emu-tax", tag=MANIFEST_TAG)), | ||
| ) | ||
|
|
||
|
|
||
| def _env_config(helm_overrides: dict[str, Any]) -> AgentEnvironmentConfig: | ||
| return AgentEnvironmentConfig(auth=AgentAuthConfig(principal={"user_id": "u-1"}), helm_overrides=helm_overrides) | ||
|
|
||
|
|
||
| def _merge( | ||
| manifest: AgentManifest, | ||
| env_config: AgentEnvironmentConfig | None = None, | ||
| image_tag: str | None = None, | ||
| ) -> dict[str, Any]: | ||
| overrides = InputDeployOverrides(image_tag=image_tag) | ||
| return merge_deployment_configs(manifest, env_config, overrides, "/nonexistent/manifest.yaml") | ||
|
|
||
|
|
||
| class TestAgentVersion: | ||
| def test_stamped_from_the_deploy_image_tag(self): | ||
| values = _merge(_manifest(), image_tag="sha-cli") | ||
|
|
||
| assert values["global"]["agent"]["version"] == "sha-cli" | ||
|
|
||
| def test_follows_an_image_tag_overridden_in_helm_overrides(self): | ||
| values = _merge(_manifest(), _env_config({"global": {"image": {"tag": "sha-env"}}})) | ||
|
|
||
| assert values["global"]["image"]["tag"] == "sha-env" | ||
| assert values["global"]["agent"]["version"] == "sha-env" | ||
|
|
||
| def test_explicit_helm_override_of_the_version_wins(self): | ||
| values = _merge(_manifest(), _env_config({"global": {"agent": {"version": "pinned"}}})) | ||
|
|
||
| assert values["global"]["agent"]["version"] == "pinned" | ||
|
|
||
| def test_skipped_when_the_manifest_env_declares_agent_version(self): | ||
| values = _merge(_manifest(env={"AGENT_VERSION": "v1.2.3"})) | ||
|
|
||
| assert "version" not in values["global"]["agent"] | ||
| assert {"name": "AGENT_VERSION", "value": "v1.2.3"} in values["env"] | ||
|
|
||
| def test_skipped_when_the_environment_env_declares_agent_version(self): | ||
| values = _merge(_manifest(), _env_config({"env": [{"name": "AGENT_VERSION", "value": "v9"}]})) | ||
|
|
||
| assert "version" not in values["global"]["agent"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_async_agentex_client()reads these values whileagentex.lib.adkbuilds its module clients. Normal FastACP startup does not load.envor.env.localuntil the later lifespan call toEnvironmentVariables.refresh(). A timeout set there is ignored, and each existing client keeps the 5-second connect default. Load dotenv before these clients are built, or apply the timeout after refresh.Prompt To Fix With AI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chakrris if applies, can you follow up on this comment in the next release?