-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(mothership): end refused replay turns cleanly and bound oversized stream events #8450
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
Merged
+3,334
−312
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c920082
fix(mothership): bound replay frames and end refused turns instead of…
waleedlatif1 38cc7f9
fix(mothership): render stream-omitted tool values honestly
waleedlatif1 a0fe73f
refactor(mothership): replace replay compaction with one string-trunc…
waleedlatif1 9b4f7c8
fix(mothership): stop stale approval cards, raw backend bodies, and e…
waleedlatif1 9491b14
fix(mothership): never forward an approval stamp on a frame that cann…
waleedlatif1 bafd6aa
fix(mothership): keep retrying an unreachable worker through a task r…
waleedlatif1 61388bf
fix(mothership): settle runs whose terminal events fail, and tighten …
waleedlatif1 7fc6db9
fix(mothership): settle tool rows left unfinished by any finished turn
waleedlatif1 177ac84
fix(mothership): harden replay compaction, stream retries, teardown, …
waleedlatif1 89977d0
fix(mothership): separate retry budgets, cap preview totals, and clea…
waleedlatif1 55386c0
fix(mothership): clean up turns whose terminal publish failed and cap…
waleedlatif1 a4debbf
fix(mothership): bound preview frames per write and per turn, and nar…
waleedlatif1 77e7e4a
fix(mothership): omit the largest field of an event no cut can bound,…
waleedlatif1 7989cdf
fix(mothership): keep sibling fields when omitting bulk, and never ca…
waleedlatif1 fc2149c
fix(mothership): keep omitting bulk until an event fits one replay write
waleedlatif1 7aa6002
fix(mothership): shed oversized replay events in one pass and retry m…
waleedlatif1 aea7ed0
refactor(mothership): tidy replay compaction and stream retry after r…
waleedlatif1 77dedc2
fix(mothership): bound preview metadata frames and settle stopped row…
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
apps/sim/app/workspace/[workspaceId]/home/hooks/message-reconcile.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import type { PersistedMessage } from '@/lib/mothership/chat/persisted-message' | ||
| import { markMessageStopped } from '@/app/workspace/[workspaceId]/home/hooks/message-reconcile' | ||
|
|
||
| describe('markMessageStopped', () => { | ||
| it.each(['executing', 'pending', 'awaiting_approval'] as const)( | ||
| 'settles a %s tool row as stopped', | ||
| (state) => { | ||
| const message: PersistedMessage = { | ||
| id: 'assistant-1', | ||
| role: 'assistant', | ||
| content: '', | ||
| timestamp: '2026-09-29T00:00:00.000Z', | ||
| contentBlocks: [ | ||
| { | ||
| type: 'tool', | ||
| endedAt: 1, | ||
| toolCall: { id: 'call-1', name: 'gmail_read_v2', state }, | ||
| }, | ||
| ], | ||
| } | ||
|
|
||
| const stopped = markMessageStopped(message) | ||
|
|
||
| expect(stopped.contentBlocks?.[0].toolCall?.state).toBe('cancelled') | ||
| } | ||
| ) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
apps/sim/app/workspace/[workspaceId]/home/hooks/stream/stream-helpers.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { finalizeResidualToolCalls } from '@/app/workspace/[workspaceId]/home/hooks/stream/stream-helpers' | ||
| import type { ContentBlock } from '@/app/workspace/[workspaceId]/home/types' | ||
|
|
||
| describe('finalizeResidualToolCalls', () => { | ||
| it.each(['executing', 'awaiting_approval'] as const)( | ||
| 'settles a %s tool row with the turn outcome on Stop', | ||
| (status) => { | ||
| const blocks: ContentBlock[] = [ | ||
| { type: 'tool_call', toolCall: { id: 'call-1', name: 'gmail_read_v2', status } }, | ||
| ] | ||
|
|
||
| finalizeResidualToolCalls(blocks, 'cancelled') | ||
|
|
||
| expect(blocks[0].toolCall?.status).toBe('cancelled') | ||
| } | ||
| ) | ||
|
|
||
| it('reports whether any tool row was left to settle', () => { | ||
| const open: ContentBlock[] = [ | ||
| { type: 'tool_call', toolCall: { id: 'call-1', name: 'read', status: 'awaiting_approval' } }, | ||
| ] | ||
| const settled: ContentBlock[] = [ | ||
| { type: 'tool_call', toolCall: { id: 'call-2', name: 'read', status: 'success' } }, | ||
| ] | ||
|
|
||
| expect(finalizeResidualToolCalls(open, 'error')).toBe(true) | ||
| expect(finalizeResidualToolCalls(settled, 'error')).toBe(false) | ||
| }) | ||
|
|
||
| it('reports closing an open subagent lane as a change to persist', () => { | ||
| const blocks: ContentBlock[] = [{ type: 'subagent', content: 'research' }] | ||
|
|
||
| expect(finalizeResidualToolCalls(blocks, 'error')).toBe(true) | ||
| expect(blocks[0].endedAt).toEqual(expect.any(Number)) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.