Skip to content

refactor(config): promote deployment-config models to agentex.config.*#396

Open
max-parke-scale wants to merge 1 commit into
nextfrom
mparke/reverent-mclaren-50328a
Open

refactor(config): promote deployment-config models to agentex.config.*#396
max-parke-scale wants to merge 1 commit into
nextfrom
mparke/reverent-mclaren-50328a

Conversation

@max-parke-scale

@max-parke-scale max-parke-scale commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Promotes the deployment/agent configuration model classes out of the heavy ADK (agentex.lib.sdk.config) into a new canonical, hand-authored namespace agentex.config.* that ships in the slim agentex-client wheel. 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 in agentex_sdk_deployment_models.py because importing them required the full ADK. This promotion lets it drop the copy.

What moved

Promoted to agentex.config.* (pure pydantic models):

New module Classes
agent_config.py AgentConfig
build_config.py BuildContext, BuildConfig
deployment_config.py ImageConfig, DeploymentConfig, ClusterConfig, InjectedSecretsValues, …
local_development_config.py LocalAgentConfig, LocalPathsConfig, LocalDevelopmentConfig
environment_config.py AgentAuthConfig, AgentKubernetesConfig, OciRegistryConfig, AgentEnvironmentConfig, AgentEnvironmentsConfig (model classes only)
credentials.py CredentialMapping (moved from agentex.lib.types)
agent_configs.py TemporalConfig, TemporalWorkerConfig, TemporalWorkflowConfig (moved from agentex.lib.types)

ConfigBaseModel (agentex/config/_base.py) inlines the ConfigDict(from_attributes=True, populate_by_name=True) the former model_utils.BaseModel provided — the behavior-preserving swap #371 established. DeploymentConfig / InjectedSecretsValues' nested class Config: validate_by_name = True is folded into it (redundant with populate_by_name; keeping both model_config and a nested Config on one class raises in pydantic v2).

environment_config split

The module mixed pure models with a yaml-loading from_yaml. The model classes (incl. AgentEnvironmentsConfig with its accessors/validators) are promoted; the from_yaml/yaml loading stays in lib as the load_environments_config free function (+ load_environments_config_from_manifest_dir) so the promoted models stay slim-safe.

Back-compat delta: the promoted AgentEnvironmentsConfig no longer carries a .from_yaml() classmethod. The two in-repo callers (validation.py + the manifest-dir helper) and the loader tests are repointed to load_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} and agentex.lib.types.{credentials,agent_configs} paths. In-repo lib consumers are repointed to the canonical agentex.config.* paths, so the shims are purely external-facing.

⚠️ Stainless dashboard action required

agentex.config is hand-authored and must be protected from codegen regen the same way agentex.protocol / adk/** are. That protection lives in the Stainless dashboard keep_files, not this repo (confirmed: no .stainless config exists locally; the pyproject.toml comments document keep_files: ["adk/**"] as dashboard config, and #371 added agentex.protocol with no repo-side codegen change).

Action: add src/agentex/config/** to the dashboard keep_files. Until that lands, codegen can clobber the new directory. This intersects the open codegen-conflict PR stainless-sdks/agentex-sdk-python#44 — flagging rather than silently resolving.

Verification (local)

  • Slim-safety (decisive): uv build --all-packages --wheel → all agentex/config/* files ship in agentex_client-*.whl and 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-deps pass. (The lone pyright error is httpx_aiohttp in untouched generated _base_client.py — pre-existing, unrelated.)
  • Old agentex.lib.* imports still resolve via shims with class identity preserved — pinned by new tests/test_config_shims.py.
  • Full ./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.
  • Slim wheel contains agentex/config/*; importable with only the 6 slim deps.
  • Old 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.* and agentex.lib.types.* into a new slim-safe agentex.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 new ConfigBaseModel base class preserves the from_attributes=True, populate_by_name=True settings from the former model_utils.BaseModel.

  • New canonical namespace: agentex/config/ ships in the slim agentex-client wheel (pydantic-only, no temporalio/fastapi/yaml runtime deps), enabling REST-only consumers to import configuration models without the full ADK.
  • Shims + tests: Every old import path is preserved via thin re-export shims; a new tests/test_config_shims.py pins symbol parity, class identity (for isinstance correctness), and populate_by_name behavior across the swap.
  • from_yaml extraction: AgentEnvironmentsConfig.from_yaml() classmethod is replaced by a free function load_environments_config in 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

Filename Overview
src/agentex/config/_base.py New ConfigBaseModel that inlines from_attributes=True, populate_by_name=True — direct replacement for model_utils.BaseModel, behavior-preserving.
src/agentex/config/deployment_config.py All deployment config classes migrated to ConfigBaseModel; nested class Config removed (was redundant in Pydantic v2); global alias field preserved correctly.
src/agentex/config/environment_config.py Model classes promoted; AgentAuthConfig/AgentKubernetesConfig/OciRegistryConfig/AgentEnvironmentConfig keep plain BaseModel (same as originals); AgentEnvironmentsConfig uses ConfigBaseModel matching UtilsBaseModel; from_yaml removed in favor of free function.
src/agentex/config/agent_configs.py TemporalConfig and friends migrated from deprecated Pydantic v1 @validator to @field_validator; logic unchanged.
src/agentex/lib/sdk/config/environment_config.py Converted to shim + yaml-loader host; re-exports all original symbols including load_environments_config and load_environments_config_from_manifest_dir.
src/agentex/lib/sdk/config/deployment_config.py Back-compat shim re-exporting all 10 original public symbols from canonical path.
src/agentex/lib/types/agent_configs.py Back-compat shim for TemporalConfig/TemporalWorkerConfig/TemporalWorkflowConfig.
tests/test_config_shims.py New shim tests covering symbol parity, class identity, and populate_by_name preservation; comprehensive coverage of all promoted modules.
tests/lib/cli/test_environment_config.py TestAgentEnvironmentsConfigFromYaml renamed and repointed to load_environments_config free function; all call sites updated correctly.
src/agentex/lib/sdk/config/validation.py Import updated to pull models from canonical agentex.config.environment_config and loader from lib shim; split is correct.

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| AGC
Loading

Reviews (2): Last reviewed commit: "refactor(config): promote deployment-con..." | Re-trigger Greptile

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>
@max-parke-scale max-parke-scale force-pushed the mparke/reverent-mclaren-50328a branch from f07aa16 to e2dd50e Compare June 9, 2026 06:52
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