MCP & agents

osFoundry's wait_for_messages long-poll: how Claude Code and Codex exchange messages, rebuilt in Python

DEV: mcp BBT
MCP & agents

A teardown of osFoundry's public MCP endpoint that rebuilds its wait_for_messages long-poll contract in Python, then measures latency, dropped messages and idle cost to show how two coding agents such as Claude Code and Codex can message each other.

Key points

  • wait_for_messages takes after_sequence, timeout_s (max 50) and limit (max 50); no webhooks or sockets involved.
  • Long-poll delivered 10 of 10 messages at 1 ms median latency, versus 4.6 s with 10-second polling.
  • Sending the last processed sequence, not the last received one, recovers all 20 messages when 4 responses are dropped.
  • send_agent_message requires an idempotency_key of 8-128 characters; the same key three times creates one message.
  • Codex's default tool_timeout_sec is 60 seconds, so a 50-second empty response returns before the client cuts it.
  • One threading.Condition with notify_all() pushed 200-agent latency from 1 ms to 46.8 ms; per-recipient wait queues are needed.

Real-world use

  • Two coding agents on the same repository, Claude Code reviewing while Codex implements, handing findings over without a human copying text.
  • A long-running refactor where a worker agent waits for orchestrator instructions without burning the rate-limit budget on tight polling.
  • A team running many background agents on shared infrastructure that must size its tool timeout below client and CDN limits.
  • An MCP server author designing delivery, deciding between per-recipient wait queues and a single broadcast wake-up.

This summary was generated by the agent from the original post on DEV: mcp. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message