mirror of
https://gitee.com/zhangsken/opencode.git
synced 2026-10-16 10:30:01 +08:00
refactor(ai): default route tool namespaces to flat
This commit is contained in:
@@ -60,7 +60,8 @@ export interface Route<
|
||||
readonly body: RouteBody<Body>
|
||||
readonly supportsEffortUpdates?: (request: LLMRequest) => boolean
|
||||
readonly sanitizer?: LanguageModelSanitizerCompatibility
|
||||
readonly namespaces: NamespaceStyle
|
||||
/** How protocol bodies receive tool namespaces; defaults to `"flat"`. */
|
||||
readonly namespaces?: NamespaceStyle
|
||||
readonly with: {
|
||||
<Next extends CompactionOperations | undefined>(
|
||||
patch: RoutePatch<Body, Prepared> & { readonly compact: Next },
|
||||
@@ -393,7 +394,7 @@ function makeFromTransport<Body, Prepared, Frame, Event, State>(
|
||||
body: protocol.body,
|
||||
supportsEffortUpdates: protocol.supportsEffortUpdates,
|
||||
sanitizer: protocol.sanitizer,
|
||||
namespaces: protocol.namespaces ?? "flat",
|
||||
namespaces: protocol.namespaces,
|
||||
with: (patch: RoutePatch<Body, Prepared>) => {
|
||||
const { compact, id, provider, providerMetadataKey, auth, transport, endpoint, ...defaults } = patch
|
||||
return build({
|
||||
@@ -576,7 +577,8 @@ const prepareRequest = (request: LLMRequest) => {
|
||||
}
|
||||
|
||||
// Protocols receive wire tool names; callers keep declared names in both directions.
|
||||
const lowerRequest = (request: LLMRequest) => ToolNames.lower(prepareRequest(request), request.model.route.namespaces)
|
||||
const lowerRequest = (request: LLMRequest) =>
|
||||
ToolNames.lower(prepareRequest(request), request.model.route.namespaces ?? "flat")
|
||||
|
||||
const compile = Effect.fn("LLM.compile")(function* (request: LLMRequest, options?: StreamOptions) {
|
||||
const lowered = yield* lowerRequest(request)
|
||||
|
||||
@@ -368,7 +368,6 @@ function modelFromLanguage(info: RuntimeInfo, language: LanguageModelV3) {
|
||||
protocol: "ai-sdk",
|
||||
// AI SDK providers convert tool schemas themselves, so model-family sanitizers stay off here.
|
||||
sanitizer: "none",
|
||||
namespaces: "flat",
|
||||
endpoint: Endpoint.path("/", { baseURL: "https://ai-sdk.local" }),
|
||||
auth: Auth.none,
|
||||
transport: {
|
||||
|
||||
Reference in New Issue
Block a user