[feature] adds web_search and fetch_url tool calls
This commit is contained in:
@@ -112,6 +112,12 @@ Behavior notes:
|
||||
- For `chatId` calls, server stores only *new* non-assistant messages from provided history to avoid duplicates.
|
||||
- Server persists final assistant output and call metadata (`LlmCall`) in DB.
|
||||
- Server updates chat-level model metadata on each call: `lastUsedProvider`/`lastUsedModel`; first successful/failed call also initializes `initiatedProvider`/`initiatedModel` if unset.
|
||||
- For `openai` and `xai`, backend enables tool use during chat completion with an internal system instruction.
|
||||
- Available tool calls for chat: `web_search` and `fetch_url`.
|
||||
- `web_search` uses Exa and returns ranked results with per-result summaries/snippets.
|
||||
- `fetch_url` fetches a URL and returns plaintext page content (HTML converted to text server-side).
|
||||
- When a tool call is executed, backend stores a chat `Message` with `role: "tool"` and tool metadata (`metadata.kind = "tool_call"`), then stores the assistant output.
|
||||
- `anthropic` currently runs without server-managed tool calls.
|
||||
|
||||
## Searches
|
||||
|
||||
@@ -171,7 +177,8 @@ Search run notes:
|
||||
"createdAt": "...",
|
||||
"role": "system|user|assistant|tool",
|
||||
"content": "...",
|
||||
"name": null
|
||||
"name": null,
|
||||
"metadata": null
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -37,8 +37,9 @@ Notes:
|
||||
|
||||
Event order:
|
||||
1. Exactly one `meta`
|
||||
2. Zero or more `delta`
|
||||
3. Exactly one terminal event: `done` or `error`
|
||||
2. Zero or more `tool_call`
|
||||
3. Zero or more `delta`
|
||||
4. Exactly one terminal event: `done` or `error`
|
||||
|
||||
### `meta`
|
||||
|
||||
@@ -60,6 +61,23 @@ Event order:
|
||||
|
||||
`text` may contain partial words, punctuation, or whitespace.
|
||||
|
||||
### `tool_call`
|
||||
|
||||
```json
|
||||
{
|
||||
"toolCallId": "call_123",
|
||||
"name": "web_search",
|
||||
"status": "completed",
|
||||
"summary": "Performed web search for 'latest CPI release'.",
|
||||
"args": { "query": "latest CPI release" },
|
||||
"startedAt": "2026-03-02T10:00:00.000Z",
|
||||
"completedAt": "2026-03-02T10:00:00.820Z",
|
||||
"durationMs": 820,
|
||||
"error": null,
|
||||
"resultPreview": "{\"ok\":true,...}"
|
||||
}
|
||||
```
|
||||
|
||||
### `done`
|
||||
|
||||
```json
|
||||
@@ -84,10 +102,15 @@ Event order:
|
||||
|
||||
## Provider Streaming Behavior
|
||||
|
||||
- `openai`: streamed via OpenAI chat completion chunks; emits `delta` from `choices[0].delta.content`.
|
||||
- `xai`: uses OpenAI-compatible API, same chunk extraction as OpenAI.
|
||||
- `openai`: backend may execute internal tool calls (`web_search`, `fetch_url`) before producing final text.
|
||||
- `xai`: same tool-enabled behavior as OpenAI.
|
||||
- `anthropic`: streamed via event stream; emits `delta` from `content_block_delta` with `text_delta`.
|
||||
|
||||
Tool-enabled streaming notes (`openai`/`xai`):
|
||||
- Stream still emits standard `meta`, `delta`, `done|error` events.
|
||||
- Stream may emit `tool_call` events before final assistant text.
|
||||
- `delta` may arrive as one consolidated chunk after tool execution, rather than many token-level chunks.
|
||||
|
||||
## Persistence + Consistency Model
|
||||
|
||||
Backend database remains source of truth.
|
||||
|
||||
Reference in New Issue
Block a user