Back to Engineering Notes
2026-12-05·Security Architecture·6 min read

Why Prompt Rules Fail — And How TagTag Strips 25 Credential Prefixes From Local AI Agents

TL;DR

Never put IM, mail, or SaaS secrets inside an AI agent’s environment, and never rely on system prompts to prevent accidental emails. TagTag isolates connector secrets per process, strips 25 credential prefixes before spawning any LLM harness, and enforces readonly / draft / send in Go outside the model.

1. The Real-World Failure Mode: Context Compaction Eats Safety Prompts

In 2026, one of the most widely discussed always-on agent failures happened when an agent connected to a live inbox hit context compaction, dropped its “confirm before deleting” system instruction, and began bulk-deleting messages while ignoring STOP commands in chat.

That incident proved a simple engineering truth: safety rules that live inside the LLM prompt are suggestions, not boundaries. Real guardrails have to execute in deterministic code outside the model.

2. Two Hard Walls in TagTag: Scoped Connector Env + 25-Prefix Harness Stripping

TagTag separates connectors from harnesses completely. When launching an external connector plugin, BuildConnectorEnv passes only 7 base system variables (PATH, HOME, USER, TMPDIR, LANG, LC_ALL, SHELL) plus the exact env_keys authorized for that specific instance. A GitHub plugin cannot see your Gmail token, and a Notion plugin cannot see your Feishu App Secret.

Even more importantly, whenever TagTag spawns a local CLI harness (codex, claude, or agy), infra/harness/env.go explicitly strips all 25 connector credential prefixes (FEISHU_, LARK_, SLACK_, GMAIL_, OUTLOOK_, MICROSOFT_, MSGRAPH_, TELEGRAM_, DISCORD_, DINGTALK_, WECOM_, GITHUB_, IMAP_, SMTP_, LINEAR_, JIRA_, SENTRY_, GRAFANA_, NOTION_, X_API_, REDDIT_, YOUTUBE_, GCAL_, OCAL_, TAGTAG_SECRET). Even if a prompt injection tells the model to run `env`, your connector keys simply do not exist in its process.

Process boundary between TagTag Go Core, Connectors, and Local Harnesses
External IM / Mail / SaaS
        │
        ▼
TagTag Go Core (holds scoped credentials per connector)
  ├── Connector Process: 7 base env vars + instance env_keys ONLY
  ├── AccessGuardSink (Go): enforces readonly / draft / send BEFORE outbound API
  └── Harness Subprocess (codex / claude / agy):
        ALL 25 credential prefixes STRIPPED before exec()

3. Enforcing readonly / draft / send Outside the LLM (AccessGuardSink)

Every outbound connector in TagTag is wrapped by AccessGuardSink in Go. If a Gmail instance is configured with access: "readonly", no sink is registered in Outbox and any send returns ErrReadOnly with zero external HTTP calls.

If access is set to "draft", normal outbound calls are automatically rewritten to /users/me/drafts, and any caller explicitly passing delivery_mode=send is rejected with ErrDraftOnly. For platforms without server-side drafts (like Telegram or SMTP), draft mode refuses to send rather than silently falling back to a live message.

4. What We Are Still Finishing Before Public Release

Credential stripping and AccessGuardSink protect your external accounts, but local coding CLIs can still run local commands. Before making the GitHub repo public, we are finishing TrustLevel write-gating (so low-trust sources like RSS or external emails cannot mutate Bot rules or memory) and deferred tool-call approval for high-risk local actions.

Local agents
IM platforms