Skip to content

Python: [BREAKING] .NET: Replace confine workdir option with disable workdir reset on each call - #10487

Merged
westey (westey-m) merged 4 commits into
mainfrom
clarify-shell-workdir-reset
Dec 1, 2026
Merged

westey (westey-m) merged 4 commits into
mainfrom
clarify-shell-workdir-reset

Conversation

@westey-m

@westey-m westey (westey-m) commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation & Context

LocalShellTool (Python) and LocalShellExecutor (.NET) have an option, on by default, that moves each persistent-mode command back to the configured working directory before it runs. That way a cd in one call does not carry over to the next call.

The option was named confine_workdir / ConfineWorkingDirectory, and several samples described the shell as "confined to" or "sandboxed in" its working directory. That wording suggests the option limits which files a command can reach, which it does not. A single command can still cd elsewhere or use an absolute path. This PR renames the option to describe what it does and updates the docs and samples to match.

Description & Review Guide

  • What are the major changes?

    • Replaced the option with one that has the opposite meaning, so it defaults to false. The old name is removed, since both packages are pre-release. confine=True becomes disable...=False (the default), and confine=False becomes disable...=True.
      • Python: LocalShellTool(confine_workdir=...) → LocalShellTool(disable_workdir_reset_on_each_call=...)
      • .NET: LocalShellExecutorOptions.ConfineWorkingDirectory → LocalShellExecutorOptions.DisableWorkingDirectoryResetOnEachCall
    • Rewrote the option's documentation in both languages. It now says that the option:
      • only sets where each command starts;
      • does not limit which files a command can reach;
      • has no effect in stateless mode, where every command already starts in the working directory;
      • is not a substitute for DockerShellTool / DockerShellExecutor when commands need to be kept inside a container.
    • Renamed the matching private helpers and fields (_maybe_reanchor → _maybe_reset_workdir, MaybeReanchor → MaybeResetWorkingDirectory).
    • The samples no longer set the option explicitly, since the default already resets the directory each call. Updated wording in the Python and .NET "Build your own claw" step 3 and step 4 samples and READMEs, the Python client_with_local_shell.py sample, the .NET Harness README, and the Python tools README.
    • Tests: renamed the existing tests and added a test in each language that documents the behaviour: a command can read a file outside the working directory, and the next call starts back in it.

    Before:

    from agent_framework.tools import LocalShellTool
    
    shell = LocalShellTool(workdir="./data", confine_workdir=True)
    keep_cd = LocalShellTool(workdir="./data", confine_workdir=False)

    After:

    from agent_framework.tools import LocalShellTool
    
    shell = LocalShellTool(workdir="./data")  # resets each call by default
    keep_cd = LocalShellTool(workdir="./data", disable_workdir_reset_on_each_call=True)
  • What is the impact of these changes?

    • Breaking rename for anyone passing the option explicitly. Python callers get a TypeError; .NET callers get a compile error. The fix is to drop confine...=True, or replace confine...=False with disable...=True.
    • Runtime behaviour is unchanged: by default each persistent-mode command still starts back in the working directory in both languages. Stateless mode is unaffected.
  • What do you want reviewers to focus on?

    • Whether the new name (with its false default) and the rewritten docs clearly describe the behaviour.

Related Issue

N/A - trivial change: renames an option and updates docs so its name and description match its existing behaviour. Runtime behaviour does not change.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: implementation of the rename, documentation and sample wording, tests, and this PR description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 12:35
@github-actions github-actions Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python .NET Usage: [Issues, PRs], Target: .Net labels Dec 1, 2026
@github-actions github-actions Bot changed the title Python, .NET: [BREAKING] Rename confine workdir option to reset workdir each call .NET: Python: Python, .NET: [BREAKING] Rename confine workdir option to reset workdir each call Dec 1, 2026
@westey-m westey (westey-m) added the breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible label Dec 1, 2026
@github-actions github-actions Bot changed the title .NET: Python: Python, .NET: [BREAKING] Rename confine workdir option to reset workdir each call .NET: [BREAKING] Python: Python, .NET: Rename confine workdir option to reset workdir each call Dec 1, 2026
@github-code-quality

github-code-quality Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: Python, C#

Python / code-coverage/python

main 9be7ded clarify-shell-workdi... e026b2a +/-
92% 92% 0%

C# / code-coverage/dotnet

main dab94e0 clarify-shell-workdi... e026b2a +/-
86% 86% 0%
View coverage of the 3 most impacted files.
File main dab94e0 clarify-shell-workdi... e026b2a +/-
/home/runner/wo...SessionStore.cs 100% 56% -44%
/home/runner/wo...geExtensions.cs 93% 93% 0%
/home/runner/wo...cutorOptions.cs 100% 100% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated December 01, 2026 14:33 UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The shell test can falsely fail on paths containing spaces, and the documentation omits that resetting requires an explicitly supplied workdir.

2 open issues
What changed in this PR

Renames the Python and .NET local-shell working-directory reset options to avoid implying filesystem isolation. This is a breaking API rename; runtime behavior and defaults remain unchanged.

Changes:

  • Renames public options and their internal fields, helpers, and callers.
  • Clarifies that working-directory resets and command filters do not restrict file access.
  • Updates tests to use the new names and demonstrate access outside the working directory.
File Description
python/​samples/​02-agents/​tools/​local_shell_with_environment_provider.py Uses the renamed option.
python/​samples/​02-agents/​providers/​openai/​client_with_local_shell.py Removes misleading confinement wording.
python/​samples/​02-agents/​harness/​build_your_own_claw/​README.md Clarifies shell reset and isolation limits.
python/​samples/​02-agents/​harness/​build_your_own_claw/​claw_step04_production_ready/​agent.py Updates option, documentation, and logging.
python/​samples/​02-agents/​harness/​build_your_own_claw/​claw_step03_scaling_capabilities.py Updates option and shell-safety explanations.
python/​packages/​tools/​tests/​test_shell_truncate_and_quote.py Updates test-module terminology.
python/​packages/​tools/​tests/​test_local_shell_tool.py Renames tests and adds access and removed-argument checks.
python/​packages/​tools/​README.md Explains that directory settings are not defenses.
python/​packages/​tools/​agent_framework_tools/​shell/​_tool.py Renames the public option and private helper; revises documentation.
dotnet/​tests/​Microsoft.Agents.AI.Tools.Shell.UnitTests/​LocalShellExecutorTests.cs Renames tests and adds outside-directory access coverage.
dotnet/​src/​Microsoft.Agents.AI.Tools.Shell/​ShellSession.cs Renames internal reset fields and helper.
dotnet/​src/​Microsoft.Agents.AI.Tools.Shell/​LocalShellExecutorOptions.cs Renames the public property and clarifies its scope.
dotnet/​src/​Microsoft.Agents.AI.Tools.Shell/​LocalShellExecutor.cs Passes the renamed option into sessions.
dotnet/​src/​Microsoft.Agents.AI.Tools.Shell/​DockerShellExecutor.cs Updates the session constructor argument name.
dotnet/​samples/​02-agents/​Harness/​README.md Describes the shell as approval-gated rather than confined.
dotnet/​samples/​02-agents/​Harness/​BuildYourOwnClaw/​Claw_Step04_ProductionReady/​ClawAgent/​README.md Corrects shell capability wording.
dotnet/​samples/​02-agents/​Harness/​BuildYourOwnClaw/​Claw_Step04_ProductionReady/​ClawAgent/​ClawAgentFactory.cs Updates option, safety comments, and logging.
dotnet/​samples/​02-agents/​Harness/​BuildYourOwnClaw/​Claw_Step03_ScalingCapabilities/​README.md Explains reset behavior and isolation limits.
dotnet/​samples/​02-agents/​Harness/​BuildYourOwnClaw/​Claw_Step03_ScalingCapabilities/​Program.cs Uses the renamed property and corrects shell comments.

Review effort: Balanced

@westey-m westey (westey-m) changed the title .NET: [BREAKING] Python: Python, .NET: Rename confine workdir option to reset workdir each call Python: [BREAKING] .NET: Rename confine workdir option to reset workdir each call Dec 1, 2026
@westey-m westey (westey-m) changed the title Python: [BREAKING] .NET: Rename confine workdir option to reset workdir each call Python: [BREAKING] .NET: Replace confine workdir option with disable workdir reset on each call Dec 1, 2026

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for making the changes!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Python side looks good

@westey-m
westey (westey-m) added this pull request to the merge queue Dec 1, 2026
Merged via the queue into main with commit 791c3e6 Dec 1, 2026
61 checks passed
@westey-m
westey (westey-m) deleted the clarify-shell-workdir-reset branch December 1, 2026 14:46

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants