These are the GitHub CoPilot instructions used to edit emitted code, in order to set the
required Foundry-Features HTTP request headers. Before running the Agent,
make sure your package sources code (files under \sdk\ai\azure-ai-projects\azure) do not have any
mypy errors.

The agent created the Python script "auto_set_foundry_features.py" in this folder. Next time
you re-emit from TypeSpec, try running that script from the \sdk\ai\azure-ai-projects folder
and see if again it did the job correctly.

Model used was Claude Sonnet 4.6

Last updated: 2/18/2026

-----------------------------


Write a Python script that will apply all the changes mentioned below.
Save the Python script in the folder "agent-scripts" and call it "auto_set_foundry_features.py".
The assumption is that this script runs in the folder azure-sdk-for-python\sdk\ai\azure-ai-projects
to apply the desired changes.

The Python script is only allowed to edit these four files:
\azure-sdk-for-python\sdk\ai\azure-ai-projects\azure\ai\projects\aio\operations\_operations.py
\azure-sdk-for-python\sdk\ai\azure-ai-projects\azure\ai\projects\operations\_operations.py
\azure-sdk-for-python\sdk\ai\azure-ai-projects\azure\ai\projects\models\__init__.py
\azure-sdk-for-python\sdk\ai\azure-ai-projects\azure\ai\projects\models\_enums.py

Part 1:

In Part 1, you are only allowed to edit the two _operation.py files. In this part, your goal
is to update all public methods that have "foundry_features" as input argument, and instead
define them locally as appropriate. You will also fix the paging call in "list" operations, 
such that "foundry_features" applies to all paging calls.

Step 1:
At the top of each Python script, you will find some comments, followed by a section of
"from" and "import" statements. After all of those, insert the following line:

_get_agent_definition_opt_in_keys: str = ",".join([key.value for key in _models.AgentDefinitionOptInKeys])

Step 2:
Find all the methods that show "foundry_features" as an input argument. It could be optional or required.
You can search for the string "foundry_features: " to find all those. But I would like you to ignore all
the methods with names that start with "build_". They should not be modified.

For each method you find, delete the "foundry_feature" line from the method signature. But take note
of how "foundry_features" is defined here, as you will need that in the next step.
Make sure you also take care of the case where "foundry_features" is the only input arguments (other than
**kwargs).

Also delete the method doc strings lines associated with this (now deleted) input argument. 
Do that by deleting the line that starts with ":keyword foundry_features:", up to and including
the line that starts with ":paramtype foundry_features:". So you may need to delete multiple
lines, not just two lines that include the above strings, but also all lines in between those two lines.

Step 3:
For each one of the methods you found, declare a new local variable _foundry_features at the top of the method,
that will replace the input argument that was removed in the previous step.

if "foundry_features" in the method signature was a required input argument before you removed it,
it should have had the form:

foundry_features: Literal[FoundryFeaturesOptInKeys.SOME_VALUE],

where "SOME_VALUE" is one of the enum values on FoundryFeaturesOptInKeys.

In this case, define the new local variable as follows:

_foundry_features: Literal[FoundryFeaturesOptInKeys.SOME_VALUE] = FoundryFeaturesOptInKeys.SOME_VALUE

where "SOME_VALUE" is the same value you originally saw in the method signature.

If "foundry_features" in the method signature was an optional input argument before you removed it,
it should have one of two forms. It could have this form:

foundry_features: Optional[Union[str, _models.AgentDefinitionOptInKeys]] = None,

in which case the local argument that you should define is the following:
_foundry_features: Optional[str] = _get_agent_definition_opt_in_keys if self._config.allow_preview else None  # type: ignore

Or it can have the form:

foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.SOME_VALUE]] = None,

where "SOME_VALUE" is one of the enum values on FoundryFeaturesOptInKeys.
in which case the local argument that you should define is the following:

_foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.SOME_VALUE]] = FoundryFeaturesOptInKeys.SOME_VALUE if self._config.allow_preview else None  # type: ignore

Step 4:
For each one of the methods you found, look for the line "foundry_features=foundry_features" 
specifying an input argument to a function call, where the function name starts with "build_".
Replace that with "foundry_features=_foundry_features".

Step 5:
For each one of the methods you found, also see if it includes a function definition with
the following signature:
def prepare_request(next_link=None):

If so, look for the following line inside that function:
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params

And replace it with this line:
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params, headers={"Foundry-Features": _SERIALIZER.header("foundry_features", _foundry_features, "str")}

Part 2:

In Part 2, you are allowed to edit all four files mentioned above. No other files. In this part you will:
* Rename the class AgentDefinitionOptInKeys to _AgentDefinitionOptInKeys and make it internal.
* Rename the class FoundryFeaturesOptInKeys to _FoundryFeaturesOptInKeys and make it internal.
Which means you need to remove them from the relevant __init__.py file and fix all imports as a result.

Verification:

After your created the Python script and saved it to disk, run it in the folder \azure-sdk-for-python\sdk\ai\azure-ai-projects
in order to apply the changes mentioned above.

To verify your result, first run the 'black' tool, which validates the formatting of the code:
black --config ../../../eng/black-pyproject.toml .

Once that is error free, run MyPy tool in the following way: 
tox run -e mypy -c ../../../eng/tox/tox.ini --root .

and make sure there are no errors in the files under folder \azure-sdk-for-python\sdk\ai\azure-ai-projects\azure .
Note there may be errors in sample or test code. Ignore those.

If there are any errors during verification, update the auto_set_foundry_features.py script to make sure those
will not appear again.
