Skip to content

Commit 9be24e1

Browse files
lindazqliCopilot
andcommitted
Scope Skills preview flag to toolbox version creation
Stable azure-ai-projects 2.3.x toolboxes.create_version does not auto-inject the Skills preview header, so passing a non-empty skills= would fail. Conditionally send headers={'Foundry-Features': 'Skills=V1Preview'} on all three version-creation paths (normal, search-first, RAI-guarded) only when skills is present, and correct the Section 4l prose that claimed skills CRUD was the only preview-gated flow. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 4321edd commit 9be24e1

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

notebooks/mastering-foundry-toolbox.ipynb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,9 +1305,11 @@
13051305
"reference it in the **separate `skills=` list** with `ToolboxSkillReference(name, version)`. Omit\n",
13061306
"`version` to track the skill's **default** version; pin it to freeze on an immutable version.\n",
13071307
"\n",
1308-
"> Skills CRUD (`project.beta.skills.*` create / update-default) is the **only** flow that needs a\n",
1309-
"> preview feature flag, and the `beta.skills` SDK sends it for you. Reading skills as MCP resources\n",
1310-
"> (section 10b) and regular toolbox/tool calls need **no** preview header.\n",
1308+
"> Two flows need the **Skills preview flag** (`Foundry-Features: Skills=V1Preview`): skills CRUD\n",
1309+
"> (`project.beta.skills.*` create / update-default), where the `beta.skills` SDK sends it for you,\n",
1310+
"> **and** creating a toolbox version that references a skill. Stable `toolboxes.create_version`\n",
1311+
"> does **not** inject it, so section 4m sets it explicitly whenever `skills` is non-empty. Reading\n",
1312+
"> skills as MCP resources (section 10b) and regular toolbox/tool calls need **no** preview header.\n",
13111313
"\n",
13121314
"**Key parameters** (`ToolboxSkillReference`):\n",
13131315
"- `name` - **required** `str`; the published skill name.\n",
@@ -1402,11 +1404,15 @@
14021404
],
14031405
"source": [
14041406
"# create_version(name, *, tools, description=None, metadata=None, skills=None, policies=None)\n",
1407+
"# Stable toolboxes.create_version does NOT auto-inject the Skills preview flag, so send it\n",
1408+
"# ourselves whenever this version references a skill (empty kwargs when there are no skills).\n",
1409+
"skill_kwargs = {\"headers\": {\"Foundry-Features\": \"Skills=V1Preview\"}} if skills else {}\n",
14051410
"version = project.toolboxes.create_version(\n",
14061411
" name=TOOLBOX_NAME,\n",
14071412
" description=\"Diverse demo toolbox: search, code, knowledge, and connection-backed tools.\",\n",
14081413
" tools=tools,\n",
14091414
" skills=skills or None,\n",
1415+
" **skill_kwargs,\n",
14101416
")\n",
14111417
"created_resources[\"toolbox\"] = TOOLBOX_NAME\n",
14121418
"created_resources[\"versions\"].append(version.version)\n",
@@ -1594,10 +1600,13 @@
15941600
" tool_configs=tool_configs,\n",
15951601
"))\n",
15961602
"\n",
1603+
"# Same rule as section 4m: only send the Skills preview flag when this version has skills.\n",
1604+
"skill_kwargs = {\"headers\": {\"Foundry-Features\": \"Skills=V1Preview\"}} if skills else {}\n",
15971605
"search_version = project.toolboxes.create_version(\n",
15981606
" name=TOOLBOX_NAME,\n",
15991607
" tools=search_tools,\n",
16001608
" skills=skills or None,\n",
1609+
" **skill_kwargs,\n",
16011610
")\n",
16021611
"created_resources[\"versions\"].append(search_version.version)\n",
16031612
"print(f\"✅ Search-first version {search_version.version} - tools/list will now return tool_search + pinned only\")"
@@ -1720,11 +1729,14 @@
17201729
"# RAI policy and Foundry screens tool inputs/outputs for that version.\n",
17211730
"RAI_POLICY_NAME = os.getenv(\"RAI_POLICY_NAME\")\n",
17221731
"if RAI_POLICY_NAME:\n",
1732+
" # Only send the Skills preview flag when this version references a skill (see 4m).\n",
1733+
" skill_kwargs = {\"headers\": {\"Foundry-Features\": \"Skills=V1Preview\"}} if skills else {}\n",
17231734
" guarded = project.toolboxes.create_version(\n",
17241735
" name=TOOLBOX_NAME,\n",
17251736
" tools=search_tools,\n",
17261737
" skills=skills or None,\n",
17271738
" policies=ToolboxPolicies(rai_config=RaiConfig(rai_policy_name=RAI_POLICY_NAME)),\n",
1739+
" **skill_kwargs,\n",
17281740
" )\n",
17291741
" created_resources[\"versions\"].append(guarded.version)\n",
17301742
" project.toolboxes.update(name=TOOLBOX_NAME, default_version=guarded.version)\n",

0 commit comments

Comments
 (0)