Private Data
Pass private values to tools, restore placeholders, and use RedactedMessage.
Privacy control, not certification
mAIvn holds no SOC 2, HIPAA, ISO 27001, or FedRAMP certification. The Platform Disclaimer explains what these controls do not cover.
#Private Data
Redaction aids, not compliance.phi_modeandHIPAA_SAFE_HARBOR_CATEGORIESare redaction aids. Using them does not make a deployment compliant with health-privacy law, and the hosted Service does not accept protected health information without a separate signed agreement; see the Acceptable Use Policy. mAIvn holds no SOC 2, HIPAA, ISO 27001, or FedRAMP certification, and cannot guarantee that every private value is detected. These controls do not replace required audits and organizational safeguards.
Examples of private-data injection and runtime redaction. Replace the example credentials and API keys before you run them. Injection keeps declared values out of model arguments. Automatic PII detection is an additional, fallible control.
#@depends_on_private_data — inject without disclosure
The injected argument is hidden from the model-facing argument schema. The runtime supplies its value just before calling the tool:
from maivn import Agent, depends_on_private_data
from maivn.messages import HumanMessage
agent = Agent(name='Account Briefing Agent', system_prompt='...', api_key='...')
@depends_on_private_data(arg_name='account_id', data_key='account_id')
@depends_on_private_data(arg_name='customer_name', data_key='customer_name')
@agent.toolify(name='account_briefing', final_tool=True)
def account_briefing(account_id: str, customer_name: str) -> dict:
return {
'account_id': account_id,
'customer_name': customer_name,
'plan': 'pro',
'status': 'active',
}
agent.private_data = {
'account_id': 'ACCT-91024',
'customer_name': 'Northwind Medical',
}
agent.invoke([HumanMessage(content='Pull the account briefing.')])Multiple keys can be injected into the same tool. The values are never serialized into the model's view of the conversation.
#Build the final response inside a tool
For a greeting that contains private values, inject those values into a final tool and construct the response there. Merely mentioning a private-data key in model-written prose is not a supported substitution contract.
greeter = Agent(name='Customer Success Assistant', api_key='...')
@depends_on_private_data(arg_name='customer_name', data_key='customer_name')
@depends_on_private_data(arg_name='account_id', data_key='account_id')
@greeter.toolify(final_tool=True)
def welcome_customer(customer_name: str, account_id: str) -> dict:
return {'message': f'Welcome, {customer_name}. Your account is {account_id}.'}
greeter.private_data = {'customer_name': 'Acme Co', 'account_id': 'ACCT-77342'}
response = greeter.invoke(
HumanMessage(content='Welcome the customer.'), force_final_tool=True,
)
print(response.result)The final result contains the private values for the recipient. Apply your application's access controls before displaying or storing it.
#RedactedMessage — redact incoming messages
When the user's message contains sensitive content that you don't want the LLM to see, wrap it in a RedactedMessage. This requests runtime PII detection and replacement before model processing. It does not redact the message locally before sending it to the mAIvn service:
from maivn.messages import RedactedMessage
response = agent.invoke(
[RedactedMessage(content=(
'Please look up case CASE-2026-7781 for dana.lee@example.com '
'(phone +1-415-555-0199) and acknowledge receipt.'
))],
)PII detection covers email, phone, SSN, credit cards, IP addresses, and several other categories out of the box, each paired with a structural check to reduce false positives. Detected values are held within the runtime and substituted back only where it's safe to do so (e.g. inside the final tool's structured output, not in the free-form LLM trace). Detection is a safety net, not a guarantee — pair it with @depends_on_private_data and known_pii_values for values you already know are sensitive.
#Tool-result PII protection
The runtime also checks tool results for private values and detected PII before model processing. Detection can miss values, so explicitly register known secrets rather than relying on a pattern match:
from maivn.messages import RedactedMessage
profile_agent = Agent(name='Contact confirmation', api_key='...')
@profile_agent.toolify(name='fetch_customer_profile')
def fetch_customer_profile(case_id: str) -> dict:
# Simulated DB row — these values were NOT in the user message
return {
'case_id': case_id,
'customer_name': 'Dana Lee',
'email': 'dana.lee@example.com',
'phone': '+1 (415) 555-0199',
'ssn': '321-54-9876',
}
@profile_agent.toolify(name='confirm_contact', final_tool=True)
def confirm_contact(case_id: str, confirmation_note: str) -> dict:
return {'case_id': case_id, 'confirmation_note': confirmation_note, 'status': 'ok'}
response = profile_agent.invoke([RedactedMessage(content=(
'Look up case CASE-2026-7781 and acknowledge receipt. In the '
'confirmation_note, include the email and phone from the lookup.'
))])The email and phone returned by fetch_customer_profile are detected by the runtime, masked when the next LLM turn sees them, but substituted back into the final tool's arguments and the user-facing response — so the round trip works end-to-end without leaking raw PII into the model's intermediate reasoning.
#Known PII values — explicit list
If you have values you know are sensitive (and might not match the auto-detector's categories), declare them up front on the RedactedMessage via known_pii_values:
from maivn.messages import RedactedMessage
response = agent.invoke([
RedactedMessage(
content='Acknowledge receipt and reference the internal case.',
known_pii_values=[
'INTERNAL-CASE-7782',
'project-coastal-shield-rev2',
],
),
])known_pii_values accepts raw strings as well as PrivateData descriptors. These get the same treatment as auto-detected PII — masked in the LLM context, substituted back only in safe spots.
#Keep values across turns
Values you pass in private_data are remembered per thread_id, so later turns on the same thread don't need to repeat them. Persistence needs an explicit thread. The default is an encrypted local vault. Pass a store to choose where the values live:
from maivn import Client, InMemoryPrivateDataStore, RunOptions
client = Client(api_key='...', private_data_store=InMemoryPrivateDataStore())
options = RunOptions(thread_id='serial-support')
client.invoke('Use my serial number to check the warranty.', options=options,
private_data={'serial_number': 'SN-8831'})
client.invoke('Check the same serial again.', options=options) # value is re-sent for you
client.forget_private_data('serial-support') # delete the saved valuesInMemoryPrivateDataStore keeps values for the life of the process. For a durable store you control, use EncryptedFilePrivateDataStore(path, secret). See Choosing a store.
#Preview what the model will receive
Client.preview_redaction() shows the redacted text and covered pages before any model call. Run on the approved copy only after you have reviewed it:
from maivn import Client, RunOptions
client = Client(api_key='...')
preview = client.preview_redaction(
'Summarize the case for Dana Lee, dana.lee@example.com.',
)
for item in preview.items:
print(item.key, item.pii_type, item.source)
response = client.invoke(
preview.approved_messages(),
options=RunOptions(redaction_preview_id=preview.preview_id),
)The call waits up to 300 seconds by default. When an agent or swarm has a system_prompt, preview through it with agent.preview_redaction(...) and run with agent.invoke(...): the scope method includes the system prompt, so the approved copy matches the run. A bare HTTP 503 from a preview, review_redaction or approve_redaction means the project's vault, tenant keys or key custody are not configured. See Preview redaction for the response fields and the checks that reject a changed copy.
#What's next
- Private Data guide — the deeper treatment, including the whitelist model and how access to private values is tracked.
- Memory — combining memory retrieval with private-data workflows.