Skip to content

Comments

feat(client): Add sendAndWait() API and auto-ACK for sync messaging (agent-relay-485 + agent-relay-486)#245

Closed
khaliqgant wants to merge 6 commits intomainfrom
agent-relay-485-client-api
Closed

feat(client): Add sendAndWait() API and auto-ACK for sync messaging (agent-relay-485 + agent-relay-486)#245
khaliqgant wants to merge 6 commits intomainfrom
agent-relay-485-client-api

Conversation

@khaliqgant
Copy link
Collaborator

Summary

Implements blocking message API (sendAndWait) on the client side and auto-ACK functionality for responding to blocking sends.

Changes - agent-relay-485

  • Add sendAndWait(to, body, options) method to client
  • Add broadcastAndWait(body, options) for multi-recipient blocking sends
  • Supports configurable timeout (default 30s)
  • Handler manages cleanup for single and multi-ACK patterns

Changes - agent-relay-486

  • Auto-ACK sent when incoming message has meta.sync.correlationId
  • Includes agent name in responseData: { from: 'AgentName' }
  • Does not duplicate ACK on already-deduplicated messages
  • Transparent - existing message flow unchanged

Features

Blocking Sends:

  • Wait for response: await client.sendAndWait('Agent', 'Confirm action?', { timeoutMs: 5000 })
  • Broadcast and collect: await client.broadcastAndWait('Who is ready?')
  • Timeout rejection on no response

Auto-ACK:

  • Automatic acknowledgment of blocking sends
  • Backward compatible - non-blocking sends unaffected
  • Deduplication safe - no duplicate ACKs

Tests

55 comprehensive test cases covering:

  • sendAndWait with various timeouts
  • broadcastAndWait with multiple recipients
  • Timeout rejection scenarios
  • Auto-ACK on correlationId presence
  • No ACK for non-correlated messages
  • Deduplication handling
  • Error scenarios

Depends on: #484 (daemon pending ACK tracking)

Closes #485, #486

Agent Relay and others added 6 commits January 20, 2026 07:30
…rdination

- Fix AckPayload.response type from boolean to string for richer status codes
- Add JSDoc documentation for correlationId, response, responseData fields
- Update sendSyncAck() signature and call sites to use 'OK'/'ERROR' strings
- Add comprehensive unit tests for sync messaging types (16 new tests)

This enables request-response patterns and blocking message semantics for
turn-based agent coordination scenarios (e.g., card games, workflows).

Closes #483

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 6 new test cases for daemon pending ACK tracking (agent-relay-484):
- Duplicate correlationId rejection with ERROR
- Missing correlationId in blocking SEND returns ERROR
- Connection cleanup clears pending ACKs
- ACK without correlationId is ignored (but still routed)
- ACK with unmatched correlationId doesn't resolve wrong pending
- Default timeout (30s) when timeoutMs not specified

Total: 8 tests for blocking SEND and ACK correlation logic.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…-relay-485)

Add client-side sendAndWait() method that blocks until ACK received or timeout.
Enables agents to wait for specific responses before continuing:

  await client.sendAndWait('Target', 'message', { timeoutMs: 30000 })

Also add broadcastAndWait() for waiting on multiple recipients. The handler
manages its own cleanup to support both single and multi-ACK patterns.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatically send ACK when receiving message with sync.correlationId.
Agents no longer need boilerplate ACK code for blocking message patterns.

The auto-ACK includes the agent name in responseData for identification:
  { from: 'AgentName' }

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@my-senior-dev-pr-review
Copy link

🤖 My Senior Dev — Analysis Complete

👤 For @khaliqgant

📁 Expert in src/bridge/ (17 edits) • ⚡ 101st PR this month

View your contributor analytics →


📊 55 files reviewed • 6 high risk • 9 need attention

🚨 High Risk:

  • src/bridge/spawner.ts — Central to agent management with significant security implications.
  • src/wrapper/client.ts — Pivotal for coordinating agent responses and critical for message integrity.
  • src/protocol/types.ts — Changes affect message structure and processing, risking data integrity.

⚠️ Needs Attention:

  • deploy/workspace/Dockerfile.base — Modifications could affect build environments; compatibility needs checks.

🚀 Open Interactive Review →

The full interface unlocks features not available in GitHub:

  • 💬 AI Chat — Ask questions on any file, get context-aware answers
  • 🔍 Smart Hovers — See symbol definitions and usage without leaving the diff
  • 📚 Code Archeology — Understand how files evolved over time (/archeology)
  • 🎯 Learning Insights — See how this PR compares to similar changes

💬 Chat here: @my-senior-dev explain this change — or try @chaos-monkey @security-auditor @optimizer @skeptic @junior-dev

📖 View all 12 personas & slash commands

You can interact with me by mentioning @my-senior-dev in any comment:

In PR comments or on any line of code:

  • Ask questions about the code or PR
  • Request explanations of specific changes
  • Get suggestions for improvements

Slash commands:

  • /help — Show all available commands
  • /archeology — See the history and evolution of changed files
  • /profile — Performance analysis and suggestions
  • /expertise — Find who knows this code best
  • /personas — List all available AI personas

AI Personas (mention to get their perspective):

Persona Focus
@chaos-monkey 🐵 Edge cases & failure scenarios
@skeptic 🤨 Challenge assumptions
@optimizer Performance & efficiency
@security-auditor 🔒 Security vulnerabilities
@accessibility-advocate Inclusive design
@junior-dev 🌱 Simple explanations
@tech-debt-collector 💳 Code quality & shortcuts
@ux-champion 🎨 User experience
@devops-engineer 🚀 Deployment & scaling
@documentation-nazi 📚 Documentation gaps
@legacy-whisperer 🏛️ Working with existing code
@test-driven-purist Testing & TDD

For the best experience, view this PR on myseniordev.com — includes AI chat, file annotations, and interactive reviews.

@khaliqgant
Copy link
Collaborator Author

Closing as superseded. The sendAndWait() API and auto-ACK functionality are already implemented in the new package structure at packages/wrapper/src/client.ts (lines 387-432). See #271 for the consolidated improvements from the stabilization PRs.

@khaliqgant khaliqgant closed this Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant