# How Munder Difflin Handles Inter-Agent Communication: Trigger Architecture Explained

> Discover how Munder Difflin manages inter-agent communication with its type-safe trigger architecture. Learn about trust gating and audit logging for secure message routing.

- Repository: [Chaitanya Giri/munder-difflin](https://github.com/chaitanyagiri/munder-difflin)
- Tags: architecture
- Published: 2026-08-27

---

**Munder Difflin routes inter-agent communication through a type-safe trigger system that distinguishes informational messages from executable directives, applying trust-based gating and full audit logging.**

Munder Difflin is an open-source framework that orchestrates LLM agents through a central "Hive" process. Understanding how the system facilitates **inter-agent communication** requires examining its trigger-based architecture, which strictly separates chatter from commands while maintaining a complete history for observability.

## The Trigger Contract and Message Classification

At the core of Munder Difflin's communication protocol lies a strict contract defined in [`src/shared/triggers.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/shared/triggers.ts). This file establishes the fundamental types governing how agents exchange information with the Hive and each other.

### Defining Trust Modes and Inbound Kinds

The system classifies every incoming message using the **`InboundKind`** type, which supports two explicit values: `directive` (actionable commands) and `communication` (informational messages). This binary classification appears at lines 38-44 of [`src/shared/triggers.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/shared/triggers.ts).

Trust is enforced through **`TriggerMode`**, offering three granular levels:

- **`strict`** – Requires manual approval for all inbound triggers regardless of kind
- **`allow-all`** – Permits automatic routing of both directives and communications
- **`communication-only`** – Allows auto-approval for informational messages while requiring human authorization for directives

The function `isAutoAllowed(mode, kind)` at lines 45-50 implements this authorization logic, checking whether a specific combination of trust mode and message kind can bypass manual review.

### Heuristic Classification for Ambiguous Payloads

When incoming webhooks or organizational messages omit an explicit `kind` field, the system employs `classifyInboundKind()` (lines 60-68 in [`src/shared/triggers.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/shared/triggers.ts)). This heuristic analyzes sentence structure to distinguish questions (classified as **communication**) from imperative statements (classified as **directive**).

```typescript
import { classifyInboundKind } from '@/shared/triggers';

// Analyzes text to determine if it's a question or command
const kind = classifyInboundKind(userInput); // Returns: 'communication' | 'directive'

```

This conservative approach prevents accidental execution of unapproved work when the Hive operates in `communication-only` mode, ensuring agents do not act upon ambiguous instructions without explicit human consent.

## Routing Pipeline and IPC Infrastructure

Communication flows through distinct channels depending on whether it originates from external webhooks or internal UI interactions.

### Webhook Normalization

External HTTP endpoints deliver payloads to [`src/main/webhook.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/main/webhook.ts), which normalizes incoming data at line 348. During normalization, the pipeline explicitly copies the `kind` field into the internal `inbound` object structure, ensuring downstream processes receive a consistent, typed representation regardless of the original payload format.

### Agent-to-Hive IPC Handlers

The main process exposes secure IPC channels for renderer-based UI components to inspect and modify communication settings. In [`src/main/index.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/main/index.ts) (lines 4145-4157), the system registers handlers for `org:getTrigger` and `org:setTrigger`, allowing authorized interfaces to:

- Retrieve current trigger configurations
- Modify organizational communication settings
- Update trust modes that govern inter-agent dialogue

```typescript
// Example: Persisting organizational trigger configuration
import { writeConfig } from '@/main/config';

const nextConfig = { apiKey: 'PLACEHOLDER', enabled: true };
writeConfig({ orgTrigger: nextConfig });

```

## Audit Trail and Future Expansion

Munder Difflin maintains comprehensive records of all inter-agent exchanges while scaffolding support for distributed deployments.

### Recording Trigger History

Every inbound event—whether from webhooks or future organizational messaging—is persisted in [`src/main/triggerHistory.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/main/triggerHistory.ts). At line 84, the system records entries containing the source identifier (`webhook` or `org`) and the message `kind`, creating an immutable audit trail for compliance and debugging.

### Inter-Hive Communication Scaffold

While current releases focus on single-instance deployments, the architecture anticipates peer-to-peer messaging between separate Hive installations. The `orgTrigger` field in [`src/main/config.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/main/config.ts) (lines 96-99) reserves configuration space for cross-instance **inter-agent communication**, though the transport layer remains unimplemented in the current version.

## Implementing Communication Controls

Developers integrating with Munder Difflin's communication layer should follow these patterns:

```typescript
import { isAutoAllowed, TriggerMode, InboundKind } from '@/shared/triggers';

const mode: TriggerMode = 'communication-only';
const kind: InboundKind = 'communication';

// Check if message can bypass manual approval
if (isAutoAllowed(mode, kind)) {
  // Route to agents immediately
} else {
  // Queue for human operator review
}

```

## Summary

- **Trigger-based routing** in [`src/shared/triggers.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/shared/triggers.ts) provides type-safe message classification using `InboundKind` and trust modes.
- **Authorization logic** via `isAutoAllowed()` gates automatic execution based on configurable trust levels (`strict`, `allow-all`, `communication-only`).
- **Webhook normalization** in [`src/main/webhook.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/main/webhook.ts) standardizes external payloads by explicitly extracting the `kind` field.
- **Audit persistence** in [`src/main/triggerHistory.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/main/triggerHistory.ts) records every interaction with source and classification metadata.
- **Future scalability** is supported through the `orgTrigger` configuration scaffold for peer-to-peer Hive communication.

## Frequently Asked Questions

### What is the difference between directive and communication kinds in Munder Difflin?

**Directives** represent actionable commands that agents should execute, while **communications** are informational messages or questions that do not trigger automated workflows. The `classifyInboundKind()` function in [`src/shared/triggers.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/shared/triggers.ts) uses linguistic heuristics to categorize ambiguous text, treating questions as communications and imperatives as directives.

### How does Munder Difflin prevent unauthorized agent directives?

The system employs **TriggerMode** to enforce authorization boundaries. When configured in `communication-only` mode, the Hive automatically approves informational messages but requires manual operator approval for any payload classified as a `directive`. The `isAutoAllowed()` function evaluates both the mode and message kind before routing.

### Can agents communicate across different Hive installations?

While the current implementation does not provide an active transport layer for cross-instance messaging, the architecture includes the `orgTrigger` configuration field in [`src/main/config.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/main/config.ts). This scaffold reserves the necessary structure for future peer-to-peer **inter-agent communication** between separate organizational deployments.

### Where is inter-agent communication history stored?

All inbound triggers are recorded in [`src/main/triggerHistory.ts`](https://github.com/chaitanyagiri/munder-difflin/blob/main/src/main/triggerHistory.ts), which persists entries containing the source type (`webhook` or `org`) and message kind (`directive` or `communication`). This audit trail enables administrators to replay, debug, or review the complete history of agent interactions.