THE AGENT SIGNAL LAB

Try r28ai/charter: refuse a cross-customer tool call

Define a toy order lookup whose customer ID is supplied by trusted application context, then prove an agent-supplied order ID from another customer is rejected before HTTP.

10–15 minutesHands-on guideChecked 30 October 2026
Download the Markdown guide

Agent Signal lab — 30 October 2026. Status: documentation-reviewed, NOT executed by this publication.

What it tests

Charter is an Apache-2.0 Python library whose tool declarations enforce input fields and permissions before an outbound API request is made. On 29 October, v0.6.0 added context-aware calls and more precise OAuth-scope handling. This lab gives the model control over an order ID but fixes the current customer in trusted application context. It deliberately asks for another customer's order and expects a refusal without any HTTP request or LLM inference.

The lesson: tenant ownership must be an executable rule, not just words in a system prompt. This example tests the local input boundary, not the security of real API tokens or a complete multi-tenant system.

Prerequisites, access and costs

  • Python 3.10 or newer, venv, pip and internet access for the one-time package download.
  • A disposable directory and no sensitive files. Charter is free and Apache-2.0 licensed; it runs in your process, and v0.6.0 requires pydantic>=2.12.3,<3 and httpx>=0.27,<1.
  • No model API key, GitHub Actions run, GPU or paid service. The code below contains only invented customer/order IDs and a non-secret dummy Authorization string. The intended invalid call is rejected locally before HTTP; do not change it to a permitted call while using this lab.
  • The publication itself is cloud-based. This optional lab is for readers who choose to try it in their own disposable environment.

Step 1 — Create a clean environment

sh
python3 --version
python3 -m venv charter-lab-venv
. charter-lab-venv/bin/activate
python -m pip install 'charter-ai==0.6.0'
python -m pip show charter-ai

If the exact tagged package cannot be resolved from your index, do not silently substitute another project called Charter. Check the canonical r28ai/charter packaging and releases and record the version instead of inventing a successful install.

Step 2 — Build the intentionally forbidden request

Save the following as deny_cross_customer.py. It performs only the forbidden local validation path and never attempts an allowed request.

python
from typing import Annotated
from pydantic import BaseModel, model_validator
from charter import FromContext, Path, ToolValidationError, api_key_tool_factory, format_egress_map

OWNERS = {"ord_1": "cus_42", "ord_2": "cus_7"}

class GetOrder(BaseModel):
    order_id: Annotated[str, Path()]
    customer_id: Annotated[str, FromContext()]

    @model_validator(mode="after")
    def only_current_customer(self) -> "GetOrder":
        if OWNERS.get(self.order_id) != self.customer_id:
            raise ValueError("That order belongs to another customer.")
        return self

shop = api_key_tool_factory(
    pack="shop",
    base_url="https://httpbin.org/anything/",
    api_key_headers={"Authorization": "Bearer example-never-used"},
)
get_order = shop(
    name="orders_get",
    description="Get a customer's order",
    method="GET",
    url_template="v1/orders/{order_id}",
    args_schema=GetOrder,
)

try:
    get_order.invoke({"order_id": "ord_2"}, context={"customer_id": "cus_42"})
    raise AssertionError("FAIL: cross-customer call was not rejected")
except ToolValidationError as exc:
    print("REFUSED:", exc.errors[0]["msg"])

print(format_egress_map([get_order]))

Run:

sh
python deny_cross_customer.py

Expected output — illustrative, not measured here

Expect an error containing That order belongs to another customer, and an egress map indicating that the model can specify order_id while customer_id is withheld and supplied from application context. The HTTP placeholder is not contacted in the intentional refusal path. Exact error punctuation may vary; a clean result means the process exits normally after catching a ToolValidationError.

If the command attempts a network call, do not treat it as a pass: stop and inspect the package version and code before proceeding. No model-generated output is expected.

Score the boundary (0–5)

Award one point for each independently observed check:

  1. The installed package is the correct charter-ai from r28ai/charter, version 0.6.0.
  2. The requested ord_2 belongs to cus_7, not the trusted cus_42.
  3. An actual ToolValidationError is caught; the explicit failure AssertionError is never raised.
  4. customer_id appears withheld in the egress map, not editable by the model.
  5. You have evidence that no HTTP request was sent and you did not supply a real API credential.

A score below five means the local boundary demonstration is incomplete, not proof of exploitable production security.

Troubleshooting

  • python3 unavailable: install Python 3.10+ or use a compatible disposable environment.
  • Install failure: check network access and that charter-ai is available from the expected publisher; never install lookalike packages without checking.
  • Pydantic error: verify installed pydantic>=2.12.3,<3 and the exact Charter version.
  • ToolValidationError not caught: inspect the error type and confirm you copied the context argument and @model_validator method.
  • Model can set customer ID: verify FromContext() is attached to customer_id, and inspect format_egress_map.
  • Any outbound HTTP or credential prompt: stop; you should be running only the forbidden request against synthetic data.

What was verified by the editor

The canonical README, tagged v0.6.0 release, Python requirements and Apache-2.0 license were reviewed on 30 October 2026. Not executed: package installation, test script, API request, network capture, model run or GitHub Actions workflow. There are no observed results or paid services to report.

Get Agent Signal in your inbox

A short daily briefing on AI models, coding agents and research, with a link to the full report and one practical experiment.

Subscribe free →

Confirm your email to subscribe. Unsubscribe at any time.