Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixes/16978-workbuddy-gateway-compliance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **fix(workbuddy):** Adapt WorkBuddy AI reverse-proxy headers and tool/turn compliance to prevent gateway errors (`10085`, `11101`, `11128`, `11133`, `11153`). Enforces mandatory `WorkBuddy/5.5.6` client identity, stable turn/conversation tracking header family (`X-Conversation-*`), first-turn system prompt injection, Gemini tool-result turn alignment, and deep tool schema normalization for DeepSeek/Kimi/GLM models. Adds alias `wbai`. ([#16978](https://github.com/diegosouzapw/OmniRoute/issues/16978))
17 changes: 16 additions & 1 deletion open-sse/config/providers/registry/workbuddy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,18 @@ export const workbuddyProvider: RegistryEntry = {
authHeader: "Authorization",
authPrefix: "Bearer ",
// Required on every gateway route, including the device-flow endpoints.
headers: { "X-Product": "SaaS" },
headers: {
"User-Agent": "WorkBuddy/5.5.6",
"X-Product": "SaaS",
"X-IDE-Type": "WorkBuddy",
"X-IDE-Name": "WorkBuddy",
"X-IDE-Version": "5.5.6",
"X-Requested-With": "XMLHttpRequest",
"X-Agent-Intent": "craft",
"X-Agent-Purpose": "conversation",
"X-Agent-Type": "main",
"X-Domain": "www.workbuddy.ai",
},
oauth: {
initiateUrl: "https://www.workbuddy.ai/v2/plugin/auth/state?platform=CLI",
pollUrlBase: "https://www.workbuddy.ai/v2/plugin/auth/token",
Expand All @@ -54,6 +65,10 @@ export const workbuddyProvider: RegistryEntry = {
bodyStringReplacements: [
// The gateway refuses a request whose body names another agent client.
// Longest first, so "Codex CLI" is not half-replaced by the "Codex" rule.
["x-anthropic-billing-header:", ""],
["You are Claude Code, Anthropic's official CLI for Claude", "You are Claude Code, Anthropic's CLI for Claude"],
["Main branch (you will usually use this for PRs)", "Main branch (usually the base for PRs)"],
["Codex CLI is an open source project led by OpenAI.", "The Codex CLI is an open source project led by OpenAI."],
["Codex CLI", "the assistant"],
["codex_cli_rs", "assistant"],
["OpenAI", "the provider"],
Expand Down
9 changes: 9 additions & 0 deletions open-sse/executors/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { resolveAlibabaProviderBaseUrl } from "@/shared/constants/alibabaProvide
import { xiaomiAlternateUrl, xiaomiMimoChatUrl } from "./default/xiaomiTokenPlan.ts";
import { usesCcWireImage } from "../services/ccWireImageBuiltins.ts";
import { applyRegistryBodyRepairs } from "../utils/strictChatHistory.ts";
import { withWorkbuddyHeaders, sanitizeWorkbuddyBody } from "../utils/workbuddyGateway.ts";

const NVIDIA_TOOL_CALL_ID_PATTERN = /^[A-Za-z0-9]{9}$/;
const PERPLEXITY_AGENT_DEFAULT_MAX_OUTPUT_TOKENS = 4096;
Expand Down Expand Up @@ -711,6 +712,10 @@ export class DefaultExecutor extends BaseExecutor {

normalizeAnthropicHeaderVariants(headers);

if (this.provider === "workbuddy") {
withWorkbuddyHeaders(headers, body);
}

return headers;
}

Expand Down Expand Up @@ -1058,6 +1063,10 @@ export class DefaultExecutor extends BaseExecutor {

applyRegistryToolNameLengthAliases(this.provider, withDefaults);

if (this.provider === "workbuddy") {
withDefaults = sanitizeWorkbuddyBody(withDefaults);
}

return applyRegistryBodyRepairs(this.provider, withDefaults);
}

Expand Down
2 changes: 2 additions & 0 deletions open-sse/services/providerAlias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ ALIAS_TO_PROVIDER_ID["agy"] = "antigravity";
// The canonical provider ID is "amazon-q". Register it so parseModel("aq/<model>")
// resolves provider = "amazon-q" instead of falling through to the identity fallback.
ALIAS_TO_PROVIDER_ID["aq"] = "amazon-q";
// wbai/ is the user-visible prefix for WorkBuddy AI (Issue #16978).
ALIAS_TO_PROVIDER_ID["wbai"] = "workbuddy";

/**
* Resolve provider alias to provider ID
Expand Down
2 changes: 2 additions & 0 deletions open-sse/services/tokenRefresh/providers/workbuddy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function postRefreshRequest(url: string, refreshToken: string, proxyConfig: unkn
Accept: "application/json",
"X-Refresh-Token": refreshToken,
"X-Product": "SaaS",
"X-Domain": "www.workbuddy.ai",
"User-Agent": "WorkBuddy/5.5.6",
},
body: "{}",
})
Expand Down
Loading
Loading