Problem
Teams building SaaS products on top of AI agents need to isolate traces, costs, and audit logs per customer. Today agent-trace has no concept of tenancy - all sessions land in the same store with no customer-level separation.
This matters for:
- Cost attribution: "how much did running agents for customer X cost this month?"
- Data isolation: customer A's trace data must not be accessible when querying for customer B
- GDPR compliance: "delete all data for customer X" must be possible and auditable
Proposed solution
A --tenant-id flag on watch and hooks that tags all events with a customer identifier, plus tenant-scoped query and export commands.
Tagging sessions
# Tag a session with a tenant ID at watch time
agent-strace watch --tenant-id customer-acme
# Or via environment variable (for CI/automated agents)
AGENT_STRACE_TENANT_ID=customer-acme python my_agent.py
All events in the session are tagged with tenant_id: customer-acme in the NDJSON store.
Querying by tenant
# List sessions for a specific customer
agent-strace list --tenant customer-acme
# Cost report for one customer
agent-strace cost --tenant customer-acme --since 30d
# Full session history for a customer (GDPR subject access request)
agent-strace tenant export customer-acme --format json
# Delete all data for a customer (GDPR right to erasure)
agent-strace tenant delete customer-acme --confirm
Tenant cost rollup
agent-strace tenant report --month 2026-06
Tenant cost report - June 2026
──────────────────────────────────────────────────────
Tenant Sessions Cost % of total
──────────────────────────────────────────────────────
customer-acme 142 $38.21 21.2%
customer-beta 89 $24.18 13.4%
customer-gamma 201 $61.44 34.1%
customer-delta 67 $18.92 10.5%
(untagged) 108 $37.74 20.9%
──────────────────────────────────────────────────────
Total 607 $180.49
Tenant-scoped API keys (hosted collector)
When using the hosted collector, tenant isolation is enforced server-side:
- Each API key is scoped to one org
tenant_id is a tag within that org's namespace
- Tenant data is stored in isolated partitions
tenant export and tenant delete operate only within the caller's org
Implementation notes
tenant_id is stored as a top-level field in session metadata and propagated to all events
- Existing
--stream-to and OTLP export include tenant_id as a span attribute
tenant delete performs a hard delete from the NDJSON store and writes a deletion audit record
- No changes to the capture path - tagging is additive
Acceptance criteria
Problem
Teams building SaaS products on top of AI agents need to isolate traces, costs, and audit logs per customer. Today agent-trace has no concept of tenancy - all sessions land in the same store with no customer-level separation.
This matters for:
Proposed solution
A
--tenant-idflag onwatchand hooks that tags all events with a customer identifier, plus tenant-scoped query and export commands.Tagging sessions
All events in the session are tagged with
tenant_id: customer-acmein the NDJSON store.Querying by tenant
Tenant cost rollup
Tenant-scoped API keys (hosted collector)
When using the hosted collector, tenant isolation is enforced server-side:
tenant_idis a tag within that org's namespacetenant exportandtenant deleteoperate only within the caller's orgImplementation notes
tenant_idis stored as a top-level field in session metadata and propagated to all events--stream-toand OTLP export includetenant_idas a span attributetenant deleteperforms a hard delete from the NDJSON store and writes a deletion audit recordAcceptance criteria
--tenant-idflag onwatchtags all session events with the tenant identifierAGENT_STRACE_TENANT_IDenv var works as an alternative to the flagagent-strace list --tenant IDfilters session list to one tenantagent-strace cost --tenant IDscopes cost calculation to one tenantagent-strace tenant reportproduces a cost rollup across all tenantsagent-strace tenant export IDexports all sessions for a tenant as JSONagent-strace tenant delete ID --confirmhard-deletes all tenant data and writes an audit recordtenant_idincluded in OTLP span attributes on export