[GH-ISSUE #2787] Docs request: add AECP secure tool execution how-to (moved from langchain-ai/langchain#35413) #2682

Open
opened 2026-06-05 17:26:16 -04:00 by yindo · 3 comments
Owner

Originally created by @PetrefiedThunder on GitHub (Feb 24, 2026).
Original GitHub issue: https://github.com/langchain-ai/docs/issues/2787

Context

This request was originally submitted as a docs-only PR in langchain-ai/langchain#35413 and was closed with guidance to open it in this docs repository.

What I’m trying to do

Add a short how-to page showing safe-by-default LangChain tool execution with delegated authority, budget constraints, and fail-closed behavior.

Why this is needed

Tool calls can trigger side effects (payments, external actions), but many examples focus on invocation mechanics and not production safety controls. A small, practical guide would help teams demonstrate:

  • pre-execution authorization,
  • budget-aware denial,
  • verifiable execution receipts/audit trail.

Proposed docs addition

A single runnable example that wraps a @tool using AECP via wrap_tool + AECPToolConfig, then demonstrates:

  1. one authorized invocation,
  2. one denied invocation due to budget,
  3. fail-closed behavior (tool not executed on deny).

Suggested structure

  • Page title: Secure tool execution with delegated authority and budget limits
  • Audience: Teams deploying tool-using agents in production
  • Sections:
    1. Problem statement (side effects + safety requirements)
    2. Minimal setup/env vars
    3. Runnable example
    4. Expected output (allow then deny)
    5. Operational notes (authorization-before-execution, signed receipts, tamper-evident audit chain)

Example snippet

import os
from aecp_langchain import AECPToolConfig, wrap_tool
from aecp_sdk import AuthorizationDenied
from langchain_core.tools import tool

@tool
def charge_customer(customer_id: str, amount_cents: int) -> dict:
    return {"status": "charged", "customer_id": customer_id, "amount_cents": amount_cents}

secure_charge = wrap_tool(
    charge_customer,
    AECPToolConfig(
        base_url=os.environ["AECP_BASE_URL"],
        delegation_token=os.environ["AECP_DELEGATION_TOKEN"],
        tool_id="tool.billing.charge",
        cost_estimate_fn=lambda args, kwargs: 1,
        action_fn=lambda args, kwargs: "charge_customer",
    ),
)

try:
    print(secure_charge.invoke({"customer_id": "cus_123", "amount_cents": 1}))  # allowed
    print(secure_charge.invoke({"customer_id": "cus_123", "amount_cents": 1}))  # denied
except AuthorizationDenied as exc:
    print(f"fail-closed deny: {exc}")

References

Originally created by @PetrefiedThunder on GitHub (Feb 24, 2026). Original GitHub issue: https://github.com/langchain-ai/docs/issues/2787 ### Context This request was originally submitted as a docs-only PR in `langchain-ai/langchain#35413` and was closed with guidance to open it in this docs repository. ### What I’m trying to do Add a short how-to page showing safe-by-default LangChain tool execution with delegated authority, budget constraints, and fail-closed behavior. ### Why this is needed Tool calls can trigger side effects (payments, external actions), but many examples focus on invocation mechanics and not production safety controls. A small, practical guide would help teams demonstrate: - pre-execution authorization, - budget-aware denial, - verifiable execution receipts/audit trail. ### Proposed docs addition A single runnable example that wraps a `@tool` using AECP via `wrap_tool` + `AECPToolConfig`, then demonstrates: 1. one authorized invocation, 2. one denied invocation due to budget, 3. fail-closed behavior (tool not executed on deny). ### Suggested structure - **Page title:** Secure tool execution with delegated authority and budget limits - **Audience:** Teams deploying tool-using agents in production - **Sections:** 1. Problem statement (side effects + safety requirements) 2. Minimal setup/env vars 3. Runnable example 4. Expected output (allow then deny) 5. Operational notes (authorization-before-execution, signed receipts, tamper-evident audit chain) ### Example snippet ```python import os from aecp_langchain import AECPToolConfig, wrap_tool from aecp_sdk import AuthorizationDenied from langchain_core.tools import tool @tool def charge_customer(customer_id: str, amount_cents: int) -> dict: return {"status": "charged", "customer_id": customer_id, "amount_cents": amount_cents} secure_charge = wrap_tool( charge_customer, AECPToolConfig( base_url=os.environ["AECP_BASE_URL"], delegation_token=os.environ["AECP_DELEGATION_TOKEN"], tool_id="tool.billing.charge", cost_estimate_fn=lambda args, kwargs: 1, action_fn=lambda args, kwargs: "charge_customer", ), ) try: print(secure_charge.invoke({"customer_id": "cus_123", "amount_cents": 1})) # allowed print(secure_charge.invoke({"customer_id": "cus_123", "amount_cents": 1})) # denied except AuthorizationDenied as exc: print(f"fail-closed deny: {exc}") ``` ### References - Original PR: https://github.com/langchain-ai/langchain/pull/35413 - AECP README: https://github.com/PetrefiedThunder/aecp#readme - AECP trust verification guide: https://github.com/PetrefiedThunder/aecp/blob/main/docs/TRUST.md
yindo added the external label 2026-06-05 17:26:16 -04:00
Author
Owner

@PetrefiedThunder commented on GitHub (Feb 24, 2026):

Opened draft PR for this request: https://github.com/langchain-ai/docs/pull/2789\n\nIncludes a new page and nav entry under LangChain Python core components.

<!-- gh-comment-id:3953702219 --> @PetrefiedThunder commented on GitHub (Feb 24, 2026): Opened draft PR for this request: https://github.com/langchain-ai/docs/pull/2789\n\nIncludes a new page and nav entry under LangChain Python core components.
Author
Owner

@PetrefiedThunder commented on GitHub (Feb 24, 2026):

Opened draft PR for this request: https://github.com/langchain-ai/docs/pull/2789\n\nIncludes a new secure tool execution page and a navigation entry under Open source -> Python -> LangChain -> Core components.

<!-- gh-comment-id:3953702857 --> @PetrefiedThunder commented on GitHub (Feb 24, 2026): Opened draft PR for this request: https://github.com/langchain-ai/docs/pull/2789\n\nIncludes a new secure tool execution page and a navigation entry under Open source -> Python -> LangChain -> Core components.
Author
Owner

@PetrefiedThunder commented on GitHub (Feb 24, 2026):

Friendly follow-up here as well: the implementation PR is ready at https://github.com/langchain-ai/docs/pull/2789 and checks are passing. If there is a preferred section/location for this page, I can adjust it quickly.

<!-- gh-comment-id:3956347193 --> @PetrefiedThunder commented on GitHub (Feb 24, 2026): Friendly follow-up here as well: the implementation PR is ready at https://github.com/langchain-ai/docs/pull/2789 and checks are passing. If there is a preferred section/location for this page, I can adjust it quickly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#2682