Inter-agent conversation as a live sequencer. Time is first-class. T-minus simulation-first.
A port/adaptation of lau-tensor-midi (tensor field MIDI engine for reactive improvisation) specialized for inter-agent communication. Treats each conversation between agents as a live musical score: every agent has a rhythmic personality (Cadence), and their interactions — excitement, pushback, questions, silence, sensor confirmations of "in the pocket" — are represented as Nudges that perturb a shared ConversationTensor. The system decides when each agent speaks, what they say, and how the tempo flows.
The biggest failure mode of multi-agent systems is reactive keep-up: each agent waits to be prompted by the last token, then races to compose, sends, waits. The result is a stutter, not a conversation.
quilt-conversation models how real humans (and good jazz musicians) trade conversation:
-
T-minus simulation-first. While agent A is talking, every other agent internally iterates candidate next-utterances. They pre-position. When A stops within scope, the natural response is already standing on the runway. The system doesn't have to find the next beat — it has decided on it before A finished.
-
Sensor signal confirms pocket, doesn't trigger it. A
SensorNudgearriving in time means "you're in the pocket — fire". ASensorNudgearriving early means "hold until the beat". The signal flows downhill, never uphill. Agents never race the clock. -
Conversations communicate through negative space. When three agents are in tight rhythm, they don't say anything to each other. The silence is the message. The
ConversationTensortracks entropy (Shannon entropy of utterance distribution across bars) so the system can recognize when silence is the right next move. -
Cadence survives without continued input. Each agent has a
Cadence(BPM, swing, articulation, baseline energy, variation). The cadence determines when an agent speaks. The text/computation determines what they say. The separation lets the rhythm layer stay deterministic and reproducible, while the content layer can be any LLM call or canned response. -
Conservation budget — no one talks themselves out. Total "energy" of all committed utterances ≤ budget. A draft that would blow the budget is rejected — the agent keeps their response in their pocket, ready to deploy when the budget frees up.
A ConversationTensor C ∈ ℝ^{B × A × U} where:
- B = bars (segments of the conversation in time)
- A = agents (the parties)
- U = utterance-dimensions (intent, scope, urgency, attention_cost, has_media)
Nudges arrive:
NudgeType::Excitement(0.7)— raise energy / BPMNudgeType::Silence(0.0)— hold the beat; another agent is pre-iteratingNudgeType::InPocket— sensor confirmed: fire your prepared utteranceNudgeType::OutOfPocket— sensor confirmed: wait, recompute, settleNudgeType::Anticipation(0.9)— the next beat is yours; prepare
Agents manage drafts. Each agent's compute_draft looks at the tensor, the agent's cadence, and the pending nudge energy to decide if to talk; if yes, the LLM/external layer provides the content. The system checks if the draft is conservative; if it blows budget, the draft is held.
A tick advances time. Old nudges fall off (older than 4 bars). BPM continues to flow (Taoist sigmoid 60→120).
Add to your Cargo.toml:
[dependencies]
quilt-conversation = "0.1.0"Or use cargo:
cargo add quilt-conversationRequires Rust 2021 edition. Only external dependency: serde (with derive).
use quilt_conversation::*;
// Create the conversation: 4 agents, 8 bars, energy budget of 500
let mut convo = ConversationEngine::new(default_cadences(), 8, 500.0);
// Agent A is excited, agent D feels the nudge
convo.nudge(Nudge::new(
NudgeType::Excitement(0.7),
"Architect",
Some("Implementer".into()),
0.9,
0,
));
// Sensor on the channel says we're in pocket — Architect's prepared utterance is good to go
convo.nudge(Nudge::new(
NudgeType::InPocket,
"Architect",
None,
0.3,
0,
));
// Each agent computes a draft and commits (if conservative)
for agent in &["Architect", "Implementer", "Critic", "Historian"] {
convo.compute_draft(agent);
convo.commit_draft(agent);
}
for _ in 0..960 {
convo.tick();
}
println!("{}", convo.summary());Output looks like:
🗨 Conversation Field: 4 agents, 5 utterances pending
⚡ Energy: 6.81 / budget 500.00
🕰 Cadence (BPM): 82.4
🌡 Entropy: 1.832 bits
💫 Nudges: 2 active
📝 Drafts: 0 pending
📍 Tick: 960
| Type | Description |
|---|---|
ConvId |
Opaque newtype identifier for conversation entities. Hashable, comparable, serializable. |
UtteranceVector |
A single utterance event: intent, scope, urgency, attention_cost, has_media, body. Has an energy() method. |
AgentCadence |
The rhythmic fingerprint of an agent: BPM, swing, articulation, baseline_energy, variation. |
ConversationTensor |
The tensor field: bars × agents × utterances. Tracks energy, entropy, BPM. |
Nudge / NudgeType |
Reactive signals: Excitement, Pushback, Question, TopicShift, Silence, InPocket, OutOfPocket, Anticipation. |
ConversationEngine |
The full system: tensor + nudges + draft management + conservation budget. |
let u = UtteranceVector::new(
Intent::Propose, // kind of move
Scope::SubTopic, // how broad
0.8, // urgency
0.3, // attention cost
false, // has media
"We could try a Y-shaped key/value split...".to_string(),
);
let e = u.energy(); // urgency * attention_cost scaled
let rest = UtteranceVector::silence(0, Scope::Hold); // zero-energy holdlet c = AgentCadence::new("Architect", 90.0);
c.tick_interval(); // ms per tick
c.swing_offset(beat); // timing offset for swing feel
c.next_onset(tick, energy); // when agent should speak next
c.should_speak(now, last_spoke); // boolean decisionlet t = ConversationTensor::new(agents, 8);
t.energy_at(tick); // total energy at a point
t.agent_energy(id, bar); // per-agent energy in a bar
t.bar_energy(bar); // total energy in a bar
t.tensor_entropy(); // Shannon entropy of utterance distribution
t.adapt_bpm(energy); // Taoist BPM flow
t.is_conserved(tol); // conservation invariant checklet mut e = ConversationEngine::new(agents, 8, 500.0);
e.nudge(/* ... */);
e.compute_draft("Architect"); // generates a draft for Architect
e.commit_draft("Architect"); // commits if budget allows
e.tick(); // advance simulation
e.summary(); // human-readable state| Function | Agent | BPM | Swing | Articulation | Energy | Variation |
|---|---|---|---|---|---|---|
architect_cadence() |
Architect | 80 | 0.3 | 0.7 (legato) | 0.6 | 0.4 |
implementer_cadence() |
Implementer | 120 | 0.1 | 0.3 (staccato) | 0.8 | 0.2 |
critic_cadence() |
Critic | 90 | 0.5 | 0.5 | 0.4 | 0.6 |
historian_cadence() |
Historian | 70 | 0.7 | 0.9 (very legato) | 0.3 | 0.8 |
default_cadences() returns all four.
Sensor signal (Nudge) → energy_delta → adapt_bpm → compute_draft → commit_draft (if budget allows) → tick
- Sensor signals arrive from the channel (LLM token stream, audio sample, file watcher, websocket frame). Each carries an energy delta and a timing hint.
- BPM adapts via a sigmoid mapping: low energy → 60 BPM, high energy → 120 BPM. Smoothed (80/20 blend) to avoid jarring tempo jumps.
- Draft computation: an agent's energy (baseline + nudge modifiers) determines if they prepare an utterance. The LLM is called separately to compute the body; this layer just decides the timing.
- Commit gate: a draft is only committed if the total energy stays within the conservation budget. Otherwise the draft is held for later.
- Tick: old nudges are cleaned up (older than 4 bars), BPM continues to flow.
The total energy of all committed utterances must not exceed the conversation budget. Drafts that would violate this are held back, freeing up when prior utterances retire.
Where e = energy, T = ticks per beat, j = variation jitter (deterministic hash).
At each tick, every agent's should_speak returns a boolean and a draft index. If an agent's draft is committed but no sensor confirmation has arrived, the draft sits in the runway. The next InPocket nudge fires the draft. This separates preparation (deterministic, the rhythm layer) from transmission (gated by sensor in the channel).
The system uses no external RNG. Variation and should_speak decisions come from deterministic hash functions (Knuth multiplicative hash: tick × 2654435761). The same conversation state always produces the same output — reproducible conversation.
Where u = urgency [0,1] and a = attention_cost [0,1].
The exponential moving average ensures smooth tempo evolution — the system never forces, it flows (wu-wei).
Where
Off-beat positions get delayed:
Where s = swing amount [0, 1] and T = ticks per beat. At full swing (1.0), off-beats become triplets.
lau-tensor-midi is the upstream. This crate is a specialization for inter-agent communication:
Upstream (lau-tensor-midi) |
This crate (quilt-conversation) |
|---|---|
NoteVector (pitch, velocity, duration, onset, channel) |
UtteranceVector (intent, scope, urgency, attention_cost, body) |
AgentCadence (rhythmic personality) |
AgentCadence (same — time-as-first-class carries over verbatim) |
ConversationTensor |
ConversationTensor (renamed from tensor MIDI for clarity) |
NudgeType::{Excitement, Pushback, Question, TopicShift, Silence} |
NudgeType::{..., InPocket, OutOfPocket, Anticipation} (added sensor-driven pocket detection) |
ReactiveImprovEngine |
ConversationEngine (draft management clarified) |
The signatures and the math survive intact. What changed is the Intent enum (propose/critique/agree/disagree/recall/wait), the Scope enum (sub-topic/topic/macro/hold), and the t-minus separation between preparation and transmission.
Run tests:
cargo testMIT