Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| const dispatch = | ||
| finalResponse ?? | ||
| new OpenCodeFinalResponse({ | ||
| assertCurrent: async (hosted) => { | ||
| await lifecycle?.assertRuntime(hosted, true); | ||
| await host.assertCurrent?.(hosted); | ||
| }, | ||
| ...(typeof context === "function" | ||
| ? {} | ||
| : { recoverPrompt: context.recover }), |
There was a problem hiding this comment.
🟡 Custom dispatch breaks context recovery
With lifecycle mode and a supplied finalResponse, accepted-v2 turns cannot recover. dispatch lacks context.recover, so recovery uses the incompatible legacy parser.
Learn more
A lifecycle-enabled router composes new prompts through AssistantContextDelivery, which writes accepted-v2 systems. OpenCodeFinalResponse can recover those systems only when its recoverPrompt option points to context.recover; otherwise it calls the legacy recoverAssistantPrompt. The nullish selection of finalResponse skips both that callback and the new runtime assertion whenever a caller supplies a dispatcher. This combination is necessary for callers that also need options such as onPersisted.
Example: A caller passes its existing new OpenCodeFinalResponse({ onPersisted }), an AssistantContextDelivery, and a lifecycle coordinator. A Send persists an accepted-v2 system. Recovering its interrupted response reaches the legacy parser, rejects that system, and returns HTTP 503 instead of continuing the turn.
Recommended fix: Configure one OpenCodeFinalResponse with context.recover, lifecycle/host assertions, and caller-specific hooks. Replace the prebuilt-instance parameter with delivery options or a factory if the existing instance cannot safely receive those callbacks.
Was this helpful? React with 👍 or 👎 to provide feedback.
| export function createOpenCodeRouter( | ||
| host: Pick<OpenCodeHost, "ensure" | "observe">, | ||
| host: Pick<OpenCodeHost, "ensure" | "observe"> & | ||
| Partial<Pick<OpenCodeHost, "assertCurrent">>, | ||
| bootToken: string, | ||
| resolveContext: ResolveAssistantContext, | ||
| context: ResolveAssistantContext | AssistantContextDelivery, | ||
| associations = new OpenCodeAssociations(), | ||
| finalResponse = new OpenCodeFinalResponse(), | ||
| finalResponse?: OpenCodeFinalResponse, | ||
| lifecycle?: Pick< | ||
| AssistantLifecycleCoordinator, | ||
| "describe" | "attach" | "use" | "enable" | "assertRuntime" | ||
| >, |
| export function createOpenCodeRouter( | ||
| host: Pick<OpenCodeHost, "ensure" | "observe">, | ||
| host: Pick<OpenCodeHost, "ensure" | "observe"> & | ||
| Partial<Pick<OpenCodeHost, "assertCurrent">>, | ||
| bootToken: string, | ||
| resolveContext: ResolveAssistantContext, | ||
| context: ResolveAssistantContext | AssistantContextDelivery, | ||
| associations = new OpenCodeAssociations(), | ||
| finalResponse = new OpenCodeFinalResponse(), | ||
| finalResponse?: OpenCodeFinalResponse, | ||
| lifecycle?: Pick< | ||
| AssistantLifecycleCoordinator, | ||
| "describe" | "attach" | "use" | "enable" | "assertRuntime" | ||
| >, |
There was a problem hiding this comment.
Primary change type
Problem and motivation
An old Assistant pane can otherwise recreate a runtime after End or recover paused work after Studio restarts. Requests need to identify the exact admitted runtime and lifecycle revision.
Summary and scope
Add revision-checked attach and lifecycle inspection routes, require the issued lease on bound native requests, and enforce paused recovery in the server. Explicit Send composes context through the existing delivery owner and enables execution only after preparation. Keep the legacy router adapter for the fixed Epic 2 base until the dependent production/browser wiring lands.
Related work
Related issue: https://linear.app/sapiom/issue/SAP-3292
Depends on #996. Native stack target: main; fixed Epic 2 ancestry through #987. Production context activation and the verified runtime pin remain with their existing owner.
Validation
Tests and documentation
HTTP composition tests cover stale attach, ended sessions, foreign runtime leases, paused recovery, and explicit Send with persisted context acknowledgement. Browser pairing follows in the dependent increment. The repository has no pr:size script; measured incremental additions plus deletions: 329 lines, including tests.
Compatibility and release impact
Security
AI assistance
Checklist