-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(chat): preserve OCG DeepSeek timeline system instructions #4473
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
131b21e
7dc6c00
6645ccb
7968347
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 |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import type { AdapterRequest, IncomingMeta, ProviderAdapter } from "./base"; | |
| import type { AdapterEvent, OcxAssistantMessage, OcxContentPart, OcxMessage, OcxParsedRequest, OcxProviderConfig, OcxTextContent, OcxThinkingContent, OcxToolCall, OcxUsage } from "../types"; | ||
| import { isAllowedToolChoice, modelInList, namespacedToolName, resolveToolChoiceWireName, toolChoiceToolPredicate } from "../types"; | ||
| import { mapReasoningEffort, modelRecordValue } from "../reasoning-effort"; | ||
| import { registryEntryForProviderDestination } from "../providers/registry"; | ||
| import { debugProviderDiagnostic } from "../lib/debug"; | ||
| import { sseFieldValue } from "../lib/sse-decoder"; | ||
| import { isDebugEnabled } from "../lib/debug-settings"; | ||
|
|
@@ -738,10 +739,14 @@ function messagesToChatFormat(parsed: OcxParsedRequest, provider: OcxProviderCon | |
| }; | ||
|
|
||
| const nativeOpenAI = isNativeOpenAIChatTarget(provider); | ||
| // Hoisting a newly appended reminder rewrites the reusable prompt prefix. | ||
| // Keep this compatibility exception on the destination/model tested with OCG. | ||
| const chronologicalSystem = parsed.modelId === "deepseek-v4.1-flash" | ||
| && registryEntryForProviderDestination(provider)?.id === "opencode-go"; | ||
|
Comment on lines
+744
to
+745
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.
This changes request serialization under AGENTS.md reference: structure/AGENTS.md:L49-L50 Useful? React with 👍 / 👎. |
||
| const toolCatalogNudge = shouldInjectNonOpenAIToolCatalogNudge(provider) | ||
| ? buildNonOpenAIToolCatalogNudgeForTools(context.tools, options.toolChoice) | ||
| : undefined; | ||
| const developerSystemParts = nativeOpenAI | ||
| const developerSystemParts = nativeOpenAI || chronologicalSystem | ||
| ? [] | ||
| : context.messages | ||
| .map(developerSystemText) | ||
|
|
@@ -767,11 +772,15 @@ function messagesToChatFormat(parsed: OcxParsedRequest, provider: OcxProviderCon | |
| const hasImages = parts?.some(p => p.type === "image") ?? false; | ||
| let chatMsg: Record<string, unknown>; | ||
| if (msg.role === "developer" && !hasImages) { | ||
| if (!nativeOpenAI) break; | ||
| if (!nativeOpenAI && !chronologicalSystem) break; | ||
| const text = typeof msg.content === "string" | ||
| ? msg.content | ||
| : parts!.map(p => (p as OcxTextContent).text).join(""); | ||
| chatMsg = { role: "developer", content: text }; | ||
| // A non-text timeline part (video, for example) serializes to nothing here. | ||
| // The generic path drops such a message; the chronological exception must not | ||
| // turn it into an empty system message that some upstreams reject. | ||
| if (!nativeOpenAI && text.length === 0) break; | ||
| chatMsg = { role: nativeOpenAI ? "developer" : "system", content: text }; | ||
| } else if (typeof msg.content === "string") { | ||
| chatMsg = { role: "user", content: msg.content }; | ||
| } else if (!hasImages) { | ||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Document that reminders follow all pending tool results.
In
src/adapters/openai-chat.ts,messagesToChatFormatdefers reminders whilependingToolCalls.length > 0and releases them only when the count reaches zero. With parallel tool calls, “after any pending tool results” may imply that one result is sufficient. Change it to “after all pending tool results” to match the ordering behavior covered bytests/adapters/openai/openai-chat-system-order.test.ts.🤖 Prompt for AI Agents