Repository navigation
fix(mcpl): require explicit final speech delivery receipts #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Require an explicit `delivered: true` receipt before reporting final channel speech as delivered. Missing or malformed publish receipts surface a routing failure with uncertain delivery and do not trigger an automatic resend. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2794,9 +2794,9 @@ export class ChannelRegistry { | |
| ): Promise<{ delivered: boolean; channelId: string; messageId?: string } | null> { | ||
| // Surface a routing failure: emit a trace AND notify the host (which drops | ||
| // a `[discord-send-failed]` marker into chronicle) so the agent learns her | ||
| // reply never reached the human, instead of it vanishing silently. | ||
| // reply delivery was not confirmed, instead of it vanishing silently. | ||
| const fail = (channelId: string | null, reason: string): null => { | ||
| console.error(`[routeSpeech] ${conversationId}: ${reason} — speech NOT routed (${text.length} chars stay in chronicle)`); | ||
| console.error(`[routeSpeech] ${conversationId}: ${reason} — speech delivery NOT confirmed (${text.length} chars stay in chronicle)`); | ||
| this.emitTraceFn({ | ||
| type: 'mcpl:speech-route-failed', | ||
| conversationId, | ||
|
|
@@ -2876,7 +2876,7 @@ export class ChannelRegistry { | |
| content: [{ type: 'text', text }], | ||
| }; | ||
| const result = await server.sendChannelsPublish(publishParams); | ||
| const delivered = (result as { delivered?: boolean } | undefined)?.delivered ?? true; | ||
| const delivered = (result as { delivered?: unknown } | undefined)?.delivered; | ||
| // Surface the posted message's id (ChannelsPublishResult.messageId) so | ||
| // trace consumers can act on the just-posted message — e.g. a TTS-relay | ||
| // tap editing it down to the words actually voiced on interruption. | ||
|
|
@@ -2890,6 +2890,12 @@ export class ChannelRegistry { | |
| return fail(channelId, `server "${entry.serverId}" reported delivered:false for "${channelId}"`); | ||
| } | ||
|
|
||
| // Final publish is a request, so success requires an explicit receipt. | ||
| // Missing/malformed responses leave delivery uncertain; do not retry here. | ||
| if (delivered !== true) { | ||
| return fail(channelId, `server "${entry.serverId}" returned no valid delivery receipt for "${channelId}" (delivery uncertain)`); | ||
|
Comment on lines
+2895
to
+2896
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/mcpl/channel-registry.ts
Line: 2895-2896
Comment:
**Uncertain delivery triggers a bounce** If a connector posts a hybrid `>>>` message but returns a missing or malformed receipt, this branch returns `null`. The hybrid caller then tells the agent the text was not delivered, retains it for `{{unsent}}`, and requests another turn. The agent may resend a message the human already received.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
| } | ||
|
|
||
| console.error(`[routeSpeech] ${conversationId}: routed ${text.length} chars -> ${channelId} (server=${entry.serverId}, delivered=${delivered})`); | ||
| this.emitTraceFn({ | ||
| type: 'mcpl:speech-routed', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addMessagehas no target here and writes it to the primary agent’s context. The fork that authored the reply gets no delivery warning.Prompt To Fix With AI