Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a241a42
initial work on code_mode
eavanvalkenburg Mar 18, 2026
492401d
updated samples
eavanvalkenburg Mar 23, 2026
9f8eada
updates to codeact
eavanvalkenburg Mar 23, 2026
988d4a9
udpated codeact
eavanvalkenburg Mar 24, 2026
ec16c12
Draft CodeAct ADR and sample updates
eavanvalkenburg Apr 7, 2026
3d168ff
initial implementation and adr and feature
eavanvalkenburg Apr 9, 2026
8dddecc
Python: Limit Hyperlight wasm backend to Python <3.14
eavanvalkenburg Apr 9, 2026
8d70aff
Python: Fix CI for Hyperlight CodeAct PR
eavanvalkenburg Apr 9, 2026
4f77938
Python: Run Hyperlight integration when available
eavanvalkenburg Apr 9, 2026
d959537
Python: Address Hyperlight review feedback
eavanvalkenburg Apr 9, 2026
779ff14
Python: Simplify Hyperlight file mount inputs
eavanvalkenburg Apr 9, 2026
003b5f2
Python: Accept Path host paths in Hyperlight mounts
eavanvalkenburg Apr 9, 2026
e296d61
Python: Fix Hyperlight mount typing for CI
eavanvalkenburg Apr 9, 2026
66e5028
temp run integration test
eavanvalkenburg Apr 10, 2026
f880d2c
Python: Strengthen Hyperlight real sandbox tests
eavanvalkenburg Apr 10, 2026
f5cb9ea
added additional tests
eavanvalkenburg Apr 10, 2026
1763ebf
Python: Simplify Hyperlight CodeAct API
eavanvalkenburg Apr 10, 2026
07d0b9e
set tests as non-integration
eavanvalkenburg Apr 13, 2026
83fe46d
Retry Hyperlight allowed-domain registration
eavanvalkenburg Apr 14, 2026
bbb8416
Gate Hyperlight integration tests by runtime support
eavanvalkenburg Apr 14, 2026
c055acd
Fix Hyperlight skip test on Python 3.14
eavanvalkenburg Apr 14, 2026
85d8e7f
Delay Hyperlight runtime probe until test execution
eavanvalkenburg Apr 14, 2026
2380fc8
Relax Hyperlight Windows integration stdout assertion
eavanvalkenburg Apr 14, 2026
bf56d12
Scan Hyperlight output directory for artifacts
eavanvalkenburg Apr 14, 2026
7cf4091
Retry Hyperlight output artifact collection
eavanvalkenburg Apr 14, 2026
771d763
Harden Hyperlight integration output assertions
eavanvalkenburg Apr 14, 2026
9f99e03
Retry Hyperlight read-back check in integration test
eavanvalkenburg Apr 14, 2026
21615b6
Simplify Hyperlight integration write assertion
eavanvalkenburg Apr 14, 2026
2d9544b
Avoid pathlib in Hyperlight integration sandbox
eavanvalkenburg Apr 14, 2026
582bf97
Use socket network check in Hyperlight sandbox
eavanvalkenburg Apr 14, 2026
be61f6f
Replace blocked Azure AI Search blog link
eavanvalkenburg Apr 14, 2026
54f1b3a
Clarify Hyperlight guest stdlib limits
eavanvalkenburg Apr 14, 2026
d25bf1f
Use _socket in Hyperlight integration sandbox
eavanvalkenburg Apr 14, 2026
7cf71c2
Handle Hyperlight mounted file paths
eavanvalkenburg Apr 14, 2026
dafdd21
Broaden Hyperlight sandbox path fallbacks
eavanvalkenburg Apr 14, 2026
55f7403
Search Hyperlight guest mounts recursively
eavanvalkenburg Apr 14, 2026
32244b1
Split Hyperlight mount coverage
eavanvalkenburg Apr 14, 2026
92eaad2
Split Hyperlight live network tests
eavanvalkenburg Apr 14, 2026
f3dbd8c
Fix Hyperlight file-write test on Windows
eavanvalkenburg Apr 14, 2026
88efc1e
Address PR review: ADR intro, manual wiring sample, doc clarifications
eavanvalkenburg Apr 15, 2026
5beb891
Address PR #5185 review comments and add .NET CodeAct design doc
eavanvalkenburg Apr 16, 2026
483ecfa
Update hyperlight README with code snippets and remove Public API sec…
eavanvalkenburg Apr 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/python-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:
--timeout=120 --session-timeout=900 --timeout_method thread
--retries 2 --retry-delay 5

# Misc integration tests (Anthropic, Ollama, MCP)
# Misc integration tests (Anthropic, Hyperlight, Ollama, MCP)
python-tests-misc-integration:
name: Python Integration Tests - Misc
runs-on: ubuntu-latest
Expand Down Expand Up @@ -162,10 +162,11 @@ jobs:
fallback_url: ${{ env.LOCAL_MCP_URL }}
- name: Prefer local MCP URL when available
run: echo "LOCAL_MCP_URL=${{ steps.local-mcp.outputs.effective_url }}" >> "$GITHUB_ENV"
- name: Test with pytest (Anthropic, Ollama, MCP integration)
- name: Test with pytest (Anthropic, Hyperlight, Ollama, MCP integration)
run: >
uv run pytest --import-mode=importlib
packages/anthropic/tests
packages/hyperlight/tests
packages/ollama/tests
packages/core/tests/core/test_mcp.py
-m integration
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/python-merge-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
- 'python/samples/**/providers/azure/**'
misc:
- 'python/packages/anthropic/**'
- 'python/packages/hyperlight/**'
- 'python/packages/ollama/**'
- 'python/packages/core/agent_framework/_mcp.py'
- 'python/packages/core/tests/core/test_mcp.py'
Expand Down Expand Up @@ -278,10 +279,11 @@ jobs:
fallback_url: ${{ env.LOCAL_MCP_URL }}
- name: Prefer local MCP URL when available
run: echo "LOCAL_MCP_URL=${{ steps.local-mcp.outputs.effective_url }}" >> "$GITHUB_ENV"
- name: Test with pytest (Anthropic, Ollama, MCP integration)
- name: Test with pytest (Anthropic, Hyperlight, Ollama, MCP integration)
run: >
uv run pytest --import-mode=importlib
packages/anthropic/tests
packages/hyperlight/tests
packages/ollama/tests
packages/core/tests/core/test_mcp.py
-m integration
Expand Down
233 changes: 233 additions & 0 deletions docs/decisions/0024-codeact-integration.md

Large diffs are not rendered by default.

625 changes: 625 additions & 0 deletions docs/features/code_act/dotnet-implementation.md

Large diffs are not rendered by default.

385 changes: 385 additions & 0 deletions docs/features/code_act/python-implementation.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions python/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"azuredocs",
"azurefunctions",
"boto",
"codeact",
"contentvector",
"contoso",
"datamodel",
Expand All @@ -45,6 +46,7 @@
"hnsw",
"httpx",
"huggingface",
"hyperlight",
"Instrumentor",
"logit",
"logprobs",
Expand Down
1 change: 1 addition & 0 deletions python/PACKAGE_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Status is grouped into these buckets:
| `agent-framework-foundry-local` | `python/packages/foundry_local` | `beta` |
| `agent-framework-gemini` | `python/packages/gemini` | `alpha` |
| `agent-framework-github-copilot` | `python/packages/github_copilot` | `beta` |
| `agent-framework-hyperlight` | `python/packages/hyperlight` | `alpha` |
| `agent-framework-lab` | `python/packages/lab` | `beta` |
| `agent-framework-mem0` | `python/packages/mem0` | `beta` |
| `agent-framework-ollama` | `python/packages/ollama` | `beta` |
Expand Down
9 changes: 5 additions & 4 deletions python/packages/core/agent_framework/_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
DEFAULT_MAX_ITERATIONS: Final[int] = 40
DEFAULT_MAX_CONSECUTIVE_ERRORS_PER_REQUEST: Final[int] = 3
SHELL_TOOL_KIND_VALUE: Final[str] = "shell"
ApprovalMode: TypeAlias = Literal["always_require", "never_require"]
ChatClientT = TypeVar("ChatClientT", bound="SupportsChatGetResponse[Any]")
ResponseModelBoundT = TypeVar("ResponseModelBoundT", bound=BaseModel)

Expand Down Expand Up @@ -270,7 +271,7 @@ def __init__(
*,
name: str,
description: str = "",
approval_mode: Literal["always_require", "never_require"] | None = None,
approval_mode: ApprovalMode | None = None,
kind: str | None = None,
max_invocations: int | None = None,
max_invocation_exceptions: int | None = None,
Expand Down Expand Up @@ -1030,7 +1031,7 @@ def tool(
name: str | None = None,
description: str | None = None,
schema: type[BaseModel] | Mapping[str, Any] | None = None,
approval_mode: Literal["always_require", "never_require"] | None = None,
approval_mode: ApprovalMode | None = None,
kind: str | None = None,
max_invocations: int | None = None,
max_invocation_exceptions: int | None = None,
Expand All @@ -1046,7 +1047,7 @@ def tool(
name: str | None = None,
description: str | None = None,
schema: type[BaseModel] | Mapping[str, Any] | None = None,
approval_mode: Literal["always_require", "never_require"] | None = None,
approval_mode: ApprovalMode | None = None,
kind: str | None = None,
max_invocations: int | None = None,
max_invocation_exceptions: int | None = None,
Expand All @@ -1061,7 +1062,7 @@ def tool(
name: str | None = None,
description: str | None = None,
schema: type[BaseModel] | Mapping[str, Any] | None = None,
approval_mode: Literal["always_require", "never_require"] | None = None,
approval_mode: ApprovalMode | None = None,
kind: str | None = None,
max_invocations: int | None = None,
max_invocation_exceptions: int | None = None,
Expand Down
21 changes: 21 additions & 0 deletions python/packages/hyperlight/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
132 changes: 132 additions & 0 deletions python/packages/hyperlight/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# agent-framework-hyperlight

Alpha Hyperlight-backed CodeAct integrations for Microsoft Agent Framework.

## Installation

```bash
pip install agent-framework-hyperlight --pre
```

This package depends on `hyperlight-sandbox`, the packaged Python guest, and the
Wasm backend package on supported platforms. If the backend is not published for
your current platform yet, `execute_code` will fail at runtime when it tries to
create the sandbox.

## Quick start

### Context provider (recommended)

Use `HyperlightCodeActProvider` to automatically inject the `execute_code` tool
and CodeAct instructions into every agent run. Tools registered on the provider
are available inside the sandbox via `call_tool(...)` but are **not** exposed as
direct agent tools.

```python
from agent_framework import Agent, tool
from agent_framework_hyperlight import HyperlightCodeActProvider

@tool
def compute(operation: str, a: float, b: float) -> float:
"""Perform a math operation."""
ops = {"add": a + b, "subtract": a - b, "multiply": a * b, "divide": a / b}
return ops[operation]

codeact = HyperlightCodeActProvider(
tools=[compute],
approval_mode="never_require",
)

agent = Agent(
client=client,
name="CodeActAgent",
instructions="You are a helpful assistant.",
context_providers=[codeact],
)

result = await agent.run("Multiply 6 by 7 using execute_code.")
```

### Standalone tool

Use `HyperlightExecuteCodeTool` directly when you want full control over how the
tool is added to the agent. This is useful when mixing sandbox tools with
direct-only tools on the same agent.

```python
from agent_framework import Agent, tool
from agent_framework_hyperlight import HyperlightExecuteCodeTool

@tool
def send_email(to: str, subject: str, body: str) -> str:
"""Send an email (direct-only, not available inside the sandbox)."""
return f"Email sent to {to}"

execute_code = HyperlightExecuteCodeTool(
tools=[compute],
approval_mode="never_require",
)

agent = Agent(
client=client,
name="MixedToolsAgent",
instructions="You are a helpful assistant.",
tools=[send_email, execute_code],
)
```

### Manual static wiring

For fixed configurations where provider lifecycle overhead is unnecessary, build
the CodeAct instructions once and pass them to the agent at construction time:

```python
execute_code = HyperlightExecuteCodeTool(
tools=[compute],
approval_mode="never_require",
)

codeact_instructions = execute_code.build_instructions(tools_visible_to_model=False)

agent = Agent(
client=client,
name="StaticWiringAgent",
instructions=f"You are a helpful assistant.\n\n{codeact_instructions}",
tools=[execute_code],
)
```

### File mounts and network access

Mount host directories into the sandbox and allow outbound HTTP to specific
domains:

```python
from agent_framework_hyperlight import HyperlightCodeActProvider, FileMount

codeact = HyperlightCodeActProvider(
tools=[compute],
file_mounts=[
"/host/data", # shorthand — same path in sandbox
("/host/models", "/sandbox/models"), # explicit host → sandbox mapping
FileMount("/host/config", "/sandbox/config"), # named tuple
],
allowed_domains=[
"api.github.com", # all methods
("internal.api.example.com", "GET"), # GET only
],
)
```

## Notes

- This package is intentionally separate from `agent-framework-core` so CodeAct
usage and installation remain optional.
- Alpha-package samples live under `packages/hyperlight/samples/`.
- `file_mounts` accepts a single string shorthand, an explicit `(host_path,
mount_path)` pair, or a `FileMount` named tuple. The host-side path in the
explicit forms may be a `str` or `Path`. Use the explicit two-value form when
the host path differs from the sandbox path.
- `allowed_domains` accepts a single string target such as `"github.com"` to
allow all backend-supported methods, an explicit `(target, method_or_methods)`
tuple such as `("github.com", "GET")`, or an `AllowedDomain` named tuple.
24 changes: 24 additions & 0 deletions python/packages/hyperlight/agent_framework_hyperlight/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) Microsoft. All rights reserved.

from __future__ import annotations

import importlib.metadata

from ._execute_code_tool import HyperlightExecuteCodeTool
from ._provider import HyperlightCodeActProvider
from ._types import AllowedDomain, AllowedDomainInput, FileMount, FileMountInput

try:
__version__ = importlib.metadata.version(__name__)
except importlib.metadata.PackageNotFoundError:
__version__ = "0.0.0"

__all__ = [
"AllowedDomain",
"AllowedDomainInput",
"FileMount",
"FileMountInput",
"HyperlightCodeActProvider",
"HyperlightExecuteCodeTool",
"__version__",
]
Loading
Loading