Repository navigation
fix(provider): deliver OpenCode steers at the next tool boundary #6530
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
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 |
|---|---|---|
|
|
@@ -1481,14 +1481,41 @@ export function makeOpenCodeAdapter( | |
| }); | ||
| } | ||
|
|
||
| yield* runOpenCodeSdk("session.promptAsync", () => | ||
| context.client.session.promptAsync({ | ||
| sessionID: context.openCodeSessionId, | ||
| model: parsedModel, | ||
| ...(context.activeAgent ? { agent: context.activeAgent } : {}), | ||
| ...(context.activeVariant ? { variant: context.activeVariant } : {}), | ||
| parts: [...(text ? [{ type: "text" as const, text }] : []), ...fileParts], | ||
| }), | ||
| // A steer sends into the busy session. Use the v2 prompt endpoint with | ||
| // `delivery: "steer"` so opencode promotes the message at the next safe | ||
| // provider-turn boundary (i.e. after the current tool call) instead of | ||
| // deferring it until the whole turn finishes — matching the behavior of | ||
| // typing into a native opencode session. Fresh turns keep the legacy | ||
| // async prompt since they start the agent loop themselves. | ||
| const sendPrompt = | ||
| steeringTurnId !== undefined | ||
| ? context.client.v2.session.prompt({ | ||
| sessionID: context.openCodeSessionId, | ||
| prompt: { | ||
| text: text ?? "", | ||
| ...(fileParts.length > 0 | ||
| ? { | ||
| files: fileParts.map((part) => ({ | ||
| uri: part.url, | ||
| mime: part.mime, | ||
| ...(part.filename !== undefined ? { name: part.filename } : {}), | ||
| })), | ||
| } | ||
| : {}), | ||
| }, | ||
| delivery: "steer", | ||
| }) | ||
| : context.client.session.promptAsync({ | ||
| sessionID: context.openCodeSessionId, | ||
| model: parsedModel, | ||
| ...(context.activeAgent ? { agent: context.activeAgent } : {}), | ||
| ...(context.activeVariant ? { variant: context.activeVariant } : {}), | ||
| parts: [...(text ? [{ type: "text" as const, text }] : []), ...fileParts], | ||
| }); | ||
|
Comment on lines
+1490
to
+1514
Contributor
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.
Consider keeping it a thunk so construction happens inside the effect: const sendPrompt = () =>
steeringTurnId !== undefined
? context.client.v2.session.prompt({ /* ... */ })
: context.client.session.promptAsync({ /* ... */ });
yield* runOpenCodeSdk(
steeringTurnId !== undefined ? "session.prompt" : "session.promptAsync",
sendPrompt,
).pipe(/* ... */);Posted via Macroscope — Effect Service Conventions |
||
|
|
||
| yield* runOpenCodeSdk( | ||
| steeringTurnId !== undefined ? "session.prompt" : "session.promptAsync", | ||
| () => sendPrompt, | ||
|
Contributor
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. SDK call escapes error handlingMedium Severity The steer/fresh prompt is invoked before Reviewed by Cursor Bugbot for commit b49bea4. Configure here. |
||
| ).pipe( | ||
| Effect.mapError(toRequestError), | ||
| // On failure of a fresh turn: clear active-turn state, flip the | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.


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.
Invalid steer file attachment fields
Medium Severity
Steer attachments map legacy file parts into v2
prompt.fileswith amimefield. OpenCode’s v2PromptInput.FileAttachmentrequest shape acceptsuriplus optionalname/description/mention;mimeis response-only and inferred by the server. Mid-turn steers that include attachments can fail validation or drop files.Reviewed by Cursor Bugbot for commit b49bea4. Configure here.