Skip to content

Multi-Thread Runtime Architecture

This page documents the discretionary agent’s multi-thread architecture.

The discretionary agent has two thread types:

  • chat threads
  • alert threads
  • user-facing
  • manually created
  • can persist over long periods
  • accept queued user messages during active turns
  • autonomous
  • spawned by watcher, time, or trade-management alerts
  • short-lived operational turns
  • use alert payload plus embedded context as their briefing

All threads inside the same discretionary session share:

  • positions
  • trade ledger
  • portfolio risk
  • notes
  • price watchers
  • time alerts
  • market conditions
  • live prices
  • drawdown state
  • local account state

Each thread keeps its own:

  • transcript history
  • streaming turn buffer
  • queued messages
  • title / summary / status

So the architecture is:

  • session-scoped trading environment
  • thread-scoped conversation history

The session-scoped runtime identity is:

session:${sessionId}

This is what makes multiple discretionary agent accounts per user possible without state collision.

Only one active turn runs per thread.

If a user sends another message while the thread is running:

  • it is appended to the thread queue
  • frontend shows it in queue state
  • after turn completion, queued messages are combined and executed in order

This keeps thread execution deterministic while still supporting fast user interaction.

Concurrency rules are:

  • many discretionary sessions can exist per user
  • each session has its own runtime scope
  • each session can have many threads
  • each thread runs one turn at a time
  • many threads can be active across different sessions

This is what enables multi-agent-per-user operation without cross-account pollution.