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
2 changes: 1 addition & 1 deletion docs/api-reference/veryfront/embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 63 additions & 0 deletions src/runtime/runtime-bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/runtime-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ function isDirectToolResultPart(
toolName: string;
result: unknown;
isError?: boolean;
providerExecuted?: boolean;
} {
return !!part &&
typeof part === "object" &&
Expand Down Expand Up @@ -579,6 +580,7 @@ function buildDirectGenerateResult(
toolName: part.toolName,
result: part.result,
...(part.isError === true ? { isError: true } : {}),
...(part.providerExecuted === true ? { providerExecuted: true } : {}),
});
}
}
Expand Down