refactor(config): promote deployment-config models to agentex.config.*#396
Open
max-parke-scale wants to merge 1 commit into
Open
refactor(config): promote deployment-config models to agentex.config.*#396max-parke-scale wants to merge 1 commit into
max-parke-scale wants to merge 1 commit into
Conversation
Promotes the deployment/agent configuration model classes out of the heavy ADK (agentex.lib.sdk.config) into a new slim-shipped, hand-authored namespace agentex.config.*, so REST-only consumers can import them from the slim agentex-client wheel without installing the ADK runtime. Deployment-models analog of #371 (which did this for protocol types). - New agentex.config.{agent_config,build_config,deployment_config, local_development_config,environment_config} plus model deps {credentials,agent_configs}. ConfigBaseModel inlines the ConfigDict the former model_utils.BaseModel provided (from_attributes/populate_by_name), folding in DeploymentConfig/InjectedSecretsValues' nested validate_by_name. - environment_config: model classes promoted; from_yaml/yaml loading stays in lib as the load_environments_config free function (keeps models slim-safe). - Back-compat shims left at the old agentex.lib.sdk.config.* and agentex.lib.types.{credentials,agent_configs} paths. - Internal lib consumers + tests repointed to the canonical paths. - Modernize the promoted agent_configs/local_development_config validators to @field_validator so the new public surface emits no pydantic-v1 deprecation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
f07aa16 to
e2dd50e
Compare
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.
Summary
Promotes the deployment/agent configuration model classes out of the heavy ADK (
agentex.lib.sdk.config) into a new canonical, hand-authored namespaceagentex.config.*that ships in the slimagentex-clientwheel. REST-only consumers can now import these models without installing the ADK runtime (temporalio / fastapi / litellm / …). Back-compat shims at the old paths keep existing imports working.Deployment-models analog of #371 (which did this for protocol types). Tracking: AGX1-292.
Downstream:
egp-api-backend(SGP-5970) currently hand-copies these models inagentex_sdk_deployment_models.pybecause importing them required the full ADK. This promotion lets it drop the copy.What moved
Promoted to
agentex.config.*(pure pydantic models):agent_config.pyAgentConfigbuild_config.pyBuildContext,BuildConfigdeployment_config.pyImageConfig,DeploymentConfig,ClusterConfig,InjectedSecretsValues, …local_development_config.pyLocalAgentConfig,LocalPathsConfig,LocalDevelopmentConfigenvironment_config.pyAgentAuthConfig,AgentKubernetesConfig,OciRegistryConfig,AgentEnvironmentConfig,AgentEnvironmentsConfig(model classes only)credentials.pyCredentialMapping(moved fromagentex.lib.types)agent_configs.pyTemporalConfig,TemporalWorkerConfig,TemporalWorkflowConfig(moved fromagentex.lib.types)ConfigBaseModel(agentex/config/_base.py) inlines theConfigDict(from_attributes=True, populate_by_name=True)the formermodel_utils.BaseModelprovided — the behavior-preserving swap #371 established.DeploymentConfig/InjectedSecretsValues' nestedclass Config: validate_by_name = Trueis folded into it (redundant withpopulate_by_name; keeping bothmodel_configand a nestedConfigon one class raises in pydantic v2).environment_configsplitThe module mixed pure models with a yaml-loading
from_yaml. The model classes (incl.AgentEnvironmentsConfigwith its accessors/validators) are promoted; thefrom_yaml/yaml loading stays inlibas theload_environments_configfree function (+load_environments_config_from_manifest_dir) so the promoted models stay slim-safe.Back-compat delta: the promoted
AgentEnvironmentsConfigno longer carries a.from_yaml()classmethod. The two in-repo callers (validation.py+ the manifest-dir helper) and the loader tests are repointed toload_environments_config; an external caller via the lib path would switch to the free function.Left in
lib(CLI/build machinery)agent_manifest.py,validation.py,project_config.py— they use yaml / jinja2 / subprocess / tar and are CLI-only.Shims
Back-compat re-export shims at the old
agentex.lib.sdk.config.{agent_config,build_config,deployment_config,local_development_config,environment_config}andagentex.lib.types.{credentials,agent_configs}paths. In-repo lib consumers are repointed to the canonicalagentex.config.*paths, so the shims are purely external-facing.agentex.configis hand-authored and must be protected from codegen regen the same wayagentex.protocol/adk/**are. That protection lives in the Stainless dashboardkeep_files, not this repo (confirmed: no.stainlessconfig exists locally; thepyproject.tomlcomments documentkeep_files: ["adk/**"]as dashboard config, and #371 addedagentex.protocolwith no repo-side codegen change).Action: add
src/agentex/config/**to the dashboardkeep_files. Until that lands, codegen can clobber the new directory. This intersects the open codegen-conflict PRstainless-sdks/agentex-sdk-python#44— flagging rather than silently resolving.Verification (local)
uv build --all-packages --wheel→ allagentex/config/*files ship inagentex_client-*.whland are absent from the ADK wheel. Installed only the slim wheel in a clean venv (6 deps: httpx, pydantic, anyio, distro, sniffio, typing-extensions — no temporalio/fastapi/litellm/yaml/ddtrace) and imported every promoted model: OK../scripts/lint(ruff + pyright +import agentex) and./scripts/check-slim-depspass. (The lone pyright error ishttpx_aiohttpin untouched generated_base_client.py— pre-existing, unrelated.)agentex.lib.*imports still resolve via shims with class identity preserved — pinned by newtests/test_config_shims.py../scripts/test(3.12) locally: 918 passed, 1376 skipped (skips are the API-endpoint tests requiring the prism mock server; all runnable tests pass, including the new shim tests).Test plan
./scripts/test(3.12) passes locally; CI to confirm across 3.12 / 3.13 + ruff/pyright/slim-deps.agentex/config/*; importable with only the 6 slim deps.agentex.lib.sdk.config.*/agentex.lib.types.*imports keep working via shims.🧑💻🤖 — posted via Claude Code
Greptile Summary
This PR promotes deployment and agent configuration Pydantic models from
agentex.lib.sdk.config.*andagentex.lib.types.*into a new slim-safeagentex.config.*namespace, following the same pattern established in #371 for protocol types. Back-compat shims at all old paths keep existing imports working, and a newConfigBaseModelbase class preserves thefrom_attributes=True, populate_by_name=Truesettings from the formermodel_utils.BaseModel.agentex/config/ships in the slimagentex-clientwheel (pydantic-only, no temporalio/fastapi/yaml runtime deps), enabling REST-only consumers to import configuration models without the full ADK.tests/test_config_shims.pypins symbol parity, class identity (forisinstancecorrectness), andpopulate_by_namebehavior across the swap.from_yamlextraction:AgentEnvironmentsConfig.from_yaml()classmethod is replaced by a free functionload_environments_configin the lib layer; in-repo callers and tests are updated accordingly.Confidence Score: 5/5
This is a well-contained structural refactor with no behavioral changes; all moved models preserve their original base class settings, every old import path is covered by a shim, and the new shim tests pin both symbol parity and class identity.
The promoted models faithfully reproduce original base class choices (confirmed against git history): deployment/agent models switched from model_utils.BaseModel to the equivalent ConfigBaseModel, while environment sub-models and credential/temporal models keep plain BaseModel exactly as before. The from_yaml classmethod removal is fully covered by the free-function replacement and retested. The one external action needed (Stainless dashboard keep_files) is correctly flagged in the PR and is outside the code change itself.
No files require special attention — all changed files are either new canonical modules, thin shims, or targeted import updates.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD subgraph slim["agentex-client wheel (slim)"] AC["agentex.config.agent_config\nAgentConfig"] BC["agentex.config.build_config\nBuildConfig, BuildContext"] DC["agentex.config.deployment_config\nDeploymentConfig, ImageConfig, …"] EC["agentex.config.environment_config\nAgentEnvironmentsConfig, …"] LC["agentex.config.local_development_config\nLocalDevelopmentConfig"] CR["agentex.config.credentials\nCredentialMapping"] AGC["agentex.config.agent_configs\nTemporalConfig, …"] BASE["agentex.config._base\nConfigBaseModel"] end subgraph adk["agentex-adk wheel (full)"] SCA["agentex.lib.sdk.config.agent_config\n(shim)"] SCB["agentex.lib.sdk.config.build_config\n(shim)"] SCD["agentex.lib.sdk.config.deployment_config\n(shim)"] SCE["agentex.lib.sdk.config.environment_config\n(shim + yaml loaders)"] SCL["agentex.lib.sdk.config.local_development_config\n(shim)"] LTC["agentex.lib.types.credentials\n(shim)"] LTA["agentex.lib.types.agent_configs\n(shim)"] end BASE --> AC & BC & DC & EC & LC SCA -->|re-exports| AC SCB -->|re-exports| BC SCD -->|re-exports| DC SCE -->|re-exports + loaders| EC SCL -->|re-exports| LC LTC -->|re-exports| CR LTA -->|re-exports| AGCReviews (2): Last reviewed commit: "refactor(config): promote deployment-con..." | Re-trigger Greptile