Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build and deploy AI applications on Azure AI Foundry using Microsoft's model catalog and AI services
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
foundry-agent/agent-optimizer/references/scaffold.md
1# Scaffold Workflow23Use this workflow to make a Python agent optimizable before running Agent Optimizer in Foundry.45## Step 1: Resolve Target and Goal67Stay inside the selected agent root. Confirm the project is Python using `requirements.txt`, `pyproject.toml`, `setup.py`, or Python entrypoints.89Identify the optimization goal from user input, selected `evaluationSuites[]`, `.foundry/evaluators/*`, recent result summaries, datasets, or code/test comments. If the goal is unclear, proceed conservatively and explain that evaluator-specific targeting improves optimization quality.1011## Step 2: Inventory Safe Targets1213Scan for instructions, model selection, skill folders, function tool definitions, topology, and hosting entrypoint. Record file path, symbol/name, role, current value, and whether it is safe to expose through the optimizer.1415Classify topology as single-agent, orchestrator/supervisor, specialist tool-agent, peer multi-agent, or unknown runtime. Do not collapse role-specific prompts into one global prompt. Ask before editing when multiple scopes are plausible.1617Use [Python Patterns](python-patterns.md#target-selection) to map evaluator/dataset goals to the smallest useful baseline.1819## Step 3: Scaffold Baseline Files2021Create the required `.agent_configs/baseline/` folder beside `agent.yaml`:2223```text24.agent_configs/25baseline/26metadata.yaml27instructions.md28tools.json29skills/<skill-name>/SKILL.md30```3132`metadata.yaml` points to selected baseline files:3334```yaml35model: <existing-chat-model-deployment-name>36temperature: 0.737instruction_file: instructions.md38skill_dir: skills39tool_file: tools.json40```4142Write the selected baseline prompt to `instructions.md`. Include only relevant skills under `skills/`. Use `tools.json` only for OpenAI function-calling tool definitions; see [Python Patterns](python-patterns.md#tools-file).4344Choose a `model` value that already exists as a model deployment in the target Foundry project.4546Do not use code-level defaults as the optimization baseline.4748## Step 4: Install and Wire SDK4950Add `azure-ai-agentserver-optimization` to the target agent project's dependency file:5152```text53azure-ai-agentserver-optimization54```5556Wire the agent with no default parameters:5758```python59from azure.ai.agentserver.optimization import load_config6061config = load_config()62```6364Map resolved values:6566- Instructions -> `config.compose_instructions()`67- Model -> `config.model`68- Skills -> `config.skills_dir` with `load_skills_from_dir(...)` only when the runtime has a safe skill/tool mechanism69- Function tool definitions -> `config.apply_tool_descriptions(tools)` when tool metadata can be patched safely7071Do not add optimization runtime env vars to `agent.yaml`. The default local config path is `.agent_configs/`; use `load_config(config_dir="...")` only when the scaffold intentionally uses a non-default local config directory.7273## Step 5: Verify and Stop7475Run Python syntax checks, SDK import smoke test, baseline config smoke test with no-arg `load_config()`, workspace diagnostics, and cheap relevant project tests.7677End with a review checkpoint. Summarize changed files, optimization targets, evaluator goals, global side effects, and verification. Do not deploy automatically.7879After user review, continue with [Optimize Workflow](optimize-workflow.md).80