Skip to content

Python: [Feature]: Python CodeAct fail-closed security coverage for FIDES-protected host tools #9251

Description

Problem

Microsoft Agent Framework provides FIDES information-flow controls for enforcing integrity and confidentiality policies on locally invoked function tools.

However, the Python CodeAct integrations (Monty and Hyperlight) can invoke registered host tools through a lower-level callback path rather than the standard function-middleware pipeline. As documented in the existing implementation, nested host-tool invocations through this path do not receive FIDES per-tool policy enforcement.

PR #9175 introduced registration-time warnings and documentation describing this unsupported integration. That is an important improvement, but the warnings are advisory and do not prevent execution.

This presents a deployment limitation for applications that require mandatory security-policy enforcement:

  • An application can configure FIDES policies for sensitive tools while using a CodeAct execution path that does not enforce those policies on nested host-tool calls.
  • A warning is insufficient for environments where execution must stop when the required policy-enforcement boundary is unavailable.
  • Existing guidance does not provide an explicit fail-closed contract that an application can require for CodeAct host-tool execution.
  • Tool registration and run-scoped tool snapshots introduce additional points where security requirements must remain consistent.

This affects developers building enterprise agents that use generated code to orchestrate sensitive host tools, including tools for accessing internal APIs, customer records, financial workflows, or protected resources.

The request concerns enforcing a documented security configuration requirement. It is not a report of a confirmed vulnerability or a claim that the existing CodeAct integrations promise FIDES protection.

Use Case and Evidence

Enterprise CodeAct agent with sensitive host tools

Consider an enterprise AI agent that uses Monty or Hyperlight to execute model-generated Python code and exposes registered host functions for:

  • Reading customer records
  • Updating internal business systems
  • Accessing confidential documents
  • Making authenticated API requests

The application requires FIDES integrity and confidentiality controls for these functions.

For direct function invocation, the application's configured FIDES middleware can evaluate security policies before tool execution.

For nested host-tool calls originating from CodeAct-generated code, the existing integration uses a different execution path and does not provide equivalent FIDES middleware enforcement.

This creates a practical difficulty: the developer cannot require an explicit runtime guarantee that all CodeAct host-tool executions subject to FIDES requirements will be mediated or rejected.

Repository evidence

PR #9175 — Python: Warn about unsupported FIDES CodeAct tools

#9175

This merged PR documents the compatibility limitation and introduces warnings when recognized FIDES metadata is encountered. The PR explicitly preserves existing invocation behavior.

Relevant implementation areas:

  • python/packages/monty/agent_framework_monty/_execute_code_tool.py
  • python/packages/hyperlight/agent_framework_hyperlight/_execute_code_tool.py
  • python/packages/core/agent_framework/security.py

The existing Monty, Hyperlight and FIDES documentation also describes the limitation.

Why current behavior is insufficient

For a security-sensitive deployment, discovering an unsupported enforcement path through a log warning is not equivalent to preventing unauthorized execution.

The desired guarantee is simple:

When an application explicitly requires FIDES enforcement for CodeAct host tools, unsupported execution paths must not silently proceed.

A narrowly scoped fail-closed behavior would let applications make this requirement explicit and testable.

No exploitation or production incident is claimed. The motivation is the documented enforcement limitation and its implications for mandatory security configurations.

Desired Outcome

Provide an opt-in capability allowing Python applications to require security-policy coverage for CodeAct host-tool execution.

A successful outcome should allow developers to:

  1. Explicitly require FIDES-compatible enforcement for registered CodeAct host tools.
  2. Prevent host-tool execution when the requested enforcement guarantee cannot be provided.
  3. Receive a clear, actionable error identifying the unsupported security-enforcement boundary.
  4. Apply the requirement consistently to initially registered tools, dynamically added tools, and run-scoped tool snapshots.
  5. Preserve current behavior for applications that do not enable the strict security requirement.
  6. Reliably test that denied executions produce no host-tool side effects.

The feature should not imply that sandbox isolation, outer execute_code approval, or registration-time warnings provide per-host-tool FIDES enforcement.

The objective is to prevent an application from unintentionally proceeding with a sensitive CodeAct execution when its explicitly configured security requirement is unsupported.

Alternatives Considered

1. Use existing FIDES registration-time warnings

PR #9175 provides diagnostics for recognized security metadata.

Limitation: Warnings do not prevent execution and may be insufficient when policy enforcement is mandatory. Metadata-based warnings also cannot establish complete enforcement coverage for every possible tool configuration.

2. Avoid CodeAct for security-sensitive tools

Applications can register sensitive operations as ordinary function tools and route them through their existing FIDES middleware configuration.

Limitation: This prevents applications from using CodeAct-based orchestration for workflows involving those operations. It is a valid current workaround but does not provide a strict enforcement mode for CodeAct integrations themselves.

3. Require approval for the outer execute_code operation

Applications can use existing approval mechanisms to authorize a generated-code execution request.

Limitation: Approval of the outer execution does not establish that every nested host-tool invocation receives the intended FIDES integrity and confidentiality checks.

4. Implement application-specific host-tool wrappers

Developers can add authorization checks inside individual host functions.

Limitation: This distributes policy enforcement across application code and does not automatically reproduce FIDES context-label propagation or information-flow semantics.

These approaches remain useful. The proposed feature would add an explicit, optional enforcement guarantee for deployments where advisory compatibility warnings are insufficient.

Proposed Direction

I suggest initially considering a narrowly scoped, opt-in strict-security requirement on the Python CodeAct integrations.

The public API shape should be determined with maintainers.

Conceptually, when strict coverage is enabled:

  • Before an unsupported host-tool execution occurs, the runtime checks whether the required security-enforcement path is available.
  • If enforcement cannot be guaranteed, execution is rejected before the host function runs.
  • The requirement comes from trusted application configuration, not model-generated code or arguments.
  • Dynamic tool registration and run-scoped configuration cannot weaken the requirement.
  • The runtime provides a clear failure reason without exposing sensitive tool arguments.
  • Without strict coverage enabled, existing behavior remains unchanged.

The initial implementation does not need to reproduce the entire FIDES middleware inside Monty or Hyperlight.

A first phase could provide a reliable fail-closed barrier for unsupported host-tool execution. A future phase could explore supporting actual per-host-tool FIDES mediation if maintainers consider that architecture appropriate.

I would welcome maintainer guidance on whether this belongs in the CodeAct provider configuration, a shared security-capability contract, or another existing extension point.

Scope and Non-Goals

In scope

  • Python Monty and Hyperlight CodeAct integrations
  • Opt-in fail-closed handling of unsupported FIDES coverage
  • Enforcement consistency across initial and dynamic tool registration
  • Run-scoped tool configuration and execution checks
  • Deterministic tests verifying rejection before host-tool side effects
  • Clear compatibility documentation and an example demonstrating strict versus existing behavior

Non-goals

  • Replacing or redesigning FIDES
  • Introducing a separate agent security framework
  • Claiming complete prompt-injection prevention
  • Automatically enabling strict behavior for existing applications
  • Changing the existing security guarantees of Monty or Hyperlight sandboxes
  • Automatically propagating all middleware into generated-code callbacks
  • Changing remote/provider-hosted tool execution
  • Implementing the same feature in .NET as part of the initial contribution

The goal is a small, backward-compatible security capability focused on making an existing enforcement limitation explicitly controllable by application developers.

Language

Python

Contribution Intent

I am willing to implement this

Acknowledgements

  • I searched existing issues and did not find a duplicate.
  • I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 10, 2026
  2. changed the title [-][Feature]: Python CodeAct fail-closed security coverage for FIDES-protected host tools[/-] [+]Python: [Feature]: Python CodeAct fail-closed security coverage for FIDES-protected host tools[/+] on Oct 10, 2026
  3. added
    skillsUsage: [Issues, PRs], Target: skills related features
    on Oct 10, 2026
  4. removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 10, 2026
  5. eavanvalkenburg commented on Oct 12, 2026

    @eavanvalkenburg
    Member

    /plan

  6. github-actions commented on Oct 12, 2026

    @github-actions
    Contributor

    Summary

    The issue asks that the Python CodeAct integrations (Monty and Hyperlight) get an opt-in "fail-closed" mode: when an application explicitly requires FIDES (the framework's per-tool information-flow security policy) coverage for host tools, registering or running a tool that CodeAct can't enforce FIDES on should raise an error instead of just logging a warning.

    I checked how things work today:

    • Both python/packages/monty/agent_framework_monty/_execute_code_tool.py (around line 278) and python/packages/hyperlight/agent_framework_hyperlight/_execute_code_tool.py (around line 1627) already detect FIDES-related keys on a registered tool's metadata (e.g. source_integrity, confidentiality, standing_guidance) in add_tools(). Today this only produces a logger.warning(...) — execution is never blocked.
    • add_tools() is the single choke point used by the constructor, dynamic add_tools() calls, and create_run_tool() (the run-scoped snapshot used by MontyCodeActProvider/HyperlightCodeActProvider). So a stricter check placed there would automatically apply to initial registration, dynamic registration, and run-scoped snapshots, which is one of the issue's explicit requirements.
    • The Monty README and the FIDES developer guide already document this as an unsupported combination and recommend keeping FIDES-governed tools as direct agent tools instead of CodeAct-managed tools — this is a real, usable workaround today, but (as the issue says) it's a workaround, not a way to make the requirement itself enforced and testable.

    I did not look at PR #9290 (closed, linked to this issue) to form this recommendation, per the investigation instructions.

    Recommendation

    Code changes are warranted, but the change should stay narrow and registration-time (not an attempt to replicate FIDES's full per-call label tracking inside Monty/Hyperlight, which the issue itself marks a non-goal). The existing advisory warning is real evidence that the gap is known and accepted by maintainers as a current limitation; it's reasonable for applications that want a hard guarantee to need a way to say "fail me here, don't just log."

    Since the FIDES-key check already lives in one shared place (add_tools) that every registration path funnels through, turning that warning into an opt-in hard error is a small, low-risk, backward-compatible change — not a redesign.

    Proposed plan

    1. Add an opt-in, keyword-only constructor flag (e.g. require_fides_coverage: bool = False) to MontyExecuteCodeTool and HyperlightExecuteCodeTool, and thread it through to their respective providers (MontyCodeActProvider, HyperlightCodeActProvider). Default stays False so existing behavior (warn-only) is unchanged for everyone who doesn't opt in.
    2. In the shared add_tools() check, when the flag is enabled and a tool carries any of the recognized FIDES metadata keys, raise a clear exception (e.g. ValueError) naming the tool and the offending keys, instead of (or in addition to) logging. This must happen before the tool is added to _managed_tools, so no call can ever reach it.
    3. Make sure create_run_tool() passes the flag through to the new run-scoped instance, so a run-scoped snapshot can't silently drop the requirement — this directly covers the issue's "dynamically added tools and run-scoped snapshots" requirement.
    4. Tests in test_monty_codeact.py and test_hyperlight_codeact.py:
      • Registering a FIDES-tagged tool with the flag on raises before any tool call can happen (and that no host-tool side effect occurs).
      • Registering a FIDES-tagged tool with the flag off keeps today's warn-and-continue behavior.
      • The flag is enforced consistently through constructor tools=, add_tools(), and create_run_tool().
      • Non-FIDES-tagged tools are unaffected either way.
    5. Update the Monty/Hyperlight READMEs' "FIDES compatibility" sections and the FIDES developer guide to describe the new opt-in flag, being explicit that it's a registration-time fail-closed barrier, not per-call FIDES mediation inside generated code (matching the issue's own non-goals).

    You'd know this is resolved when an application can set the new flag, attempt to register (or dynamically add, or get a run-scoped snapshot containing) a FIDES-tagged tool on a CodeAct provider, and reliably get a raised error with no host-tool execution — while existing applications that don't set the flag see no behavior change.

    This is a proposal only; no code has been changed.

    Generated by Issue Planning for #9251 · copilot · auto · 64.1 AIC · ⌖ 6 AIC · ⊞ 10.8K · ◷

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

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: PythonskillsUsage: [Issues, PRs], Target: skills related features

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions