maf-sandbox-codeact 0.22.0__tar.gz → 0.23.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/PKG-INFO +38 -3
- {maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/README.md +35 -0
- {maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/pyproject.toml +3 -3
- {maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/pyproject.toml.orig +5 -6
- {maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/src/maf_sandbox_codeact/__init__.py +2 -2
- {maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/src/maf_sandbox_codeact/_tool.py +29 -4
- {maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/LICENSE +0 -0
- {maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/src/maf_sandbox_codeact/_runtime.py +0 -0
- {maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/src/maf_sandbox_codeact/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maf-sandbox-codeact
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.0
|
|
4
4
|
Summary: CodeAct as a Microsoft Agent Framework tool — the model writes a short Python program and it runs inside a sandbox — written against maf-sandbox so it runs on any sandbox backend.
|
|
5
5
|
Keywords: codeact,code-execution,sandbox,agent-framework,microsoft-agent-framework
|
|
6
6
|
Author: SOKOLAI BV
|
|
@@ -15,8 +15,8 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.14
|
|
17
17
|
Classifier: Topic :: Software Development :: Interpreters
|
|
18
|
-
Requires-Dist: maf-sandbox>=0.
|
|
19
|
-
Requires-Dist: agent-framework-core>=1.
|
|
18
|
+
Requires-Dist: maf-sandbox>=0.48.0,<0.49
|
|
19
|
+
Requires-Dist: agent-framework-core>=1.20.0,<1.21
|
|
20
20
|
Requires-Python: >=3.12, <3.15
|
|
21
21
|
Project-URL: Homepage, https://www.sokol.ai
|
|
22
22
|
Project-URL: Source, https://github.com/sokolaidev/maf-extensions
|
|
@@ -135,6 +135,41 @@ Network access is closed unless `egress_allow` names hosts. An allowed host can
|
|
|
135
135
|
|
|
136
136
|
See [host-tool controls](https://github.com/sokolaidev/maf-extensions/blob/main/docs/sandbox/hosts.md#calling-host-tools) for registration, identities and limits.
|
|
137
137
|
|
|
138
|
+
### Disable host functions when FIDES is enabled
|
|
139
|
+
|
|
140
|
+
Pass `host_tools_enabled=False` to `make_codeact_tools` and, if constructing a spec separately, `codeact_sandbox_spec`. CodeAct ignores any supplied registry without reading or sealing it. It requests no `HOST_TOOLS`, advertises no host functions and installs no host-tool channel; Python computation remains available. The default is `True`, preserving registry behavior. The switch is host configuration and never a model tool argument.
|
|
141
|
+
|
|
142
|
+
Use the same trusted setting that installs FIDES middleware. CodeAct does not infer that setting from tool metadata or the current call's security context:
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from agent_framework import Agent
|
|
146
|
+
from agent_framework.security import (
|
|
147
|
+
LabelTrackingFunctionMiddleware,
|
|
148
|
+
PolicyEnforcementFunctionMiddleware,
|
|
149
|
+
)
|
|
150
|
+
from maf_sandbox_codeact import make_codeact_tools
|
|
151
|
+
|
|
152
|
+
fides_enabled = True
|
|
153
|
+
codeact_tools = make_codeact_tools(
|
|
154
|
+
router,
|
|
155
|
+
"data-analyst",
|
|
156
|
+
context,
|
|
157
|
+
host_tools=registry,
|
|
158
|
+
host_tools_enabled=not fides_enabled,
|
|
159
|
+
image="mcr.microsoft.com/devcontainers/python:3.13-bookworm",
|
|
160
|
+
)
|
|
161
|
+
middleware = (
|
|
162
|
+
[LabelTrackingFunctionMiddleware(), PolicyEnforcementFunctionMiddleware()]
|
|
163
|
+
if fides_enabled
|
|
164
|
+
else []
|
|
165
|
+
)
|
|
166
|
+
agent = Agent(client=client, tools=[sensitive_tool, *codeact_tools], middleware=middleware)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The host supplies `sensitive_tool` as an ordinary agent function tool with its FIDES declarations. Direct calls still pass through that middleware; generated code cannot reach the function through CodeAct's disabled channel. File, artifact and network settings remain independent.
|
|
170
|
+
|
|
171
|
+
The setting is captured when building tools. To change it, stop admission through the old tool surface, await or cancel its active calls and complete cleanup, dispose its CodeAct sandboxes, then rebuild and replace the tools and middleware together. Changing the configuration variable alone does not revoke an existing tool. The router refuses reuse of a known sandbox with a different host-tool enablement contract; hosts must also retire old surfaces and instances across processes. This option disables nested calls and does not implement per-host-tool FIDES mediation.
|
|
172
|
+
|
|
138
173
|
## Runtime backends
|
|
139
174
|
|
|
140
175
|
Use `CodeactRuntime` to select `run_code` instead of command execution. The host must verify that the backend evaluates Python statements and returns their output. The required instructions describe the modules and facilities available to the model.
|
|
@@ -110,6 +110,41 @@ Network access is closed unless `egress_allow` names hosts. An allowed host can
|
|
|
110
110
|
|
|
111
111
|
See [host-tool controls](https://github.com/sokolaidev/maf-extensions/blob/main/docs/sandbox/hosts.md#calling-host-tools) for registration, identities and limits.
|
|
112
112
|
|
|
113
|
+
### Disable host functions when FIDES is enabled
|
|
114
|
+
|
|
115
|
+
Pass `host_tools_enabled=False` to `make_codeact_tools` and, if constructing a spec separately, `codeact_sandbox_spec`. CodeAct ignores any supplied registry without reading or sealing it. It requests no `HOST_TOOLS`, advertises no host functions and installs no host-tool channel; Python computation remains available. The default is `True`, preserving registry behavior. The switch is host configuration and never a model tool argument.
|
|
116
|
+
|
|
117
|
+
Use the same trusted setting that installs FIDES middleware. CodeAct does not infer that setting from tool metadata or the current call's security context:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from agent_framework import Agent
|
|
121
|
+
from agent_framework.security import (
|
|
122
|
+
LabelTrackingFunctionMiddleware,
|
|
123
|
+
PolicyEnforcementFunctionMiddleware,
|
|
124
|
+
)
|
|
125
|
+
from maf_sandbox_codeact import make_codeact_tools
|
|
126
|
+
|
|
127
|
+
fides_enabled = True
|
|
128
|
+
codeact_tools = make_codeact_tools(
|
|
129
|
+
router,
|
|
130
|
+
"data-analyst",
|
|
131
|
+
context,
|
|
132
|
+
host_tools=registry,
|
|
133
|
+
host_tools_enabled=not fides_enabled,
|
|
134
|
+
image="mcr.microsoft.com/devcontainers/python:3.13-bookworm",
|
|
135
|
+
)
|
|
136
|
+
middleware = (
|
|
137
|
+
[LabelTrackingFunctionMiddleware(), PolicyEnforcementFunctionMiddleware()]
|
|
138
|
+
if fides_enabled
|
|
139
|
+
else []
|
|
140
|
+
)
|
|
141
|
+
agent = Agent(client=client, tools=[sensitive_tool, *codeact_tools], middleware=middleware)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The host supplies `sensitive_tool` as an ordinary agent function tool with its FIDES declarations. Direct calls still pass through that middleware; generated code cannot reach the function through CodeAct's disabled channel. File, artifact and network settings remain independent.
|
|
145
|
+
|
|
146
|
+
The setting is captured when building tools. To change it, stop admission through the old tool surface, await or cancel its active calls and complete cleanup, dispose its CodeAct sandboxes, then rebuild and replace the tools and middleware together. Changing the configuration variable alone does not revoke an existing tool. The router refuses reuse of a known sandbox with a different host-tool enablement contract; hosts must also retire old surfaces and instances across processes. This option disables nested calls and does not implement per-host-tool FIDES mediation.
|
|
147
|
+
|
|
113
148
|
## Runtime backends
|
|
114
149
|
|
|
115
150
|
Use `CodeactRuntime` to select `run_code` instead of command execution. The host must verify that the backend evaluates Python statements and returns their output. The required instructions describe the modules and facilities available to the model.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "maf-sandbox-codeact"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.23.0"
|
|
4
4
|
description = "CodeAct as a Microsoft Agent Framework tool — the model writes a short Python program and it runs inside a sandbox — written against maf-sandbox so it runs on any sandbox backend."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12,<3.15"
|
|
@@ -24,8 +24,8 @@ classifiers = [
|
|
|
24
24
|
"Topic :: Software Development :: Interpreters",
|
|
25
25
|
]
|
|
26
26
|
dependencies = [
|
|
27
|
-
"maf-sandbox>=0.
|
|
28
|
-
"agent-framework-core>=1.
|
|
27
|
+
"maf-sandbox>=0.48.0,<0.49",
|
|
28
|
+
"agent-framework-core>=1.20.0,<1.21",
|
|
29
29
|
]
|
|
30
30
|
|
|
31
31
|
[[project.authors]]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "maf-sandbox-codeact"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.23.0"
|
|
4
4
|
description = "CodeAct as a Microsoft Agent Framework tool — the model writes a short Python program and it runs inside a sandbox — written against maf-sandbox so it runs on any sandbox backend."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12,<3.15"
|
|
@@ -35,11 +35,10 @@ dependencies = [
|
|
|
35
35
|
# import, and that one fails at the call, where no import check is looking. The number
|
|
36
36
|
# itself is below, and `scripts/set_dependents_range.py` moves it — so this says which
|
|
37
37
|
# release the floor is for, never which release that is.
|
|
38
|
-
"maf-sandbox>=0.
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
"agent-framework-core>=1.19.0,<1.20",
|
|
38
|
+
"maf-sandbox>=0.48.0,<0.49",
|
|
39
|
+
# MAF 1.20 binds approvals to the issuing session; older minors are excluded.
|
|
40
|
+
# The ceiling admits only the minor covered by the framework-contract tests.
|
|
41
|
+
"agent-framework-core>=1.20.0,<1.21",
|
|
43
42
|
]
|
|
44
43
|
|
|
45
44
|
[project.urls]
|
{maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/src/maf_sandbox_codeact/__init__.py
RENAMED
|
@@ -32,8 +32,8 @@ __all__ = [
|
|
|
32
32
|
"make_codeact_tools",
|
|
33
33
|
]
|
|
34
34
|
|
|
35
|
-
# Experimental package (Beta): importing it emits a
|
|
36
|
-
#
|
|
35
|
+
# Experimental package (Beta): importing it emits a warning, and catches it when
|
|
36
|
+
# `python -W error` promotes it, so such a host can still import the package.
|
|
37
37
|
import warnings as _warnings
|
|
38
38
|
|
|
39
39
|
|
|
@@ -202,6 +202,7 @@ def codeact_sandbox_spec(
|
|
|
202
202
|
files_in: TransferLimits = _DEFAULT_FILES_IN,
|
|
203
203
|
files_out: TransferLimits = _DEFAULT_FILES_OUT,
|
|
204
204
|
host_tools: HostToolRegistry | None = None,
|
|
205
|
+
host_tools_enabled: bool = True,
|
|
205
206
|
egress_allow: Sequence[str | EgressRule] = (),
|
|
206
207
|
runtime: CodeactRuntime | None = None,
|
|
207
208
|
program: ProgramRequirements = ProgramRequirements(),
|
|
@@ -254,6 +255,10 @@ def codeact_sandbox_spec(
|
|
|
254
255
|
one refuses this spec at attach. Reading a registry **seals** it, so ask for the spec once
|
|
255
256
|
everything is registered.
|
|
256
257
|
|
|
258
|
+
``host_tools_enabled=False`` ignores the registry without reading or sealing it.
|
|
259
|
+
Pass ``not fides_enabled`` from trusted host configuration to disable nested calls
|
|
260
|
+
while FIDES is enabled. Rebuild the tools and dispose existing sandboxes when changing it.
|
|
261
|
+
|
|
257
262
|
Raises:
|
|
258
263
|
ValueError: when an ``egress_allow`` host is blank, scheme-qualified, or holds
|
|
259
264
|
whitespace or a comma.
|
|
@@ -265,7 +270,8 @@ def codeact_sandbox_spec(
|
|
|
265
270
|
outputs=outputs,
|
|
266
271
|
files_in=files_in,
|
|
267
272
|
files_out=files_out,
|
|
268
|
-
surface=_host_tools(host_tools),
|
|
273
|
+
surface=_host_tools(_enabled_host_tools(host_tools, host_tools_enabled)),
|
|
274
|
+
host_tools_enabled=host_tools_enabled,
|
|
269
275
|
egress_allow=egress_allow,
|
|
270
276
|
runtime=runtime,
|
|
271
277
|
program=program,
|
|
@@ -285,6 +291,7 @@ def make_codeact_tools(
|
|
|
285
291
|
withhold_guest_output: bool = False,
|
|
286
292
|
outbound_max_confidentiality: str | None = None,
|
|
287
293
|
host_tools: HostToolRegistry | None = None,
|
|
294
|
+
host_tools_enabled: bool = True,
|
|
288
295
|
image: str | None = None,
|
|
289
296
|
image_id: str | None = None,
|
|
290
297
|
exec_timeout_seconds: int = 120,
|
|
@@ -402,6 +409,10 @@ def make_codeact_tools(
|
|
|
402
409
|
answered the sink question, the guest may hand it conversation-derived arguments,
|
|
403
410
|
and every other undeclared leg is read as the worst it could be — so this one is
|
|
404
411
|
too, and the cap above applies.
|
|
412
|
+
host_tools_enabled: Host-only switch, default ``True``. ``False`` ignores the registry
|
|
413
|
+
without reading or sealing it and installs no host-tool channel. Pass
|
|
414
|
+
``not fides_enabled`` from the same configuration that installs FIDES middleware.
|
|
415
|
+
Rebuild the tools and dispose existing sandboxes when changing this setting.
|
|
405
416
|
image: OCI reference of a sandbox image with a Python interpreter on its path.
|
|
406
417
|
image_id: A backend-native disk-image id, skipping resolution.
|
|
407
418
|
exec_timeout_seconds: Execution bound; for ``run_code`` this includes backend queue
|
|
@@ -437,6 +448,7 @@ def make_codeact_tools(
|
|
|
437
448
|
"""
|
|
438
449
|
configured = router is not None and router.enabled
|
|
439
450
|
if configured:
|
|
451
|
+
host_tools = _enabled_host_tools(host_tools, host_tools_enabled)
|
|
440
452
|
_validate_runtime(runtime, takes_files=file_store is not None, outputs=outputs)
|
|
441
453
|
if runtime is not None and host_tools is not None and len(host_tools):
|
|
442
454
|
raise ValueError("CodeAct runtime host tools require a native channel; not supported")
|
|
@@ -516,6 +528,7 @@ def make_codeact_tools(
|
|
|
516
528
|
files_in=files_in,
|
|
517
529
|
files_out=files_out,
|
|
518
530
|
surface=surface,
|
|
531
|
+
host_tools_enabled=host_tools_enabled if configured else True,
|
|
519
532
|
egress_allow=egress_allow if configured else (),
|
|
520
533
|
runtime=runtime if configured else None,
|
|
521
534
|
program=program if configured else ProgramRequirements(),
|
|
@@ -644,6 +657,14 @@ def _validated_hosts(hosts: Sequence[str | EgressRule]) -> tuple[str | EgressRul
|
|
|
644
657
|
return tuple(hosts)
|
|
645
658
|
|
|
646
659
|
|
|
660
|
+
def _enabled_host_tools(
|
|
661
|
+
host_tools: HostToolRegistry | None, enabled: bool
|
|
662
|
+
) -> HostToolRegistry | None:
|
|
663
|
+
if not isinstance(cast(object, enabled), bool):
|
|
664
|
+
raise TypeError("host_tools_enabled must be a bool from trusted host configuration")
|
|
665
|
+
return host_tools if enabled else None
|
|
666
|
+
|
|
667
|
+
|
|
647
668
|
def _host_tools(host_tools: HostToolRegistry | None) -> HostToolAggregate | None:
|
|
648
669
|
"""What a host's registry means for this kind, or ``None`` when nothing is callable.
|
|
649
670
|
|
|
@@ -667,6 +688,7 @@ def _codeact_spec(
|
|
|
667
688
|
files_in: TransferLimits,
|
|
668
689
|
files_out: TransferLimits,
|
|
669
690
|
surface: HostToolAggregate | None,
|
|
691
|
+
host_tools_enabled: bool = True,
|
|
670
692
|
egress_allow: Sequence[str | EgressRule] = (),
|
|
671
693
|
runtime: CodeactRuntime | None = None,
|
|
672
694
|
program: ProgramRequirements = ProgramRequirements(),
|
|
@@ -703,6 +725,11 @@ def _codeact_spec(
|
|
|
703
725
|
if authority:
|
|
704
726
|
requires.add(Capability.ATTACHED_IDENTITY)
|
|
705
727
|
egress = Egress.ALLOWLIST if effective_egress else Egress.CLOSED
|
|
728
|
+
execution_contract = (
|
|
729
|
+
runtime_contract(runtime) if runtime is not None else f"codeact:{program.profile}"
|
|
730
|
+
)
|
|
731
|
+
if not host_tools_enabled:
|
|
732
|
+
execution_contract += ":host-tools-disabled"
|
|
706
733
|
return SandboxSpec(
|
|
707
734
|
kind=CODEACT_KIND,
|
|
708
735
|
image=image,
|
|
@@ -713,9 +740,7 @@ def _codeact_spec(
|
|
|
713
740
|
max_identity_scope=IdentityScope.PER_SANDBOX if authority else None,
|
|
714
741
|
max_identity_retention_seconds=credential_retention_seconds,
|
|
715
742
|
work_dir=runtime.guest_work_dir if runtime is not None else None,
|
|
716
|
-
execution_contract=
|
|
717
|
-
if runtime is not None
|
|
718
|
-
else f"codeact:{program.profile}",
|
|
743
|
+
execution_contract=execution_contract,
|
|
719
744
|
program=program if runtime is None else None,
|
|
720
745
|
# Model-written code can write outside the call path and leave processes running.
|
|
721
746
|
confined_to_guest_call_path=False,
|
|
File without changes
|
{maf_sandbox_codeact-0.22.0 → maf_sandbox_codeact-0.23.0}/src/maf_sandbox_codeact/_runtime.py
RENAMED
|
File without changes
|
|
File without changes
|