Repository navigation
Commit 87d4d0a
authored
Python: feat(core): add session-scoped file access isolation (microsoft#8542)
* feat(core): add session-scoped mode to FileAccessProvider
Add an opt-in session_scoped mode (with an optional explicit scope) that
confines file-access tool operations to a working folder derived from the
session id via the shared _storage_key_segment derivation under the
file-access-specific "~access-" prefix, mirroring FileMemoryProvider. The
mode fails closed (ValueError) when neither a scope nor a session id is
available, creates the session folder in before_run, appends a
session-isolation note to the tool instructions, and logs the derived
folder at debug level. All eight tools route store calls through a single
_session_path helper; ls/grep treat an empty directory as the session root
and grep results stay session-relative. Default mode is byte-for-byte
unchanged.
Adds seven regression tests, including the COLLIDING_IDENTIFIERS attack
strings parametrization, fail-closed coverage, scope override, and
shared-store default regression. All harness file-access tests pass; the
only full-suite failure is the pre-existing
test_feature_stage.py::test_feature_id_allows_lowercase_values on main.
Addresses microsoft#8539.
* feat(core): wire file_access_session_scoped through create_harness_agent
Expose the FileAccessProvider session-scoped mode from
create_harness_agent via a new file_access_session_scoped flag (default
False, preserving shared-store semantics), threaded through
_assemble_context_providers and synchronized across the .pyi stub and the
package AGENTS.md file-access section.
Adds a pass-through regression test. Addresses microsoft#8539.
* docs(core): describe scoped file access isolation relative to the workspace
The session-scoped instruction suffix claimed files are never visible to
other sessions, which is wrong when an explicit scope intentionally shares
a workspace across sessions. Rephrase the suffix, the class docstring, and
the session_scoped parameter docs to describe isolation relative to the
resolved workspace (session or configured scope).
Addresses review feedback on PR microsoft#8542.
* fix(core): harden session-scoped file access boundaries
Address review feedback on PR microsoft#8542:
- Normalize ls/grep directories with _normalize_relative_path(...,
is_directory=True) in scoped mode so a ".." directory cannot escape the
session workspace through a permissive custom store.
- Place every scoped working folder under a fixed ~access- namespace
directory, so file access and file memory working folders cannot collide
when both providers share one store root and a literal-safe identifier.
- Treat a non-empty explicit scope as enabling scoped mode by itself,
aligning with FileMemoryProvider(scope=...).
Adds parent-traversal, namespace-collision, and scope-only regression
tests and updates layout assertions to the namespaced folder shape. All
harness suites pass; ruff clean.1 parent 435012e commit 87d4d0a
6 files changed
Lines changed: 359 additions & 21 deletions
File tree
- python/packages/core
- agent_framework/_harness
- tests/core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
| 208 | + | |
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| |||
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| 200 | + | |
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
| |||
330 | 332 | | |
331 | 333 | | |
332 | 334 | | |
| 335 | + | |
333 | 336 | | |
334 | 337 | | |
335 | 338 | | |
| |||
454 | 457 | | |
455 | 458 | | |
456 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
457 | 464 | | |
458 | 465 | | |
459 | 466 | | |
| |||
608 | 615 | | |
609 | 616 | | |
610 | 617 | | |
| 618 | + | |
611 | 619 | | |
612 | 620 | | |
613 | 621 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
0 commit comments