Jasper John Cinatad
← All work

Conduit

An LLM gateway that keeps multi-turn chats on the right seat.

Role
Senior Full-Stack & AI Engineer
Where
Promota.ai
When
2025 to now
Built with
TypeScript, Node.js, Express, SQLite (WAL), OAuth PKCE
Access
Proprietary work for Promota.ai. Source is private.
Diagram: clients connect to Conduit, which keeps one agent conversation on Seat 2, with the affinity key order below.
Illustration Diagram I drew of how routing works.

Problem

Coding tools and agents shared a pool of ChatGPT and Codex seats. When a follow-up message landed on a different seat, prompt caching and encrypted reasoning from the previous turn stopped working.

What I built

An OpenAI-compatible gateway. Clients point at it like the normal API. It pools the seats, keeps each conversation on the seat that served it, and fails over when a seat hits a limit.

How it works

  • Chat identity (previous response id, conversation id, session ids, prompt cache key) is turned into SHA-256 routing keys, tried strongest first.
  • Every key is scoped to the calling API key, so one client can never pin or take over another client’s seat.
  • If a chat has to move, encrypted reasoning items are stripped first, which avoids the upstream invalid_encrypted_content error. A request is never replayed once output has reached the client.
  • A pin never traps traffic on a dead seat: cooldowns, errors or removed seats drop out of the candidates and weighted failover takes over.
Simplified lookup order
const order = ['previous_response', 'conversation', 'session', 'prompt_cache', 'client'];

// each key: 'affinity:v1:<kind>:<sha256(apiKeyId + id)>'
const seat = firstPinnedSeat(order, request) ?? weightedRotation(pool);

Outcome

  • Per-key limits of 300 requests per minute and 8 concurrent.
  • Pins older than 7 days are pruned, so the table stays bounded.
  • Weighted rotation, rate-limit failover, quota tracking and OpenRouter share one pool.