diff --git a/docs/api-reference/veryfront/embedding.md b/docs/api-reference/veryfront/embedding.md index 2ff6a25435..0fc01d72a6 100644 --- a/docs/api-reference/veryfront/embedding.md +++ b/docs/api-reference/veryfront/embedding.md @@ -42,7 +42,7 @@ export const { POST, GET, DELETE } = createUploadHandler(store, { | `ragStore` | Creates a persistent RAG store with lazy embedding and similarity search. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/embedding/rag-store.ts#L212) | | `registerEmbeddingProvider` | Register an embedding provider factory. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/embedding/resolve.ts#L25) | | `resolveEmbeddingModel` | Resolve a "provider/model" string to an embedding runtime instance. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/embedding/resolve.ts#L116) | -| `similarity` | Compute cosine similarity between two numeric vectors. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/runtime/runtime-bridge.ts#L973) | +| `similarity` | Compute cosine similarity between two numeric vectors. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/runtime/runtime-bridge.ts#L975) | | `vectorStore` | Creates an in-memory vector store with integrated embedding and similarity search. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/embedding/vector-store.ts#L46) | ### Types diff --git a/src/runtime/runtime-bridge.test.ts b/src/runtime/runtime-bridge.test.ts index 5942a7b3bf..4a4ee36d61 100644 --- a/src/runtime/runtime-bridge.test.ts +++ b/src/runtime/runtime-bridge.test.ts @@ -1186,6 +1186,69 @@ describe("runtime-bridge", () => { }]); }); + it("keeps providerExecuted on direct generate provider tool results", async () => { + // Mirrors what ext-llm-anthropic's buildAnthropicGenerateResult and + // ext-llm-openai's Responses normalizer actually return from doGenerate: + // server-side tool results always carry providerExecuted: true. + const model = createGenerateModel( + "anthropic", + "anthropic/test-direct-provider-executed-generate", + async () => ({ + content: [ + { + type: "tool-call", + toolCallId: "tool-web-3", + toolName: "web_search", + input: '{"query":"Veryfront"}', + providerExecuted: true, + }, + { + type: "tool-result", + toolCallId: "tool-web-3", + toolName: "web_search", + result: [{ url: "https://veryfront.com", title: "Veryfront" }], + providerExecuted: true, + }, + { + type: "tool-result", + toolCallId: "tool-web-4", + toolName: "web_fetch", + result: { message: "fetch blocked" }, + isError: true, + providerExecuted: true, + }, + ], + finishReason: { unified: "stop", raw: "stop" }, + usage: { + inputTokens: { total: 6 }, + outputTokens: { total: 9 }, + }, + }), + ); + + const result = await generateText({ + model, + messages: [{ role: "user", content: "Research Veryfront" }], + temperature: 0, + }); + + assertEquals(result.toolResults, [ + { + toolCallId: "tool-web-3", + toolName: "web_search", + result: [{ url: "https://veryfront.com", title: "Veryfront" }], + providerExecuted: true, + }, + { + toolCallId: "tool-web-4", + toolName: "web_fetch", + result: { message: "fetch blocked" }, + isError: true, + providerExecuted: true, + }, + ]); + }); + it("uses the direct stream path for provider-native web_fetch", async () => { const model = createStreamModel( "anthropic", diff --git a/src/runtime/runtime-bridge.ts b/src/runtime/runtime-bridge.ts index 139bcec4d5..bb653646cd 100644 --- a/src/runtime/runtime-bridge.ts +++ b/src/runtime/runtime-bridge.ts @@ -540,6 +540,7 @@ function isDirectToolResultPart( toolName: string; result: unknown; isError?: boolean; + providerExecuted?: boolean; } { return !!part && typeof part === "object" && @@ -579,6 +580,7 @@ function buildDirectGenerateResult( toolName: part.toolName, result: part.result, ...(part.isError === true ? { isError: true } : {}), + ...(part.providerExecuted === true ? { providerExecuted: true } : {}), }); } }