NATS Topics & Contracts

The inter-agent communication mesh is defined by strictly typed Pydantic models in backend/app/contracts.py over NATS JetStream topics. Using these contracts at publish/subscribe boundaries eliminates key-rename and type-mismatch bugs at runtime.


Core Subject Routing Table

Subject NameTopics EnumPublisher AgentSubscriber AgentsPayload Contract Class
audio.inboundAUDIO_INBOUNDtransport_agentstt-agent (Rust)Raw binary PCM (16kHz mono)
audio.stopAUDIO_STOPstt-agent (Rust)voice-agent (Rust)AudioStop
audio.perceptionAUDIO_PERCEPTIONstt-agent (Rust)brain_agentAudioPerception
chat.inputCHAT_INPUTmain.py / talk.pybrain_agentChatInput
chat.outputCHAT_OUTPUTbrain_agentvoice-agent, main.pyChatOutput
audio.playbackAUDIO_STREAMvoice-agent (Rust)transport_agentRaw binary PCM (32kHz)
audio.playback.visemesAUDIO_PLAYBACK_VISEMESvoice-agent (Rust)transport_agentAudioPlaybackVisemes
audio.playback.progressAUDIO_PLAYBACK_PROGRESSvoice-agent (Rust)brain_agentAudioPlaybackProgress
vision.descriptionVISION_DESCRIPTIONvision_agentbrain_agentVisionDescription
state.presenceSESSION_PRESENCEtransport_agentsubconscious_agentSessionPresence
state.subconsciousSTATE_SUBCONSCIOUSsubconscious_agentbrain_agentStateSubconscious
memory.surfacedMEMORY_SURFACEDsubconscious_agentbrain_agentMemorySurfaced

Authenticated Schema Definitions (backend/app/contracts.py)

ChatInput

python
class ChatInput(BaseModel):
    model_config = {"extra": "allow"}
    text: str
    utterance_id: str | None = None
    turn_id: str | None = None
    modality: str = "text"  # "text" | "voice" | "mock"
    metadata: dict[str, Any] = Field(default_factory=dict)

ChatOutput

python
class ChatOutput(BaseModel):
    model_config = {"extra": "allow"}
    content: str
    turn_id: str
    done: bool = False
    proactive: bool = False
    affect: ChatOutputAffect | None = None

AudioPlaybackVisemes

python
class AudioPlaybackVisemes(BaseModel):
    model_config = {"extra": "allow"}
    target_level: float
    viseme_id: int
    turn_id: str
    timestamp: float

SessionPresence

python
class SessionPresence(BaseModel):
    model_config = {"extra": "allow"}
    client_id: str
    status: str  # "connected" | "disconnected" | "speaking"
    timestamp: float