-
Notifications
You must be signed in to change notification settings - Fork 905
feat(adapters): annotate present-but-empty tool outputs (DeepSeek default) #2350
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
Draft
harryzhou2000
wants to merge
12
commits into
lidge-jun:dev
Choose a base branch
from
harryzhou2000:fix/annotate-empty-tool-outputs
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9f9f1c4
feat(adapters): annotate present-but-empty tool outputs (DeepSeek def…
harryzhou2000 742479c
fix(adapters): annotate whitespace-only text-part arrays on the chat …
harryzhou2000 67d56bf
test(adapters): cover orphaned empty tool results on the chat wire
harryzhou2000 5eb1907
docs(types): end the annotateEmptyToolOutputs comment sentence
harryzhou2000 d7106a6
fix(adapters): never annotate non-text Responses tool outputs; shared…
harryzhou2000 b5dd29b
fix(adapters): treat Responses input_text/output_text parts as wire t…
harryzhou2000 5db0968
fix(adapters): annotate empty tool outputs before stateless orphan re…
harryzhou2000 564adc9
fix(adapters): never annotate missing/null tool outputs; pin DeepSeek…
harryzhou2000 0dd0784
fix(management): validate annotateEmptyToolOutputs off the auth surface
harryzhou2000 7b5ecd3
fix(management): redact provider name in annotation error; support PA…
harryzhou2000 3db0316
fix(ci): bump dev version and avoid privacy-scan flag in release-trai…
harryzhou2000 e3be23e
revert(ci): keep SSH deploy-key push in upstream release devlog
harryzhou2000 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
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,43 @@ | ||
| /** | ||
| * Shared wire text and emptiness contract for present-but-empty tool outputs. | ||
| * | ||
| * Both the OpenAI Chat and Responses adapters use this module so the two wires | ||
| * cannot drift again: only a pure text/refusal part array whose joined content | ||
| * trims empty is "present but empty". Image, file, encrypted-content and any | ||
| * other non-text part is real output and is never replaced by the annotation. | ||
| */ | ||
|
|
||
| /** Wire text used when a present-but-empty tool output must stay visible to the model. */ | ||
| export const EMPTY_TOOL_OUTPUT_ANNOTATION = | ||
| "[ocx] empty tool output: the tool ran but produced no stdout or return value; do not treat this as success, failure, or user-provided input."; | ||
|
|
||
| function isPlainObject(value: unknown): value is Record<string, unknown> { | ||
| return typeof value === "object" && value !== null && !Array.isArray(value); | ||
| } | ||
|
|
||
| /** Part types that carry wire text on either adapter (Chat uses `text`, Responses uses `input_text`/`output_text`). */ | ||
| const TEXT_PART_TYPES = new Set(["text", "input_text", "output_text"]); | ||
|
|
||
| /** | ||
| * True when every part is text/refusal and the joined text/refusal content trims | ||
| * empty. An empty array is the array twin of a blank string. Any image, file, | ||
| * encrypted-content or other non-text part makes the array non-empty so the | ||
| * model still receives the real payload. | ||
| */ | ||
| export function isWhitespaceOnlyTextPartArray(parts: readonly unknown[]): boolean { | ||
| if (parts.length === 0) return true; | ||
| let joined = ""; | ||
| for (const part of parts) { | ||
| if (!isPlainObject(part)) return false; | ||
| if (typeof part.type === "string" && TEXT_PART_TYPES.has(part.type) && typeof part.text === "string") { | ||
| joined += part.text; | ||
| continue; | ||
| } | ||
| if (part.type === "refusal" && typeof part.refusal === "string") { | ||
| joined += part.refusal; | ||
| continue; | ||
| } | ||
| return false; | ||
| } | ||
| return joined.trim() === ""; | ||
| } |
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
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
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.