Skip to content

[feat] new azure-ai-agentserver-optimization package for load_config#47096

Open
Zyysurely wants to merge 5 commits into
mainfrom
zyying/opt_load_config
Open

[feat] new azure-ai-agentserver-optimization package for load_config#47096
Zyysurely wants to merge 5 commits into
mainfrom
zyying/opt_load_config

Conversation

@Zyysurely
Copy link
Copy Markdown
Contributor

@Zyysurely Zyysurely commented May 23, 2026

Description

azure-ai-agentserver-optimization — Initial beta release (1.0.0b1)

Summary

Adds a new package azure-ai-agentserver-optimization that provides a drop-in config loader for optimization-ready Azure AI Hosted Agents. A single load_config() call resolves optimization parameters (instructions, model, temperature, skills, tool definitions) from multiple sources with graceful fallback — the agent works unchanged when not running under optimization.

What's included

Public API:

  • load_config(*, config_dir, required) — 4-priority config resolution with graceful fallback
  • load_skills_from_dir(path) — load skills from a directory of SKILL.md files on demand
  • OptimizationConfig — resolved config dataclass (instructions, model, temperature, skills, skills_dir, tool_definitions, source, candidate_id)
  • OptimizationConfig.apply_tool_descriptions(tools) — patch __doc__, .description, and input_model parameter descriptions on @tool-decorated functions
  • OptimizationConfig.compose_instructions() — append skill catalog to instructions
  • CandidateConfig / Skill — typed models for API payload and learned skills

Resolution order (first match wins):

  1. Inline JSONOPTIMIZATION_CONFIG env var (used by temp agent versions during eval)
  2. Resolver APIOPTIMIZATION_CANDIDATE_ID + OPTIMIZATION_RESOLVE_ENDPOINT → fetches config, persists to local layout
  3. Local directoryconfig_dir param / OPTIMIZATION_LOCAL_DIR env var / .agent_configs/ default → reads metadata.yaml + instructions.md + tools.json + skills/
  4. No configrequired=True raises ValueError; required=False returns None

Key design decisions:

  • Tool definitions use OpenAI function-calling list format exclusively
  • Local directory layout: baseline/ as required fallback, <candidate_id>/ folders for optimization candidates
  • Resolver API persists fetched configs and skill files to local directory for offline use
  • Path traversal (zip-slip) protection on skill file downloads from untrusted API responses
  • Uses azure-core PipelineClient for HTTP transport with DefaultAzureCredential auth

Files

  • azure/ai/agentserver/optimization/_config.py — config loader with 4-priority resolution
  • azure/ai/agentserver/optimization/_models.py — data models (OptimizationConfig, CandidateConfig, Skill, MetadataConfig)
  • azure/ai/agentserver/optimization/_resolver.py — resolver API client with local persistence
  • tests/test_config.py, test_resolver.py, test_integration.py — 183 tests

Copilot AI review requested due to automatic review settings May 23, 2026 03:29
@github-actions github-actions Bot added the Hosted Agents sdk/agentserver/* label May 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new azure-ai-agentserver-optimization package under sdk/agentserver/ that provides a single load_config() entry point for resolving hosted-agent optimization configuration from multiple sources (env inline JSON, resolver API, local directory, defaults), and wires the new package into the agentserver CI artifact list.

Changes:

  • Added the new azure-ai-agentserver-optimization package (packaging metadata, README, changelog, namespace package files, and typed implementation for config loading + resolver API persistence).
  • Implemented config resolution logic (_config.py), models/parsers (_models.py), and remote candidate resolution/persistence (_resolver.py).
  • Added a comprehensive unit test suite for resolution priorities, parsing, persistence, and resolver behavior; updated sdk/agentserver/ci.yml to include the new artifact.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
sdk/agentserver/ci.yml Adds azure-ai-agentserver-optimization to CI artifacts for the agentserver service directory.
sdk/agentserver/azure-ai-agentserver-optimization/README.md New package README describing load_config(), env vars, file layout, and formats.
sdk/agentserver/azure-ai-agentserver-optimization/pyproject.toml New package build metadata, dependencies, classifiers, and azure-sdk-build settings.
sdk/agentserver/azure-ai-agentserver-optimization/MANIFEST.in sdist manifest entries (docs, license, tests, namespace files, py.typed).
sdk/agentserver/azure-ai-agentserver-optimization/LICENSE MIT license for the new package.
sdk/agentserver/azure-ai-agentserver-optimization/dev_requirements.txt Dev/test requirements for the new package.
sdk/agentserver/azure-ai-agentserver-optimization/CHANGELOG.md Initial release notes for the new package.
sdk/agentserver/azure-ai-agentserver-optimization/azure/init.py Namespace package marker for azure.
sdk/agentserver/azure-ai-agentserver-optimization/azure/ai/init.py Namespace package marker for azure.ai.
sdk/agentserver/azure-ai-agentserver-optimization/azure/ai/agentserver/init.py Namespace package marker for azure.ai.agentserver.
sdk/agentserver/azure-ai-agentserver-optimization/azure/ai/agentserver/optimization/init.py Public API exports (load_config, models) and module docstring.
sdk/agentserver/azure-ai-agentserver-optimization/azure/ai/agentserver/optimization/_version.py Declares package version.
sdk/agentserver/azure-ai-agentserver-optimization/azure/ai/agentserver/optimization/_models.py Dataclasses (OptimizationConfig, etc.) and parsing helpers.
sdk/agentserver/azure-ai-agentserver-optimization/azure/ai/agentserver/optimization/_config.py load_config() implementation + local directory loading/parsing.
sdk/agentserver/azure-ai-agentserver-optimization/azure/ai/agentserver/optimization/_resolver.py Remote resolver API calls and persistence to local layout.
sdk/agentserver/azure-ai-agentserver-optimization/azure/ai/agentserver/optimization/py.typed Enables PEP 561 typing for the package.
sdk/agentserver/azure-ai-agentserver-optimization/tests/conftest.py Test-wide env var cleanup fixture.
sdk/agentserver/azure-ai-agentserver-optimization/tests/test_config.py Unit tests for load_config() resolution and parsing helpers.
sdk/agentserver/azure-ai-agentserver-optimization/tests/test_resolver.py Unit tests for resolver API behavior and persistence helpers.

Comment thread sdk/agentserver/azure-ai-agentserver-optimization/CHANGELOG.md Outdated
Comment thread sdk/agentserver/azure-ai-agentserver-optimization/README.md Outdated
Comment thread sdk/agentserver/azure-ai-agentserver-optimization/tests/test_config.py Outdated
Comment thread sdk/agentserver/azure-ai-agentserver-optimization/tests/conftest.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants