Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(model-hub): turn on web_fetch (WF-3) (#2982)

Call White08adc50687f5
diff --git a/config/v2_config.py b/config/v2_config.py
index 6871229b1..f49da2973 100644
--- a/config/v2_config.py
+++ b/config/v2_config.py
@@ -3045,8 +3045,8 @@ class ModelHubAgentSupplyConfig:
# through the executor, and the direct image tool.
MODEL_HUB_SEARCH_TOOLS: tuple[str, ...] = ("web_search", "x_search")
MODEL_HUB_HOSTED_TOOLS: tuple[str, ...] = (*MODEL_HUB_SEARCH_TOOLS, "image_generate", "web_fetch")
-# Readers precede every producer release; activation is coordinated with public disclosure.
-WEB_FETCH_ACTIVE = False
+# WF-3 enables read, declaration and producer together; coordinated release decision: docs/plans/web-fetch.md §8.
+WEB_FETCH_ACTIVE = True
def _drop_vibey_client_presets(agent: "ModelHubAgentSupplyConfig") -> None:
diff --git a/core/agent_core/agent/loop.py b/core/agent_core/agent/loop.py
index c1aa5f1cf..64b91ba8b 100644
--- a/core/agent_core/agent/loop.py
+++ b/core/agent_core/agent/loop.py
@@ -152,6 +152,7 @@ from core.agent_core.hosted_continuations import pending_hosted
from core.agent_core.messages import (
AssistantMessage,
HostedImage,
+ HostedRecord,
Message,
Origin,
ToolCallBlock,
@@ -1433,7 +1434,8 @@ class Agent:
self._rows.append(row)
# The committed result, which a settlement race may have taken from another writer, not this execution's.
committed = row.message.hosted if isinstance(row.message, ToolResultMessage) else None
- if committed is not None and committed.record.status == "completed" and call.name == "image_generate":
+ if (committed is not None and isinstance(committed.record, HostedRecord)
+ and committed.record.status == "completed" and call.name == "image_generate"):
# Only an image a surface can deliver counts toward the reply, and is carried with it.
self._generated_images.extend(image for image in committed.record.images or () if image_deliverable(image))
if emit_finished:
diff --git a/core/handlers/model_hub/service.py b/core/handlers/model_hub/service.py
index 47e3f8962..dbfafe9c8 100644
--- a/core/handlers/model_hub/service.py
+++ b/core/handlers/model_hub/service.py
@@ -7305,7 +7305,7 @@ class ModelHubService:
return {}
async def _run_fetch_chain(self, call: ExecutorCall, turn: TurnHostedTools, *, say: Callable[..., str]) -> dict:
- """Run the dormant web_fetch service/local chain behind the activation flag."""
+ """Run the web_fetch service/local chain behind the shared activation switch."""
from .fetch_chain import FetchChain
return await FetchChain(self, call, turn, say).run()
diff --git a/docs/plans/agent-core-contracts/README.md b/docs/plans/agent-core-contracts/README.md
index 63cacba3c..623bd3d69 100644
--- a/docs/plans/agent-core-contracts/README.md
+++ b/docs/plans/agent-core-contracts/README.md
@@ -28,8 +28,10 @@ Conventions:
are unchanged. Executor origins accept `fetch_api` and `local_fetch`, not
assistant-model origins. Attempts accept `local`.
- C-6 recognizes function-only fetch facts (`native` and `replay` both
- `unsupported`). The dormant build never declares or executes fetch; records,
- activity and usage remain readable. #2920's released rc4 reader preserves the
+ `unsupported`). WF-3 enables declaration and execution through the shared
+ `WEB_FETCH_ACTIVE` switch; records, activity and usage remain readable even
+ when the switch is false. The coordinated reader/activation release decision is
+ in `../web-fetch.md` §8. #2920's released rc4 reader preserves the
full ordinary quotation when discarding unknown hosted metadata. Config and
usage downgrade writes are intentionally lossy as disclosed in the owning plan.
diff --git a/docs/plans/agent-core-contracts/model-hub-consumer.md b/docs/plans/agent-core-contracts/model-hub-consumer.md
index 06ae21926..415c391d0 100644
--- a/docs/plans/agent-core-contracts/model-hub-consumer.md
+++ b/docs/plans/agent-core-contracts/model-hub-consumer.md
@@ -68,17 +68,18 @@ consumer's requirements, and the Model Hub lane lands the change in both places.
7. **Hosted tools** (v2, [`../vibey-hosted-tools.md`](../vibey-hosted-tools.md) §3.4, §3.5, §6, §7).
- `HopResolution.hosted_tools` has one entry per hosted tool the turn declares:
- - **`web_fetch`** (WF-1/WF-2V, unreleased v21) has exactly
+ - **`web_fetch`** (WF-1/2/3, v21) has exactly
`{native: "unsupported", replay: "unsupported"}`: always function-only,
- never Claude-native. Both its server entry and Vibey registration remain
- absent while `WEB_FETCH_ACTIVE = False`. When active, the first resolution
+ never Claude-native. WF-3 enables its server entry, Vibey registration and
+ producer with `WEB_FETCH_ACTIVE = True`; an explicit false hides them and
+ rejects execution. The first resolution
freezes its canonical `{url}`-only function beside the other turn tools.
Vibey posts `{"arguments": {"url": ...}}` under the live turn to
`/hosted-tools/web_fetch`; the gateway owns normalization and the budget.
The validated record produces C-1's complete capped ordinary quotation
through the same deterministic frame used by readers. Replay preserves
- the stored call/result without a fetch or settlement. Activation belongs
- to WF-3, after a reader release.
+ the stored call/result without a fetch or settlement. The owner chose to
+ ship readers and activation together (`../web-fetch.md` §8).
- **a search tool** (`web_search`, `x_search`) gives the primary hop's facts:
- `native` is `assumed` when the tool runs on the hop (`hosted_tools.runs_on`: a hub Source with an eligible
credential, never a Claude subscription, and an untranslated path, that serves the model, for which the
diff --git a/docs/plans/model-hub-contracts/README.md b/docs/plans/model-hub-contracts/README.md
index 108502100..1fd601922 100644
--- a/docs/plans/model-hub-contracts/README.md
+++ b/docs/plans/model-hub-contracts/README.md
@@ -1,7 +1,7 @@
# Model Hub contracts
-Status: **contract_version 21**, 2026-10-25: keyless Exa activation (KEX-3)
-and dormant fetch readers (WF-1) / Vibey and UI producer support (WF-2V).
+Status: **contract_version 21**, 2026-10-26: keyless Exa activation (KEX-3)
+and web fetch readers, producers and coordinated activation (WF-1/2/3).
`gh-v3.2.3rc3` through `rc7` carry v20, so the unreleased v21 event now includes
its coordinated readers, producer, and default-on Exa search activation. The versioned
mirrors advance together; persisted TurnProvenance retains v5–v20 and adds v21.
@@ -16,8 +16,9 @@ WF-1 appends dormant `web_fetch` readers to this unreleased event:
separate fetch consent/order, local/Exa/Jina synthetic identities, fetch/local
executor origins and local attempts, C-1 bounded fetch records, C-6 function-only
facts, and optional service usage `tool` attribution (absent means `web_search`).
-`WEB_FETCH_ACTIVE = False` keeps GET/candidates/declarations/active settings UI
-unchanged; historical reads and V2/PUT preservation do not depend on activation.
+WF-1 originally kept `WEB_FETCH_ACTIVE = False`, leaving GET/candidates/
+declarations/active settings UI unchanged; historical reads and V2/PUT preservation
+do not depend on activation.
The exact shapes and downgrade losses are owned by [`../web-fetch.md`](../web-fetch.md)
§§2/4/6/8. WF-1 adds no fetch producer, network transport or dependency.
The localized hosted-activity vocabulary adds `service_rate_limited` as a fallback
@@ -33,7 +34,18 @@ activity projection adds optional `policy_sources` (service ids reached before
an address-policy refusal; an empty list means not forwarded). Web and IM read
that one decision, localize synthetic labels, and retain historical readability
regardless of activation. See [`../web-fetch-vibey-ui.md`](../web-fetch-vibey-ui.md)
-for fixture acceptance and intentional boundaries. The production flag stays off.
+for fixture acceptance and intentional boundaries.
+
+WF-3 sets `WEB_FETCH_ACTIVE = True` across the read, candidates, frozen declaration
+and gateway producer after the WF-2G engine/chain/provider PRs (#2962/#2968/#2976).
+It changes no serialized shape or contract version. Missing fetch config uses the
+automatic local → configured services → keyless Exa → keyless Jina order without
+writing defaults; saved fetch opt-outs and ordering remain independent of search.
+Public en/zh disclosure ships with activation (`avibe-docs#83`); §7 of the owning
+plan specifies up/down buttons, not drag. **Owner decision, 2026-10-26 01:56
+Asia/Shanghai:** ship WF-1 readers and the activation flip together; no separate
+prior reader release is required. Exact-head review/CI and coordinated activation/
+disclosure acceptance still apply. See [`../web-fetch.md`](../web-fetch.md) §8.
It builds on v20 (2026-10-22): active web-search services (S2b-2).
`gh-v3.2.3rc1` and `gh-v3.2.3rc2` carried v19, so activation opened v20 rather than
diff --git a/docs/plans/model-hub-contracts/api.md b/docs/plans/model-hub-contracts/api.md
index 6ac87c849..2a35cf5fc 100644
--- a/docs/plans/model-hub-contracts/api.md
+++ b/docs/plans/model-hub-contracts/api.md
@@ -73,7 +73,7 @@ runtime open. Once models are configured it participates in the runtime Stop gua
| GET `/api/models/quota` | → `{quota: QuotaSummary}` | Rate-limit windows of every hub-held subscription Source, from the vendor's own usage report, plus each Source's API-price `value` (see Subscription quota). Served from the server cache; a Source older than five minutes is re-read before answering, bounded by a short deadline, and a Source still being read is listed in `pending`. Never starts the engine. |
| POST `/api/models/quota/refresh` | → `{quota: QuotaSummary}` | Forced re-read. Rate-limited per Source to one vendor call every 30 seconds and suppressed while a Source cools down after a vendor 429; a suppressed Source returns its cached snapshot. |
| GET `/api/models/hosted-tools` | → `{hosted_tools: HostedToolsStatus}` | Models → Tools (`hosted-tools-status.schema.json`): every catalog tool with its switch (absent setting = on), its passive status from real use (`latest_ok`, current `refused[]`, per-pair `verified[]`), for a search tool the saved and effective executor order with every eligible executor candidate and its unit rates, and for `image_generate` the saved and effective default and the available image models. Memory only; nothing is probed. |
-| POST `/api/models/hosted-tools/web_fetch/services/<source_id>/retry` | `{}` → `{}` | WF-1 reader/control only: clears the same Source/service cooldown and generation as search for Exa (`src_exakeyless`, `exa/mcp`), or Jina's own. Member management role; no fetch is sent. Local has no whole-executor retry and returns `404 source_not_found`. |
+| POST `/api/models/hosted-tools/web_fetch/services/<source_id>/retry` | `{}` → `{}` | Clears the same Source/service cooldown and generation as search for Exa (`src_exakeyless`, `exa/mcp`), or Jina's own. Member management role; no fetch is sent. Local has no whole-executor retry and returns `404 source_not_found`. |
| POST `/api/models/hosted-tools/web_search/services/<source_id>/retry` | `{}` → `{}` | Clears the controller's `(Source, service)` cooldown, advances its generation, and leaves Source health unchanged. The Tools read is the follow-up source of truth. Member management role. |
| PUT `/api/models/hosted-tools/<tool>` | `{enabled?: boolean, executor_order?: null \| [source_id], default_model?: null \| {source_id, model_id}, prefer_native?: boolean, services?: {source_id: null \| {results?: integer \| null, enabled?: boolean \| null}}}` → `{hosted_tools: HostedToolsStatus}` | Changes one tool's settings field by field: an absent field is unchanged, `null` resets `executor_order` to automatic or `default_model` to the default. `executor_order` is for search/fetch tools and `default_model` for `image_generate`; values are saved as given, never resolved. It applies from the next turn and interrupts nothing. An unknown tool returns `404 hosted_tool_not_found`; an empty or malformed body `400 invalid_parameter`, including a null `enabled`, an id that is not a Source id (`src_…`), or a model id with surrounding whitespace. |
| POST `/api/models/hosted-tools/<tool>/clear` | `{source_id?, model_id?}` → `{hosted_tools: HostedToolsStatus}` | Clears the tool's refusals (`call` and `replay`): on one Source and model, on one Source (every model), or with `{}` on every Source. `model_id` requires `source_id`; neither is nullable, so a malformed body is refused rather than widened into a broader clear. A Source or model with nothing to clear is a no-op that answers the read. The file is written first: a failed write returns `500 state_write_failed` and changes nothing. A cleared Source is assumed again from its next request. An unknown tool returns `404 hosted_tool_not_found`; any other body `400 invalid_parameter`. |
@@ -140,7 +140,7 @@ reader and producer together, with the public disclosure shipped in the same v21
event.
PUT accepts `prefer_native` only for `web_search`; search's `services` patch includes
-`results`, while fetch accepts enabled-only patches (see WF-1 below). `prefer_native`
+`results`, while fetch accepts enabled-only patches (see Web fetch below). `prefer_native`
is a boolean, not nullable. `services` is a Source-keyed patch: an absent Source
is untouched, a present object merges only its supplied fields, and a null
Source or null field removes its saved override. An empty patch is a no-op.
@@ -180,12 +180,15 @@ orders. Re-upgrading then uses service defaults; reapply DeepSeek's opt-out
before enabling service execution. This is not a promise to retain new choices
through an older release's write.
-### Dormant fetch readers (WF-1)
+### Web fetch (WF-1 readers, WF-3 activation)
-`web_fetch` is a known saved tool in contract v21, but while `WEB_FETCH_ACTIVE`
-is false it is absent from GET, effective candidates, model declarations and
-active settings UI. V2 and PUT retain its settings; historical activity and
-usage remain readable. There is no fetch execution endpoint in WF-1.
+`web_fetch` is active in contract v21. The shared `WEB_FETCH_ACTIVE = True`
+switch enables GET, effective candidates, model declarations and the gateway
+producer together. An explicit false still omits the active surfaces and refuses
+execution; V2/PUT settings and historical activity/usage remain readable.
+The canonical `{url}` function uses `/hosted-tools/web_fetch` on the live Vibey
+turn; it is never a native Claude fetch. The owner's coordinated reader/activation
+release decision and public disclosure are in `web-fetch.md` §8.
PUT accepts `{enabled?, executor_order?, services?}` for fetch: each service patch
has only nullable `enabled`; no `results`, `prefer_native` or client-written
@@ -193,7 +196,7 @@ roles. Null resets an override/order, absent fields are untouched. An explicit
order save captures the current `local`/`service` roles. Independent ordering,
automatic insertion and disabled-tail rules are specified in `web-fetch.md` §2.
-The future active GET entry is `FetchTool` in `hosted-tools-status.schema.json`:
+The active GET entry is `FetchTool` in `hosted-tools-status.schema.json`:
`services` contains saved partial consent; candidate `settings` is `{enabled}`.
`service_vendors` carries `capabilities: ["web_fetch"]`, `content_types`, price,
Source ids and `{built_in, requires_setup, auto_enroll}`. The local executor and
diff --git a/docs/plans/model-hub-contracts/mirror-registry.json b/docs/plans/model-hub-contracts/mirror-registry.json
index 7906f1a73..9cab134cb 100644
--- a/docs/plans/model-hub-contracts/mirror-registry.json
+++ b/docs/plans/model-hub-contracts/mirror-registry.json
@@ -425,7 +425,7 @@
"decision_tables": [
{
"id": "D31",
- "domain": "readable hosted result tools including dormant fetch",
+ "domain": "readable hosted result tools including fetch",
"authority": {"kind": "schema_vocabulary", "schema": "capability-evidence.schema.json", "paths": ["/properties/feature/oneOf/1/properties/name"]},
"consumers": [{"kind": "typescript_string_union", "file": "ui/src/lib/hostedActivity.ts", "name": "HostedToolName"}]
},
diff --git a/docs/plans/web-fetch-gateway-delivery.md b/docs/plans/web-fetch-gateway-delivery.md
index 38369ad61..1c49ae970 100644
--- a/docs/plans/web-fetch-gateway-delivery.md
+++ b/docs/plans/web-fetch-gateway-delivery.md
@@ -1,24 +1,27 @@
# WF-2G gateway delivery
-Status: 2026-10-25, dormant implementation; `WEB_FETCH_ACTIVE=False`.
+Status: 2026-10-26, WF-2G complete: #2962, #2968 and #2976 merged.
+WF-2G kept `WEB_FETCH_ACTIVE=False`; WF-3 now prepares the coordinated activation
+and public disclosure. The owner chose a combined reader/activation release
+(see §8 of the owning plan). The sections below retain the split's history.
The behavior contract remains [web-fetch.md](web-fetch.md), especially §§3–6.
This plan narrows delivery units, not the activation/release scope.
## Delivery units and ownership
1. **Local engine and packaging:** PR #2962 merged. No activation.
-2. **Chain and keyless services:** PR #2968 retains the URL/DNS gate, local
+2. **Chain and keyless services:** PR #2968 merged with the URL/DNS gate, local
wiring, keyless Exa/Jina, ordered fallback, no-send/skipped contract,
additive fetch usage attribution, and endpoint routing.
-3. **Configured services:** a separate PR from the updated `master` after
- #2968 merges adds Tavily Extract, keyed Exa `/contents`, and DeepSeek Fetch.
- Both producer PRs must merge before WF-3 enables the feature.
+3. **Configured services:** PR #2976 merged from updated `master` after #2968,
+ adding Tavily Extract, keyed Exa `/contents`, and DeepSeek Fetch.
+ Both producer prerequisites are complete; WF-3 still requires review/CI and acceptance.
The gateway lane prepares exact-head review/CI evidence; the orchestrator owns
merging. No service restart, regression deployment, release or live paid probe is
part of this lane. Tests use test-owned state and loopback fixtures only.
-## Convergence boundary
+## Convergence boundary (historical #2968 split)
The third reviewed head of #2968 again had multiple provider-mapping/settlement
findings, triggering the orchestrator's split guard. The configured transport,
@@ -40,7 +43,7 @@ response → settlement lifecycle. Boundary tests now own these invariants:
| Boundary | Required evidence |
| --- | --- |
-| Dormancy | Global flag rejects stale turns; configured providers cannot reach either adapter or transport even in flag-enabled test fixtures. |
+| Activation boundary | Global flag rejects stale turns before local or configured transport admission. Configured providers became eligible only with #2976; WF-3 exercises defaults without flag-on test patches. |
| Admission | Every service submission re-gates only the original URL; a refusal stops forwarding but retains usage for earlier sent attempts. |
| Attempt ownership | One capped deadline starts before the shared Exa lock, includes subsequent transport work, and allows Jina fallback on expiry. |
| No-send | Disabled/unavailable/contended/over-budget candidates have only skipped facts, no usage, no capability success and no cooldown write. |
@@ -56,10 +59,10 @@ fixture in `tests/test_model_hub_keyless_exa.py`. Existing search-chain and fetc
reader tests cover shared cooldown/ledger/read compatibility. Local engine tests
remain the gate/transport/extraction owner; no live providers are test or CI inputs.
-## Configured-provider follow-up acceptance
+## Configured-provider follow-up acceptance (delivered in #2976)
-Build one explicit table across provider × response phase × failure scope before
-implementing the smaller PR:
+The separate follow-up used an explicit table across provider × response phase ×
+failure scope:
- request shapes: Tavily basic/Markdown `urls`, Exa `/contents` `ids` and bounded
text, DeepSeek `url`; use only the catalog endpoint and opaque credential owner;
diff --git a/docs/plans/web-fetch-vibey-ui.md b/docs/plans/web-fetch-vibey-ui.md
index c15e4d7dc..da103f5eb 100644
--- a/docs/plans/web-fetch-vibey-ui.md
+++ b/docs/plans/web-fetch-vibey-ui.md
@@ -5,6 +5,12 @@ Change contract, 2026-10-25. Implements the Vibey and UI portion of
owns gateway policy, network transports, extraction, normalization, settlement
and packaging. No gateway contract change is needed by this lane.
+Activation follow-up, 2026-10-26: WF-3 sets the shared flag to true after all
+WF-2G producers merged, with default-on boundary acceptance and public en/zh
+disclosure. At 01:56 Asia/Shanghai the owner chose to ship readers and activation
+together, without a separate reader-first release. The invariants below describe
+WF-2V's original dormant landing; the current contract is `web-fetch.md` §§7–8.
+
## Invariants
- The production `WEB_FETCH_ACTIVE` remains false. No function registration or
@@ -53,10 +59,39 @@ The existing WF-1 downgrade tests remain the authority for released-shape
loading and lossy old config/usage rewrites. They are not lossless downgrade
claims. The ordinary text path remains compatible with #2920.
+## WF-3 runtime acceptance and hosted-record audit
+
+The activation's direct tool test did not reach transcript commit. Real Vibey
+acceptance now exercises Anthropic wire → Agent loop → hosted tool/gateway HTTP
+→ result frame → SQLite transcript/media registration → dispatcher/mirror →
+activity API, then creates a fresh adapter for next-turn replay with fetch no
+longer declared. The table covers Local, keyless Exa, Jina and policy refusal on
+Web and Telegram, without live providers. A 200 must produce one committed
+`WebFetchRecord`, one card/IM line and an ordinary final answer, not an interrupted
+call; replay preserves that row and frame without another fetch or media entry.
+
+Audit of production search/image-only record access:
+
+| Owner | Type boundary |
+| --- | --- |
+| `storage/agent_transcript.py::_register_images` | Narrow to `HostedRecord` before enumerating images. `WebFetchRecord` is not a media container; previously this generic consumer raised before the result transaction committed. |
+| `core/agent_core/agent/loop.py::_commit_result` | Image collection requires both `HostedRecord` and `image_generate`; a fetch can never enter it. |
+| `core/agent_core/messages.py::_record_to_dict` | Dispatch fetch serialization before reading search sources/image fields. |
+| `core/agent_core/ai/hosted.py::record_text` | Dispatch to the bounded fetch frame before search/image formatting. |
+| `core/hosted_activity.py::proxy_activity` | Narrow fetch by type and project empty search sources/images plus the fetch record. Native activities accept only `HostedToolBlock`, whose record is validated as `HostedRecord`. |
+| Vibey image tool, media sink and shared mirror | Image tool decoding validates the image tool's record; the media sink accepts image bytes, not generic records. The mirror reads the projected card's image list, empty for fetch. |
+
+Primary regression: `tests/test_vibey_agent.py::test_web_fetch_survives_the_real_agent_commit_delivery_and_next_turn_replay`.
+It reproduced the exact `WebFetchRecord` missing `images` failure before the fix.
+Existing transcript media-sweep and image-generation tests retain positive image
+registration/delivery coverage; no dummy image/search fields are added to fetch.
+The orchestrator owns the separate local-Incus live-provider rerun before merge.
+
## Known by design
- No activation, release/tag, public-doc activation, deployment, service restart
- or local/remote regression update. WF-3 must first establish a reader release.
+ or local/remote regression update in the original WF-2V scope. WF-3's coordinated
+ activation and owner-controlled acceptance are described above.
- The Tools read has no live local-transport state. Per orchestrator approval,
Local detail shows the default Chrome 150 profile, fallback policy and limits;
only actual call records show transport degradation and its reason.
diff --git a/docs/plans/web-fetch.md b/docs/plans/web-fetch.md
index 8cadd974c..ff099e133 100644
--- a/docs/plans/web-fetch.md
+++ b/docs/plans/web-fetch.md
@@ -136,13 +136,14 @@ readers skip residual unknown ids without a write.
### 2.3 Read and controls
-`GET /api/models/hosted-tools` adds `web_fetch` **only after activation**. WF-1
-sets `WEB_FETCH_ACTIVE = False`: GET has no fetch entry, candidates, declaration
-or active settings UI. V2 and PUT still preserve saved fetch choices, while
-historical records, usage and activity are readable regardless of the flag.
-This dormant-read boundary was approved on 2026-10-25.
-
-Once active, the entry contains saved `services` and
+`GET /api/models/hosted-tools` includes `web_fetch` in WF-3, with the shared
+`WEB_FETCH_ACTIVE = True` switch enabling the read, candidates, declaration and
+producer together. WF-1/WF-2 kept that switch false until activation; an explicit
+false still hides the row/candidates/declaration and rejects producer calls.
+V2 and PUT preserve saved fetch choices, while historical records, usage and
+activity remain readable regardless of the flag.
+
+The active entry contains saved `services` and
`executor_order`, resolved `effective_order`, `executor_candidates`, status and
capability-bearing `service_vendors`. The candidate uses existing service fields:
`source_id`, `model_id` (service id), `kind`, `billing`, `relay`, dated `price`,
@@ -629,8 +630,10 @@ Built-ins do not become “removed Source” rows without a credential row.
Add **网页读取 / Web fetch** after Web search in Models → Tools. Header switch,
latest real result and **always-visible** numbered fetch-order list (including
-automatic state). Each row has the existing up/down/drag controls, enabled switch,
+automatic state). Each row has the existing up/down **buttons only**, enabled switch,
kind pill, provider/Local label, price/unit, capability badges and current status.
+There is no drag interaction: fetch follows web search's buttons-only ordering
+(owner-approved clarification, 2026-10-25).
Disabled rows remain at the tail. Reset to automatic writes null, never effective
defaults. No Claude-native/prefer-native row or “unverified” state.
@@ -691,9 +694,53 @@ Python/TypeScript mirrors, public routes and contract registry on one tested hea
| Phase | Scope / gate |
| --- | --- |
-| WF-1 readers | Config/read/record/usage/activity readers, synthetic identities, versioned mirrors and downgrade fixtures. Include #2920, release before any fetch producer writes. Hide active UI/candidates until activation. |
+| WF-1 readers | Config/read/record/usage/activity readers, synthetic identities, versioned mirrors and downgrade fixtures. Include #2920; originally reader-first, superseded by the coordinated-release decision below. Hide active UI/candidates until activation. |
| WF-2 producer | Behind `WEB_FETCH_ACTIVE=false`: gateway policy/local transport/extraction, keyed APIs, shared Exa client + Jina, Vibey framing/replay, UI fixtures. Separate lanes only after reader contracts merge. Flag-off preserves prior behavior. |
-| WF-3 activation | Confirm reader release exists; flip declaration/candidates/producer together and publish public en/zh docs. Recheck vendor facts/tags, review/CI and manual fixture acceptance. |
+| WF-3 activation | Owner-approved coordinated reader/flip release: enable declaration/candidates/producer together and publish public en/zh docs. Recheck vendor facts/tags, review/CI and manual acceptance. |
+
+### WF-3 activation and coordinated release
+
+The activation change sets the one shared switch to true; it changes no schema,
+contract version, migration, catalog price or default ordering. It builds on the
+merged local engine (#2962), local/keyless chain (#2968), and configured providers
+(#2976). Public disclosure is the coordinated `avibe-docs#83` English/Chinese change.
+
+At activation preparation on **2026-10-26**, the latest published release was
+`gh-v3.2.3rc7` (v20), and no fetched tag contained WF-1 `9e47e5f`. At **01:56
+Asia/Shanghai on 2026-10-26**, the owner explicitly waived the separate reader-first
+release and chose to **ship readers and the activation flip together**. No rc8 or
+other prior reader release is required. The orchestrator merges the activation
+and public-doc PRs together once the activation is Merge-ready and its required
+acceptance is complete; exact-head review and CI are not waived. This lane does
+not publish a tag/release, deploy or restart a service.
+
+Primary activation acceptance connects the real default-on Tools read, frozen
+candidates, C-6 hop, Vibey declaration, gateway chain and bounded C-1 result/usage
+without patching either flag. Only external I/O is stubbed. Existing provider,
+policy, downgrade and four-protocol replay tests remain in force. Screenshots in
+`wf3-shots/` are hermetic real-component/projection fixtures, not live-provider or
+installed-runtime verification; §7's buttons match the accepted UI.
+
+### Release note (publish only with activation)
+
+**English:** Web fetch is now available in Vibey and Models → Tools. It reads one
+URL through local fetch → configured fetch services → free Exa → free Jina Reader
+by default. Fetch switches and up/down ordering are independent of search;
+existing eligible API-key Sources are included automatically. Local fetch sends
+requests directly from your runtime host without browser credentials or JavaScript
+rendering; remote services receive the URL and may render JavaScript or charge
+per request. Review the Web fetch documentation for costs, limits and terms.
+Stored results are bounded to 48,000 UTF-8 bytes including quotation framing and
+replay without fetching or billing again. Older-version config/usage rewrites can
+lose fetch opt-outs and attribution; recheck settings after a downgrade/re-upgrade.
+
+**中文:** Vibey 和「模型 → 工具」现已支持网页读取。默认依次尝试本机、已配置的
+读取服务、免费 Exa 和免费 Jina Reader;读取开关及上下按钮排序与搜索独立,现有
+符合条件的 API 密钥来源会自动加入。本机从运行 Avibe 的主机直接发起请求,不携带
+浏览器凭据、不渲染 JavaScript;远端服务会接收网址,可能渲染 JavaScript 或按次收费。
+费用、限制及条款请查看网页读取文档。保存结果连同引用框架最多 48,000 UTF-8 字节,
+重放不会再次读取或计费。旧版本重写配置或用量可能丢失读取禁用选项及用量归属;
+降级后重新升级时请检查设置。
Unknown-tool compatibility is #2920's exact ordinary-content degradation, not a
promise that old readers understand new record fields or preserve new config
diff --git a/storage/agent_transcript.py b/storage/agent_transcript.py
index 5be79d1fa..1bb2c6ba9 100644
--- a/storage/agent_transcript.py
+++ b/storage/agent_transcript.py
@@ -77,6 +77,7 @@ from core.agent_core.harness.store import ContextEntry, EntryKind
from core.agent_core.messages import (
AssistantMessage,
HostedImage,
+ HostedRecord,
HostedToolBlock,
TextBlock,
ToolResultMessage,
@@ -467,10 +468,15 @@ def _register_images(
) -> None:
"""Register each generated image ``message`` names, in its row's transaction (module docstring)."""
+ # WebFetchRecord shares the hosted envelope, not search/image fields.
+ # Narrow before entering media registration so page results can commit.
+ records: list[HostedRecord]
if isinstance(message, AssistantMessage):
records = [block.record for block in message.content if isinstance(block, HostedToolBlock)]
+ elif message.hosted is not None and isinstance(message.hosted.record, HostedRecord):
+ records = [message.hosted.record]
else:
- records = [message.hosted.record] if message.hosted is not None else []
+ return
for image in (image for record in records for image in record.images or ()):
media_service.register(
conn,
diff --git a/tests/test_model_hub_fetch_chain.py b/tests/test_model_hub_fetch_chain.py
index c7ab86d48..4a8a0f04b 100644
--- a/tests/test_model_hub_fetch_chain.py
+++ b/tests/test_model_hub_fetch_chain.py
@@ -22,12 +22,6 @@ from vibe.model_hub_runtime.fetch_catalog import fetch_service_catalog
from core.handlers.model_hub.service import ModelHubError
[email protected](autouse=True)
-def _reset_fetch_flag(monkeypatch):
- monkeypatch.setattr(hosted_tools, "WEB_FETCH_ACTIVE", False)
- yield
-
-
@pytest.mark.asyncio
async def test_jina_builtin_fetch_is_admitted_with_reader_headers():
adapter = object.__new__(CLIProxyEngineAdapter)
@@ -94,8 +88,8 @@ def test_http_200_malformed_provider_envelopes_are_service_failures(body, vendor
@pytest.mark.asyncio
@pytest.mark.parametrize("vendor", ["exa", "tavily", "deepseek"])
-async def test_configured_fetch_is_dormant_at_chain_and_adapter_boundaries(tmp_path, vendor):
- """The activation flag still blocks the new producer while the adapter is ready for hermetic tests."""
+async def test_flag_off_rejects_configured_fetch_from_a_previously_frozen_turn(tmp_path, monkeypatch, vendor):
+ """The shared kill switch rejects stale turns before any configured transport admission."""
sid = IDS[vendor]
service, config = _service(
tmp_path, vendor=vendor,
@@ -109,7 +103,7 @@ async def test_configured_fetch_is_dormant_at_chain_and_adapter_boundaries(tmp_p
service.adapter.fetch = unexpected
turn = service.freeze_turn_hosted_tools(config)
- hosted_tools.WEB_FETCH_ACTIVE = False
+ monkeypatch.setattr(hosted_tools, "WEB_FETCH_ACTIVE", False)
with pytest.raises(ModelHubError) as raised:
await service.run_hosted_tool(
"web_fetch", {"arguments": {"url": "https://example.com/"}},
@@ -626,7 +620,6 @@ def _service(tmp_path: Path, *, enabled: dict[str, bool], order=(LOCAL, EXA), ve
)
service.store.config = config
service._local_fetch_engine = _Local()
- hosted_tools.WEB_FETCH_ACTIVE = True
return service, config
@@ -634,7 +627,7 @@ def _service(tmp_path: Path, *, enabled: dict[str, bool], order=(LOCAL, EXA), ve
async def test_flag_off_rejects_fetch_without_running_gate_or_adapter(tmp_path, monkeypatch):
service, config = _service(tmp_path, enabled={LOCAL: True, EXA: True, FREE_EXA: False, JINA: False})
turn = service.freeze_turn_hosted_tools(config)
- hosted_tools.WEB_FETCH_ACTIVE = False
+ monkeypatch.setattr(hosted_tools, "WEB_FETCH_ACTIVE", False)
called = []
monkeypatch.setattr(service.adapter, "fetch", lambda *args, **kwargs: called.append(args), raising=False)
with pytest.raises(ModelHubError) as raised:
@@ -644,25 +637,75 @@ async def test_flag_off_rejects_fetch_without_running_gate_or_adapter(tmp_path,
)
assert raised.value.code == "tool_not_enabled"
assert called == []
+ assert service._local_fetch_engine.checks == 0
@pytest.mark.asyncio
-async def test_local_sent_attempt_is_recorded_as_exact_zero_fetch_usage(tmp_path):
- service, config = _service(
- tmp_path,
- enabled={LOCAL: True, EXA: False, FREE_EXA: False, JINA: False},
- order=(LOCAL, EXA),
- )
- result = await service.run_hosted_tool(
- "web_fetch", {"arguments": {"url": "https://example.com/"}},
- turn=service.freeze_turn_hosted_tools(config),
- )
+async def test_default_activation_connects_tools_read_frozen_hop_and_bounded_local_result(tmp_path):
+ """WF-3: no flag patches; a read/declaration/producer mismatch must break this path.
+
+ Earlier lane fixtures forced activation or supplied a canned gateway answer.
+ Only the external local engine and HTTP transport are replaced here.
+ """
+ import httpx
+
+ from config import v2_config
+ from core.agent_core.messages import ToolResultMessage, WebFetchRecord, message_from_dict, message_to_dict
+ from modules.agents.model_hub import ModelHubLaunch
+ from modules.agents.vibey.models import selection_from_hop
+ from modules.agents.vibey.tools import hosted_tools as declared_tools
+ from tests.test_vibey_web_fetch import router
+
+ service = owner(tmp_path, (), model=True)
+ service._local_fetch_engine = _Local()
+ config = service.store.load()
+ before = config.to_payload()
+ assert "web_fetch" not in config.hosted_tools
+ assert v2_config.WEB_FETCH_ACTIVE and hosted_tools.WEB_FETCH_ACTIVE
+ fetch = next(row for row in service.hosted_tools_status()["hosted_tools"]["tools"] if row["name"] == "web_fetch")
+ assert fetch["enabled"] is True
+ assert fetch["effective_order"] == [LOCAL, FREE_EXA, JINA]
+ frozen = service.freeze_turn_hosted_tools(config)
+ assert [slot.source_id for slot in frozen.executors["web_fetch"]] == [LOCAL, FREE_EXA, JINA]
+ source = config.sources[0]
+ model = source.models[0].id
+ facts = service.hosted_tools_for_hop(source, model, frozen)
+ assert facts["web_fetch"] == {"native": "unsupported", "replay": "unsupported"}
+ hop = ModelHubLaunch(
+ backend="vibey", channel="hub", requested_model=model, target_model=model, runtime_model=model,
+ source_id=source.id, source_identity="test-identity", gateway_base_url="http://hub.invalid/vibey",
+ gateway_token="fixture", gateway_request_metadata={"x-avibe-turn-id": "turn-fetch"},
+ protocol="openai_chat", provider="openai", hosted_tools=facts,
+ ).to_hop_resolution()
+ sent = []
+
+ async def gateway(request):
+ assert request.url.path == "/vibey/v1/hosted-tools/web_fetch"
+ assert request.headers["x-avibe-turn-id"] == "turn-fetch"
+ sent.append(request)
+ return httpx.Response(200, json=await service.run_hosted_tool(
+ "web_fetch", json.loads(request.content), turn=frozen,
+ ))
+
+ async with httpx.AsyncClient(transport=httpx.MockTransport(gateway)) as client:
+ tools = declared_tools(router(selection_from_hop(hop)), client)
+ tool = next(tool for tool in tools if tool.spec.name == "web_fetch")
+ output = await tool.execute({"url": "https://example.com/"}, None)
+ assert len(sent) == 1 and not output.is_error
+ assert isinstance(output.hosted.record, WebFetchRecord)
+ message = ToolResultMessage("fetch1", "web_fetch", output.content, hosted=output.hosted)
+ saved = message_to_dict(message)
+ assert message_from_dict(saved) == message
+ assert "local page" in saved["content"][0]["text"]
+ assert len(saved["content"][0]["text"].encode("utf-8")) <= 48000
+ result = saved["hosted"]
assert result["record"]["status"] == "completed"
assert result["record"]["attempts"][0]["kind"] == "local"
assert result["execution"]["executor_origin"]["api"] == "local_fetch"
assert result["execution"]["cost"] == {"basis": "list", "usd": 0}
row = next(row for row in service.usage_summary(days=7)["services"] if row["tool"] == "web_fetch")
assert row["requests"] == 1 and row["billable_requests"] == 0 and row["uncertain_requests"] == 0
+ assert service.store.load().to_payload() == before
@pytest.mark.asyncio
diff --git a/tests/test_model_hub_hosted_executor.py b/tests/test_model_hub_hosted_executor.py
index 6583a91ef..f969dbb5b 100644
--- a/tests/test_model_hub_hosted_executor.py
+++ b/tests/test_model_hub_hosted_executor.py
@@ -1121,7 +1121,7 @@ async def test_a_turn_keeps_its_tools_and_executor_order_until_the_next_turn(tmp
_bind(service, "web_search", (OPENAI, "gpt-6-astra"))
_bind(service, "x_search", (XAI, "grok-4.6"))
again = await router.resolve_hop("menu-alias", process_scope="vibey:freeze", turn_id="turn-freeze")
- assert again["hosted_tools"].keys() == first["hosted_tools"].keys() == {"web_search", "image_generate"}
+ assert again["hosted_tools"].keys() == first["hosted_tools"].keys() == {"web_search", "image_generate", "web_fetch"}
status, answer = await search(again, "web_search")
assert status == 200 and answer["execution"]["executor_source_id"] == XAI
assert (await search(again, "x_search"))[0] == 409
diff --git a/tests/test_model_hub_hosted_tools_config.py b/tests/test_model_hub_hosted_tools_config.py
index 79eaa697c..ceac3ef59 100644
--- a/tests/test_model_hub_hosted_tools_config.py
+++ b/tests/test_model_hub_hosted_tools_config.py
@@ -59,7 +59,7 @@ def test_released_configs_load_with_every_tool_on_and_stay_without_the_section()
section = json.loads((FIXTURES / "released_pre_vibey_consumer.json").read_text(encoding="utf-8"))
config = ModelHubConfig.from_payload(section, repairing=True)
assert config.hosted_tools == {}
- assert enabled_tools(config) == RELEASED_TOOLS
+ assert enabled_tools(config) == KNOWN_TOOLS
assert "hosted_tools" not in config.to_payload()
@@ -140,7 +140,7 @@ def test_disk_load_with_a_broken_hosted_tools_section_keeps_model_hub(monkeypatc
assert not loaded.load_warnings
assert [source.id for source in loaded.model_hub.sources] == ["src_xai00001"]
- assert enabled_tools(loaded.model_hub) == ("image_generate",)
+ assert enabled_tools(loaded.model_hub) == ("image_generate", "web_fetch")
assert config_path.read_text(encoding="utf-8") == original
assert not list(tmp_path.glob("config.json.bak-recovery-*"))
@@ -182,7 +182,7 @@ async def test_the_tools_api_writes_one_field_of_one_tool_at_a_time(tmp_path):
status = service.hosted_tools_status()["hosted_tools"]
_validate_status(status)
by_name = {tool["name"]: tool for tool in status["tools"]}
- assert list(by_name) == list(RELEASED_TOOLS) and all(tool["enabled"] for tool in status["tools"])
+ assert list(by_name) == list(KNOWN_TOOLS) and all(tool["enabled"] for tool in status["tools"])
# The executor runs on the vendor's lightweight model, priced by the overlay's dated list price.
(candidate,) = by_name["x_search"]["executor_candidates"]
assert (candidate["source_id"], candidate["model_id"], candidate["billing"], candidate["relay"]) == (
diff --git a/tests/test_model_hub_hosted_tools_resolution.py b/tests/test_model_hub_hosted_tools_resolution.py
index 2cc47bfc5..27c1a37a6 100644
--- a/tests/test_model_hub_hosted_tools_resolution.py
+++ b/tests/test_model_hub_hosted_tools_resolution.py
@@ -22,6 +22,7 @@ from config.v2_config import (
ModelHubModelConfig,
ModelHubSourceConfig,
ModelHubSourceStateConfig,
+ model_hub_builtin_source,
)
from core.handlers.model_hub import hosted_tools as hosted_tools_module
from core.handlers.model_hub.capability_evidence import (
@@ -313,13 +314,21 @@ def test_a_turn_freezes_its_tools_executors_and_image_enum_and_each_hop_states_i
with the identity it was built under, and the image enum; a hop states facts only, the enum's params sorted."""
evidence = _evidence(tmp_path)
turn = freeze_turn_tools(_config(), evidence=evidence, spec_for=_spec_for)
- assert turn.tools == {"web_search", "x_search", "image_generate"}
+ assert turn.tools == {"web_search", "x_search", "image_generate", "web_fetch"}
assert turn.executors == {
"web_search": (
ExecutorSlot("src_xai00001", "grok-fast", identity_digest(XAI), label="src_xai00001"),
ExecutorSlot("src_oai00001", "gpt-mini", identity_digest(OPENAI), label="src_oai00001"),
),
"x_search": (ExecutorSlot("src_xai00001", "grok-fast", identity_digest(XAI)),),
+ "web_fetch": tuple(
+ ExecutorSlot(sid, model, identity_digest(model_hub_builtin_source(sid)), kind=kind)
+ for sid, model, kind in (
+ ("src_localfetch", "local/fetch", "local"),
+ ("src_exakeyless", "exa/mcp", "service"),
+ ("src_jinakeyless", "jina/reader", "service"),
+ )
+ ),
}
image = {"description": "Grok Imagine", "params": ["images", "size"], "size_forms": ["pixels"]}
assert hop_hosted_tools(turn, OPENAI, "gpt-6-astra", evidence=evidence, spec_for=_spec_for) == {
@@ -329,6 +338,7 @@ def test_a_turn_freezes_its_tools_executors_and_image_enum_and_each_hop_states_i
},
# OpenAI does not run X search: the hop takes the function.
"x_search": {"native": "unsupported", "replay": "unsupported"},
+ "web_fetch": {"native": "unsupported", "replay": "unsupported"},
"image_generate": {
"models": [
{"source_id": "src_xai00001", "model_id": "grok-imagine-image", **image},
@@ -343,7 +353,10 @@ def test_a_turn_freezes_its_tools_executors_and_image_enum_and_each_hop_states_i
"native": "unsupported", "replay": "unsupported", "refused": True,
}
# Off, or with no image model available, a tool is not declared at all.
- off = _config({"x_search": ModelHubHostedToolConfig(enabled=False)}, sources=[CLAUDE_SUB, OPENAI, GEMINI])
+ off = _config({
+ "x_search": ModelHubHostedToolConfig(enabled=False),
+ "web_fetch": ModelHubHostedToolConfig(enabled=False),
+ }, sources=[CLAUDE_SUB, OPENAI, GEMINI])
turn = freeze_turn_tools(
off, evidence=_evidence(tmp_path / "o", (OPENAI, "gpt-image-2", "image_generate", "call")), spec_for=_spec_for,
)
@@ -365,7 +378,7 @@ def test_the_tools_read_states_saved_and_effective_values_and_what_real_use_show
config = _config({"web_search": ModelHubHostedToolConfig(executor_order=("src_oai00001",))})
status = hosted_tools_status(config, evidence=evidence, spec_for=_spec_for, image_price=lambda _source, _spec: None)
by_name = {tool["name"]: tool for tool in status["tools"]}
- assert list(by_name) == ["web_search", "x_search", "image_generate"]
+ assert list(by_name) == ["web_search", "x_search", "image_generate", "web_fetch"]
web = by_name["web_search"]
assert web["enabled"] is True and by_name["x_search"]["enabled"] is True
assert web["executor_order"] == ["src_oai00001"]
diff --git a/tests/test_model_hub_local_fetch.py b/tests/test_model_hub_local_fetch.py
index 70866c6b2..6e00d0758 100644
--- a/tests/test_model_hub_local_fetch.py
+++ b/tests/test_model_hub_local_fetch.py
@@ -593,7 +593,8 @@ async def test_stop_during_success_cleanup_is_rethrown_after_reap(monkeypatch):
await task
-async def test_active_worker_cap_and_cancellation_safe_host_release(monkeypatch):
[email protected]("spawn_delay", [0, 0.4], ids=["normal-start", "slow-start"])
+async def test_active_worker_cap_and_cancellation_safe_host_release(monkeypatch, spawn_delay):
script = '''import sys,time,json
from urllib.parse import urlsplit
request=json.loads(sys.stdin.readline())
@@ -602,9 +603,12 @@ print('{"event":"sent"}',flush=True); sys.stdin.readline()
time.sleep(60)
'''
monkeypatch.setattr(local_fetch, "_WORKER", script)
- children, spawn = [], asyncio.create_subprocess_exec
+ children, spawn, spawn_attempts = [], asyncio.create_subprocess_exec, []
reaping, release = asyncio.Event(), asyncio.Event()
async def capture(*args, **kwargs):
+ spawn_attempts.append(1)
+ if spawn_delay:
+ await asyncio.sleep(spawn_delay)
child = await spawn(*args, **kwargs)
children.append(child)
if len(children) == 1:
@@ -634,11 +638,21 @@ time.sleep(60)
again.cancel()
await asyncio.gather(again, return_exceptions=True)
children.clear()
+ spawn_attempts.clear()
# Distinct hosts still have one aggregate process cap.
- tasks = [asyncio.create_task(engine.fetch(f"https://host{i}.example/", deadline=time.monotonic() + 10)) for i in range(20)]
+ sent, ready = 0, asyncio.Event()
+ worker_cap = local_fetch._WORKERS
+ def mark_sent():
+ nonlocal sent
+ sent += 1
+ if sent == worker_cap:
+ ready.set()
+ tasks = [asyncio.create_task(engine.fetch(f"https://host{i}.example/", deadline=time.monotonic() + 10,
+ on_sent=mark_sent)) for i in range(20)]
try:
- await asyncio.sleep(.3)
- assert 1 <= len(children) <= 8
+ await asyncio.wait_for(ready.wait(), 10)
+ assert sent == worker_cap
+ assert len(spawn_attempts) == len(children) == worker_cap == 8
finally:
for task in tasks:
task.cancel()
diff --git a/tests/test_model_hub_vibey_consumer.py b/tests/test_model_hub_vibey_consumer.py
index 83d4bc9d6..27007d525 100644
--- a/tests/test_model_hub_vibey_consumer.py
+++ b/tests/test_model_hub_vibey_consumer.py
@@ -1167,6 +1167,8 @@ async def test_hop_resolution_states_each_enabled_hosted_tool(tmp_path):
assert resolving_threads and threading.main_thread() not in resolving_threads
_validate("hop-resolution.schema.json", hop)
assert hop["hosted_tools"] == {
+ # Fetch is enabled by default, but is function-only on every model.
+ "web_fetch": {"native": "unsupported", "replay": "unsupported"},
"web_search": {
"native": "assumed",
"declaration": {"type": "web_search"},
diff --git a/tests/test_model_hub_web_fetch_readers.py b/tests/test_model_hub_web_fetch_readers.py
index a94610820..8aba269fe 100644
--- a/tests/test_model_hub_web_fetch_readers.py
+++ b/tests/test_model_hub_web_fetch_readers.py
@@ -1,4 +1,4 @@
-"""WF-1: dormant settings, independent order, and future ledger readers.
+"""WF-1/WF-3: saved fetch consent, active reads and independent ledger attribution.
The existing search cases cannot catch erased fetch consent or merged Exa tool
rows. These tests exercise the settings/read and ledger owners, not a producer.
@@ -38,7 +38,7 @@ def fetch_config(settings=None):
@pytest.mark.asyncio
async def test_fetch_consent_survives_v2_reload_and_unrelated_save(tmp_path):
- """WF-1: a dormant build must not erase a newer build's built-in opt-outs."""
+ """Fetch activation must not erase persisted built-in opt-outs on unrelated saves."""
config = fetch_config()
assert config.to_payload()["hosted_tools"]["web_fetch"] == FETCH_SETTINGS
service, path, _ = _disk_service(tmp_path, config)
@@ -94,8 +94,8 @@ def test_future_fetch_ledger_rows_do_not_merge_shared_exa_identity(tmp_path, win
assert {(r.get("tool", "web_search"), r["requests"]) for r in reopened["services"]} == {("web_search", 3), ("web_fetch", 3)}
-def test_dormant_hop_reader_accepts_function_only_fetch_but_never_declares_it():
- """WF-1 can read a future C-6 entry without enabling an execution path."""
+def test_hop_reader_declares_function_only_fetch_by_default():
+ """WF-3: a supplied C-6 entry registers the canonical function without flag patches."""
from types import SimpleNamespace
from modules.agents.model_hub import ModelHubLaunch
from modules.agents.vibey.models import selection_from_hop
@@ -106,17 +106,21 @@ def test_dormant_hop_reader_accepts_function_only_fetch_but_never_declares_it():
hop["hosted_tools"] = {"web_fetch": {"native": "unsupported", "replay": "unsupported"}}
selection = selection_from_hop(hop)
assert selection.endpoint.hosted_tools["web_fetch"].mode == "proxy"
- assert turn_tools(SimpleNamespace(preflight=selection, current=selection)) == ()
+ assert [tool.spec.name for tool in turn_tools(SimpleNamespace(preflight=selection, current=selection))] == ["web_fetch"]
-def test_dormant_read_candidates_and_turn_do_not_advertise_fetch(tmp_path):
- """A known stored tool must not implicitly enter a live turn or the Tools UI."""
- service, path, _ = _disk_service(tmp_path, fetch_config())
+def test_active_read_candidates_and_turn_preserve_saved_fetch_consent(tmp_path):
+ """The visible row and frozen candidates agree without rewriting saved choices."""
+ config = fetch_config()
+ service, path, _ = _disk_service(tmp_path, config)
before = path.read_bytes()
- assert hosted_tools.WEB_FETCH_ACTIVE is False
- assert "web_fetch" not in {t["name"] for t in service.hosted_tools_status()["hosted_tools"]["tools"]}
- assert "web_fetch" not in hosted_tools.freeze_turn_tools(fetch_config(), evidence=service.hosted_evidence(), spec_for=hosted_tools.hosted_tool_spec).tools
- assert not hosted_tools.executor_candidates(fetch_config(), "web_fetch", evidence=service.hosted_evidence(), spec_for=hosted_tools.hosted_tool_spec)
+ fetch = next(t for t in service.hosted_tools_status()["hosted_tools"]["tools"] if t["name"] == "web_fetch")
+ turn = service.freeze_turn_hosted_tools(config)
+ assert "web_fetch" in turn.tools
+ assert [slot.source_id for slot in turn.executors["web_fetch"]] == fetch["effective_order"]
+ assert {slot.source_id: slot.enabled for slot in turn.executors["web_fetch"]} == {
+ LOCAL: False, FREE_EXA: False, JINA: False, EXA: True, TAVILY: True, DEEPSEEK: True,
+ }
assert path.read_bytes() == before
@@ -127,10 +131,9 @@ def test_dormant_read_candidates_and_turn_do_not_advertise_fetch(tmp_path):
({"executor_order": [LOCAL, JINA], "executor_order_kinds": {LOCAL: "service", JINA: "service"}}, [LOCAL, EXA, TAVILY, DEEPSEEK, JINA, FREE_EXA]),
({"services": {LOCAL: {"enabled": False}, EXA: {"enabled": False}}}, [TAVILY, DEEPSEEK, FREE_EXA, JINA, LOCAL, EXA]),
])
-def test_active_fetch_read_owns_independent_order_without_writing(tmp_path, monkeypatch, settings, expected):
+def test_active_fetch_read_owns_independent_order_without_writing(tmp_path, settings, expected):
"""Search's disabled Tavily/order cannot decide fetch consent or deliberate placement."""
from tests.test_model_hub_api import _api_response_registry
- monkeypatch.setattr(hosted_tools, "WEB_FETCH_ACTIVE", True)
service, path, _ = _disk_service(tmp_path, fetch_config(settings))
before = path.read_bytes()
payload = service.hosted_tools_status()["hosted_tools"]
@@ -164,12 +167,11 @@ def test_fetch_catalog_capability_and_catalog_off_preserve_identity(monkeypatch)
@pytest.mark.asyncio
@pytest.mark.parametrize("sid,service_id", [(FREE_EXA, "exa/mcp"), (JINA, "jina/reader")])
-async def test_synthetic_fetch_cooldown_survives_save_and_retry_is_shared(tmp_path, monkeypatch, sid, service_id):
+async def test_synthetic_fetch_cooldown_survives_save_and_retry_is_shared(tmp_path, sid, service_id):
"""Retry uses the same synthetic identity/generation as other tools; no request is made."""
from config.v2_config import model_hub_builtin_source
from core.handlers.model_hub.search_services import ServiceCooldowns, ServiceResult
from core.handlers.model_hub.adapter import SearchResponse
- monkeypatch.setattr(hosted_tools, "WEB_FETCH_ACTIVE", True)
service, _, _ = _disk_service(tmp_path, fetch_config({}))
service.now = lambda: NOW
service._service_cooldowns = ServiceCooldowns()
@@ -191,7 +193,7 @@ async def test_synthetic_fetch_cooldown_survives_save_and_retry_is_shared(tmp_pa
@pytest.mark.asyncio
@pytest.mark.parametrize("sid,service_id,label", [(LOCAL, "local/fetch", "Local"), (FREE_EXA, "exa/mcp", "Exa (free)"), (JINA, "jina/reader", "Jina Reader (free)")])
async def test_synthetic_fetch_evidence_and_usage_survive_without_credential_sources(tmp_path, sid, service_id, label):
- """Synthetic identities join both durable readers even when activation is off."""
+ """Synthetic identities join both durable readers without becoming credential Sources."""
from config.v2_config import model_hub_builtin_source
from core.handlers.model_hub.capability_evidence import CapabilityEvidenceStore
service, _, _ = _disk_service(tmp_path, fetch_config())
diff --git a/tests/test_vibey_agent.py b/tests/test_vibey_agent.py
index c08b8ebbf..c2d81350a 100644
--- a/tests/test_vibey_agent.py
+++ b/tests/test_vibey_agent.py
@@ -3915,6 +3915,131 @@ async def test_a_proxied_hosted_call_runs_on_the_turns_executor_chain_and_keeps_
assert sent["type"] == "tool_result" and seen in json.dumps(sent)
[email protected]("platform", ["avibe", "telegram"])
[email protected]("executor", ["local", "exa", "jina", "policy"])
+async def test_web_fetch_survives_the_real_agent_commit_delivery_and_next_turn_replay(
+ engine, session, tmp_path, published, monkeypatch, platform, executor
+):
+ """WF-3: a gateway 200 must commit and display, not become an interrupted call.
+
+ The earlier tool-only acceptance never reached SQLite media registration.
+ Exercise the real parser, Agent loop, tool runtime, transcript, dispatcher,
+ mirror and activity reader; only HTTP is stubbed. A fresh adapter then replays
+ the stored fetch with the tool disabled, without another fetch or media write.
+ """
+ import httpx
+
+ from core.agent_core.messages import ServiceExecutorOrigin, WebFetchRecord
+ from core.agent_core.web_fetch import frame_fetch_record
+ from modules.agents.vibey.models import registry_providers
+ from storage import agent_activity_service
+ from storage.models import media_objects
+
+ monkeypatch.setattr("core.message_mirror._activity_streaming_enabled", lambda: True)
+ blocked = executor == "policy"
+ url = "http://10.0.0.5/" if blocked else "https://example.test/page"
+ content = "" if blocked else "Hello 世界"
+ sid, label, kind, vendor, service_id = {
+ "local": ("src_localfetch", "Local", "local", "local", "local/fetch"),
+ "exa": ("src_exakeyless", "Exa (free)", "service", "exa-mcp", "exa/mcp"),
+ "jina": ("src_jinakeyless", "Jina Reader (free)", "service", "jina-reader", "jina/reader"),
+ "policy": (None, None, None, None, None),
+ }[executor]
+ cost = HostedCost(basis="list", usd=0)
+ record = WebFetchRecord(
+ status="failed" if blocked else "completed", requested_url=url,
+ content=content, size_bytes=len(content.encode("utf-8")), retrieved_at="2026-10-25T17:27:45Z",
+ error="blocked by local policy" if blocked else None,
+ error_code="fetch_url_blocked" if blocked else None,
+ attempts=() if blocked else (HostedAttempt(sid, label, kind, "completed", cost=cost),),
+ )
+ hosted = HostedResult(record=record, execution=None if blocked else ProxyExecution(
+ executor_origin=ServiceExecutorOrigin(vendor, "local_fetch" if kind == "local" else "fetch_api", service_id),
+ executor_source_id=sid, executor_billing="metered", cost=cost,
+ ))
+ frame = frame_fetch_record(record)
+ expected = ToolResultMessage("toolu_fetch", "web_fetch", (text(frame),), is_error=blocked, hosted=hosted)
+ envelope = message_to_dict(expected)["hosted"]
+ served = {"provider": "test-provider", "api": "anthropic", "model": "test-model", "source": "src_served00001"}
+ replies = [
+ _anthropic_reply(json.dumps({"type": "tool_use", "id": "toolu_fetch", "name": "web_fetch", "input": {"url": url}}), stop_reason="tool_use"),
+ _anthropic_reply('{"type":"text","text":"fetch handled"}', stop_reason="end_turn"),
+ _anthropic_reply('{"type":"text","text":"stored read recalled"}', stop_reason="end_turn"),
+ ]
+ models, executed = [], []
+
+ def gateway(request):
+ if request.url.path == "/vibey/v1/hosted-tools/web_fetch":
+ executed.append(request)
+ assert json.loads(request.content) == {"arguments": {"url": url}}
+ return httpx.Response(200, json=envelope)
+ assert request.url.path == "/vibey/v1/messages"
+ models.append(json.loads(request.content))
+ return httpx.Response(200, headers={
+ "content-type": "text/event-stream", "x-avibe-served-hop": json.dumps(served),
+ }, text=replies.pop(0))
+
+ async with httpx.AsyncClient(transport=httpx.MockTransport(gateway)) as client:
+ harness = _Harness(engine, tmp_path, platform, [],
+ providers=registry_providers(media_loader=None, client=client), gateway_client=client)
+ harness.controller.hub_source_id = served["source"]
+ harness.controller.hub_hosted_tools = {"web_fetch": {"native": "unsupported", "replay": "unsupported"}}
+ harness.controller.im_client.supports_message_editing = lambda context=None: False
+ first = harness.request("read this page")
+ await harness.agent.handle_message(first)
+ assert harness.controller.terminals[-1]["is_error"] is False
+ assert harness.controller.terminal_texts[-1] == "fetch handled"
+ [committed] = [row for row in await harness.context_rows() if row.kind == "tool_result"]
+ assert committed.message == expected
+ assert executed[0].headers["x-avibe-turn-id"] == _turn(first.context)
+ assert executed[0].headers["authorization"] == "Bearer hub-token"
+
+ # Reconstruct from durable rows, with no web_fetch declaration on the new turn.
+ harness.new_agent()
+ harness.controller.hub_hosted_tools = {}
+ await harness.agent.handle_message(harness.request("recall the stored read"))
+ assert harness.controller.terminals[-1]["is_error"] is False
+ assert harness.controller.terminal_texts[-1] == "stored read recalled"
+ [replayed] = [row for row in await harness.context_rows() if row.kind == "tool_result"]
+ assert replayed == committed
+
+ assert len(executed) == 1 and len(models) == 3 and replies == []
+ assert models[0]["tools"][0]["name"] == "web_fetch"
+ assert all(tool.get("name") != "web_fetch" for tool in models[2].get("tools", []))
+ for request in models[1:]:
+ [answer] = [block for message in request["messages"] for block in message["content"]
+ if block.get("type") == "tool_result" and block.get("tool_use_id") == "toolu_fetch"]
+ assert answer["content"] == [{"type": "text", "text": frame}]
+ assert answer.get("is_error", False) is blocked
+ assert "tool call interrupted" not in json.dumps(request)
+
+ # The dispatcher/mirror create exactly one hosted trace, read unchanged by
+ # the activity API. Page records never register images or produce uploads.
+ with engine.connect() as conn:
+ traces = conn.execute(select(agent_events).where(
+ agent_events.c.session_id == SESSION, agent_events.c.event_type == "tool_call"
+ )).mappings().all()
+ groups = agent_activity_service.list_turn_groups(conn, session_id=SESSION)["groups"]
+ details = [agent_activity_service.get_turn_group(conn, session_id=SESSION, group_id=group["id"]) for group in groups]
+ assert conn.execute(select(media_objects.c.token).where(media_objects.c.session_id == SESSION)).first() is None
+ [trace] = [row for row in traces if json.loads(row["content_json"]).get("hosted")]
+ card = json.loads(trace["content_json"])["hosted"]
+ assert card["tool"] == "web_fetch" and card["status"] == record.status
+ assert card["sources"] == card["images"] == []
+ assert card["fetch"] == envelope["record"]
+ if blocked:
+ assert card["policy_sources"] == [] and card["error_code"] == "fetch_url_blocked"
+ else:
+ assert card["source_id"] == sid and card["cost"]["usd"] == 0
+ assert [row["hosted"] for detail in details for row in detail["rows"] if row.get("hosted")] == [card]
+ live = [payload["content"]["hosted"] for name, payload in published
+ if name == "message.new" and (payload.get("content") or {}).get("hosted")]
+ assert live == ([card] if platform == "avibe" else [])
+ assert harness.controller.im_client.sent.count(trace["content_text"]) == 1
+ assert not harness.controller.im_client.uploads
+ assert len(harness.rows("result")) == 2 and not harness.rows("error")
+
+
_JPEG = b"\xff\xd8\xff\xe0" + bytes(range(256)) * 8
_DIRECT = {
"mode": "direct",
diff --git a/tests/test_vibey_web_fetch.py b/tests/test_vibey_web_fetch.py
index ab744212a..d3c18b433 100644
--- a/tests/test_vibey_web_fetch.py
+++ b/tests/test_vibey_web_fetch.py
@@ -46,7 +46,10 @@ def router(first):
@pytest.mark.parametrize("protocol", ["anthropic", "openai_responses", "openai_chat", "google"])
@pytest.mark.parametrize("active,offered", [(False, True), (True, False), (True, True)])
async def test_fetch_declaration_is_a_frozen_url_only_function(monkeypatch, protocol, active, offered):
- monkeypatch.setattr(v2_config, "WEB_FETCH_ACTIVE", active)
+ if not active:
+ monkeypatch.setattr(v2_config, "WEB_FETCH_ACTIVE", False)
+ else:
+ assert v2_config.WEB_FETCH_ACTIVE is True
turn = router(selection(protocol, offered=offered))
tools = hosted_tools(turn)
assert [tool.spec.name for tool in tools] == (["web_fetch"] if active and offered else [])
@@ -72,8 +75,7 @@ async def test_fetch_declaration_is_a_frozen_url_only_function(monkeypatch, prot
@pytest.mark.parametrize("outcome", ["completed", "policy", "closed", "off", "malformed", "unreachable"])
-async def test_gateway_result_preserves_one_frame_and_live_turn(monkeypatch, outcome):
- monkeypatch.setattr(v2_config, "WEB_FETCH_ACTIVE", True)
+async def test_gateway_result_preserves_one_frame_and_live_turn(outcome):
stored = json.loads(FIXTURE.read_text())
answer = copy.deepcopy(stored["hosted"])
if outcome == "policy":
@@ -119,8 +121,7 @@ async def test_gateway_result_preserves_one_frame_and_live_turn(monkeypatch, out
@pytest.mark.parametrize("length", [8192, 8193])
-async def test_gateway_failure_never_fabricates_a_shortened_requested_url(monkeypatch, length):
- monkeypatch.setattr(v2_config, "WEB_FETCH_ACTIVE", True)
+async def test_gateway_failure_never_fabricates_a_shortened_requested_url(length):
url = "https://example.test/" + "a" * (length - len("https://example.test/"))
def unavailable(request):
raise httpx.ConnectError("offline", request=request)
@@ -134,8 +135,7 @@ async def test_gateway_failure_never_fabricates_a_shortened_requested_url(monkey
@pytest.mark.parametrize("protocol", ["anthropic", "openai_responses", "openai_chat", "google"])
-async def test_newly_produced_result_replays_without_fetch_or_rebill(monkeypatch, protocol):
- monkeypatch.setattr(v2_config, "WEB_FETCH_ACTIVE", True)
+async def test_newly_produced_result_replays_without_fetch_or_rebill(protocol):
fixture = json.loads(FIXTURE.read_text())
calls = []
def gateway(request):