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(vibey): replay hosted calls verbatim to their own Source and resend portably once on pin_unavailable (#2577)

Call Whiteeae8357c2b70
diff --git a/core/agent_core/ai/_common.py b/core/agent_core/ai/_common.py
index 1e639faf7..a8f5019ab 100644
--- a/core/agent_core/ai/_common.py
+++ b/core/agent_core/ai/_common.py
@@ -1579,6 +1579,38 @@ def request_credential_values(endpoint: ModelEndpoint) -> tuple[str, ...]:
#: Pins a request that carries Source-specific hosted content to one Source (``vibey-hosted-tools.md`` §3.5): the
#: gateway serves it from that Source only, and answers ``pin_unavailable`` where it would otherwise fail over.
PIN_SOURCE_HEADER = "x-avibe-pin-source"
+#: With the pin of an in-flight continuation: the served model of the response it continues.
+PIN_MODEL_HEADER = "x-avibe-pin-model"
+
+
+class PinUnavailable:
+ """The gateway's answer to a pinned request it cannot serve from the pinned Source (§3.5): HTTP 409
+ ``pin_unavailable``, before anything reached a model. ``drive_sse_stream`` yields it in place of a terminal."""
+
+
+PIN_UNAVAILABLE = PinUnavailable()
+
+
+def _pin_unavailable(body: str) -> bool:
+ try:
+ value = json.loads(body)
+ except (TypeError, ValueError):
+ return False
+ error = value.get("error") if isinstance(value, Mapping) else None
+ return (
+ isinstance(error, Mapping)
+ and error.get("type") == "model_hub_pin_unavailable"
+ and error.get("code") == "pin_unavailable"
+ )
+
+
+def portable_request(request: ModelRequest) -> ModelRequest:
+ """The same request in portable form (§3.5): no Source to pin to, and every hosted tool as its function, so it
+ carries no native declaration and replays no native payload."""
+
+ endpoint = request.endpoint
+ routes = {name: HostedToolRoute("proxy", route.executor, False) for name, route in endpoint.hosted_tools.items()}
+ return replace(request, endpoint=replace(endpoint, source_id=None, hosted_tools=routes))
@dataclass(frozen=True)
@@ -1607,14 +1639,37 @@ def native_declaration(route: HostedToolRoute) -> dict[str, Any]:
return copy.deepcopy(dict(route.declaration or {}))
-def hosted_pin(request: ModelRequest) -> dict[str, str]:
- """The pin header of a request that sends a native hosted declaration, else nothing."""
+def hosted_pin(request: ModelRequest, messages: tuple[Any, ...] = ()) -> dict[str, str]:
+ """The pin of a request that carries Source-specific hosted content (§3.5), else nothing.
+
+ ``messages`` are the request's transformed messages; a call goes back verbatim only to the hop's own Source, so
+ that is the pin. A continuation whose calls go back verbatim also names the model that served them.
+
+ A model id that is not a legal header value (printable ASCII, no surrounding space) is left out: the pinned Source
+ is the hop's, and the gateway takes that hop's own model, which served the continued response.
+ """
+
+ from core.agent_core.ai.transform import in_flight_position
+
+ def replays(message: Any) -> bool:
+ return isinstance(message, AssistantMessage) and any(isinstance(b, HostedToolBlock) for b in message.content)
- if not native_hosted_tools(request):
+ if not native_hosted_tools(request) and not any(replays(message) for message in messages):
return {}
if not request.endpoint.source_id:
- raise ValueError("a native hosted declaration needs the Source the request is pinned to")
- return {PIN_SOURCE_HEADER: request.endpoint.source_id}
+ raise ValueError("native hosted content needs the Source the request is pinned to")
+ pin = {PIN_SOURCE_HEADER: request.endpoint.source_id}
+ live = in_flight_position(messages)
+ continued = messages[live] if live is not None else None
+ if replays(continued) and _header_value(continued.origin.model):
+ pin[PIN_MODEL_HEADER] = continued.origin.model
+ return pin
+
+
+def _header_value(value: str) -> bool:
+ """Whether ``value`` can travel as an HTTP header value as it is: printable ASCII, with no surrounding space."""
+
+ return bool(value) and value == value.strip() and all(" " <= char <= "~" for char in value)
def forced_tool(request: ModelRequest) -> tuple[str, HostedToolRoute | None] | None:
@@ -1734,6 +1789,11 @@ async def drive_sse_stream(
else:
if body is None:
candidate = assembler.aborted(cancel.reason)
+ elif gateway and response.status_code == 409 and PIN_SOURCE_HEADER in headers and _pin_unavailable(body):
+ # The pinned Source cannot serve this content; nothing reached a model. The adapter sends
+ # the same request once more in portable form (§3.5), so no terminal is committed here.
+ yield PIN_UNAVAILABLE
+ return
else:
candidate = assembler.error(
body or f"provider endpoint returned HTTP {response.status_code}",
@@ -1937,6 +1997,7 @@ async def prepare_messages(
protocol: str,
media_loader: MediaLoader | None,
cancel: CancelToken,
+ endpoint: ModelEndpoint | None = None,
) -> tuple[tuple[Any, ...], dict[str, tuple[str, str]]] | ProviderError:
"""Transform history and resolve immutable media snapshots as one safe boundary."""
@@ -1948,6 +2009,7 @@ async def prepare_messages(
target=target,
supports_images=supports_images,
protocol=protocol,
+ endpoint=endpoint,
)
loaded_images = await load_images(transformed.messages, media_loader, cancel)
except _CancelledDependency:
diff --git a/core/agent_core/ai/anthropic.py b/core/agent_core/ai/anthropic.py
index 63fce1c67..aa83a474d 100644
--- a/core/agent_core/ai/anthropic.py
+++ b/core/agent_core/ai/anthropic.py
@@ -7,6 +7,7 @@ httpx directly so Model Hub remains the only gateway boundary.
from __future__ import annotations
+import copy
import json
import logging
import re
@@ -25,6 +26,8 @@ from core.agent_core.ai._common import (
dispatch_wire_event,
endpoint_origin,
hosted_pin,
+ PIN_UNAVAILABLE,
+ portable_request,
join_endpoint_url,
json_object,
native_declaration,
@@ -48,6 +51,7 @@ from core.agent_core.ai.provider import (
from core.agent_core.cancel import CancelToken
from core.agent_core.messages import (
AssistantMessage,
+ HostedToolBlock,
ImageBlock,
TextBlock,
ThinkingBlock,
@@ -232,6 +236,7 @@ class AnthropicAdapter(ProviderAdapter):
protocol=self.protocol,
media_loader=self._media_loader,
cancel=cancel,
+ endpoint=request.endpoint,
)
if isinstance(prepared, ProviderError):
terminal = assembler.terminal(prepared)
@@ -792,10 +797,11 @@ class AnthropicAdapter(ProviderAdapter):
terminal = assembler.terminal(assembler.incomplete())
if terminal is not None:
yield terminal
+ sending = request
while True:
# The lifetime ``wire_request`` gives the prefix: the default once this route has rejected the field.
- prefix_ttl = _prefix_ttl(request)
- wire = wire_request(request, transformed_messages, gateway=self._gateway, loaded_images=loaded_images)
+ prefix_ttl = _prefix_ttl(sending)
+ wire = wire_request(sending, transformed_messages, gateway=self._gateway, loaded_images=loaded_images)
driver = drive_sse_stream(
self._client,
method="POST",
@@ -804,20 +810,45 @@ class AnthropicAdapter(ProviderAdapter):
headers=wire.headers,
cancel=cancel,
assembler=assembler,
- endpoint=request.endpoint,
+ endpoint=sending.endpoint,
resolver=self._served_hop_resolver,
gateway=self._gateway,
translate=translate,
)
- rejected = False
+ rejected = unavailable = False
try:
async for event in driver:
+ if event is PIN_UNAVAILABLE:
+ unavailable = True
+ break
if prefix_ttl is not None and _rejects_ttl(event):
rejected = True
break
yield event
finally:
await driver.aclose()
+ if unavailable and sending is request:
+ # The pinned Source cannot serve this content: the same request once more, in portable form and
+ # unpinned, which the gateway fails over as any other (§3.5). Never the generic retry.
+ sending = portable_request(request)
+ hosted = frozenset()
+ prepared = await prepare_messages(
+ sending.messages,
+ target=origin,
+ supports_images=sending.supports_images,
+ protocol=self.protocol,
+ media_loader=self._media_loader,
+ cancel=cancel,
+ endpoint=sending.endpoint,
+ )
+ if isinstance(prepared, ProviderError):
+ terminal = assembler.terminal(prepared)
+ if terminal is not None:
+ yield terminal
+ return
+ transformed_messages, loaded_images = prepared
+ assembler = new_assembler()
+ continue
if not rejected:
return
# The endpoint refused the request before answering, so the consumer saw nothing: send it once more
@@ -914,7 +945,7 @@ def wire_request(
payload = build_messages_payload(request, messages, loaded_images=loaded_images, prefix_ttl=_prefix_ttl(request))
headers = auth_headers(request.endpoint, provider="anthropic", gateway=gateway)
headers.update({"anthropic-version": ANTHROPIC_VERSION, "content-type": "application/json"})
- headers.update(hosted_pin(request))
+ headers.update(hosted_pin(request, messages))
return WireRequest(join_endpoint_url(request.endpoint.base_url, "/messages"), headers, payload)
@@ -941,6 +972,9 @@ def _message_to_anthropic(
content.append({"type": "text", "text": block.text})
elif isinstance(block, ToolCallBlock):
content.append({"type": "tool_use", "id": block.id, "name": block.name, "input": dict(block.arguments)})
+ elif isinstance(block, HostedToolBlock):
+ # Its server_tool_use and web_search_tool_result, verbatim (transform allowed it for this Source).
+ content.extend(copy.deepcopy(list(block.native.payload)))
return {"role": "assistant", "content": content}
if isinstance(message, ToolResultMessage):
result = _anthropic_user_content(message.content, supports_images, loaded_images)
diff --git a/core/agent_core/ai/openai_chat.py b/core/agent_core/ai/openai_chat.py
index 79013fc45..8d8c0ed18 100644
--- a/core/agent_core/ai/openai_chat.py
+++ b/core/agent_core/ai/openai_chat.py
@@ -22,6 +22,8 @@ from core.agent_core.ai._common import (
endpoint_origin,
forced_tool,
hosted_pin,
+ PIN_UNAVAILABLE,
+ portable_request,
join_endpoint_url,
json_object,
native_declaration,
@@ -198,6 +200,7 @@ class OpenAIChatAdapter(ProviderAdapter):
protocol=self.protocol,
media_loader=self._media_loader,
cancel=cancel,
+ endpoint=request.endpoint,
)
if isinstance(prepared, ProviderError):
terminal = assembler.terminal(prepared)
@@ -636,24 +639,51 @@ class OpenAIChatAdapter(ProviderAdapter):
terminal = assembler.terminal(final if isinstance(final, ProviderError) else Done(final))
if terminal is not None:
yield terminal
- driver = drive_sse_stream(
- self._client,
- method="POST",
- url=wire.url,
- json_body=wire.body,
- headers=wire.headers,
- cancel=cancel,
- assembler=assembler,
- endpoint=request.endpoint,
- resolver=self._served_hop_resolver,
- gateway=self._gateway,
- translate=translate,
- )
- try:
- async for event in driver:
- yield event
- finally:
- await driver.aclose()
+ sending = request
+ while True:
+ driver = drive_sse_stream(
+ self._client,
+ method="POST",
+ url=wire.url,
+ json_body=wire.body,
+ headers=wire.headers,
+ cancel=cancel,
+ assembler=assembler,
+ endpoint=sending.endpoint,
+ resolver=self._served_hop_resolver,
+ gateway=self._gateway,
+ translate=translate,
+ )
+ unavailable = False
+ try:
+ async for event in driver:
+ if event is PIN_UNAVAILABLE:
+ unavailable = True
+ break
+ yield event
+ finally:
+ await driver.aclose()
+ if not unavailable or sending is not request:
+ return
+ # The pinned Source cannot serve this content: the same request once more, in portable form and
+ # unpinned, which the gateway fails over as any other (§3.5). Never the generic retry.
+ sending = portable_request(request)
+ prepared = await prepare_messages(
+ sending.messages,
+ target=endpoint_origin(sending.endpoint),
+ supports_images=sending.supports_images,
+ protocol=self.protocol,
+ media_loader=self._media_loader,
+ cancel=cancel,
+ endpoint=sending.endpoint,
+ )
+ if isinstance(prepared, ProviderError):
+ terminal = assembler.terminal(prepared)
+ if terminal is not None:
+ yield terminal
+ return
+ transformed_messages, loaded_images = prepared
+ wire = wire_request(sending, transformed_messages, gateway=self._gateway, loaded_images=loaded_images)
except Exception as exc:
terminal = assembler.terminal(assembler.exception(exc))
if terminal is not None:
@@ -732,7 +762,7 @@ def wire_request(
payload = build_chat_payload(request, messages, loaded_images=loaded_images)
headers = auth_headers(request.endpoint, provider="openai", gateway=gateway)
headers.setdefault("content-type", "application/json")
- headers.update(hosted_pin(request))
+ headers.update(hosted_pin(request, messages))
return WireRequest(join_endpoint_url(request.endpoint.base_url, "/chat/completions"), headers, payload)
diff --git a/core/agent_core/ai/openai_responses.py b/core/agent_core/ai/openai_responses.py
index fb877c67e..ce19d0c0a 100644
--- a/core/agent_core/ai/openai_responses.py
+++ b/core/agent_core/ai/openai_responses.py
@@ -9,6 +9,7 @@ Payload and stream rules are ported from tau's ``tau_ai/openai_compatible.py``
from __future__ import annotations
+import copy
import json
from collections.abc import AsyncIterator, Mapping
from typing import Any
@@ -33,6 +34,8 @@ from core.agent_core.ai._common import (
endpoint_origin,
forced_tool,
hosted_pin,
+ PIN_UNAVAILABLE,
+ portable_request,
join_endpoint_url,
json_object,
native_declaration,
@@ -322,6 +325,7 @@ class OpenAIResponsesAdapter(ProviderAdapter):
protocol=self.protocol,
media_loader=self._media_loader,
cancel=cancel,
+ endpoint=request.endpoint,
)
if isinstance(prepared, ProviderError):
terminal = assembler.terminal(prepared)
@@ -1283,24 +1287,52 @@ class OpenAIResponsesAdapter(ProviderAdapter):
terminal = assembler.terminal(assembler.incomplete())
if terminal is not None:
yield terminal
- driver = drive_sse_stream(
- self._client,
- method="POST",
- url=wire.url,
- json_body=wire.body,
- headers=wire.headers,
- cancel=cancel,
- assembler=assembler,
- endpoint=request.endpoint,
- resolver=self._served_hop_resolver,
- gateway=self._gateway,
- translate=translate,
- )
- try:
- async for event in driver:
- yield event
- finally:
- await driver.aclose()
+ sending = request
+ while True:
+ driver = drive_sse_stream(
+ self._client,
+ method="POST",
+ url=wire.url,
+ json_body=wire.body,
+ headers=wire.headers,
+ cancel=cancel,
+ assembler=assembler,
+ endpoint=sending.endpoint,
+ resolver=self._served_hop_resolver,
+ gateway=self._gateway,
+ translate=translate,
+ )
+ unavailable = False
+ try:
+ async for event in driver:
+ if event is PIN_UNAVAILABLE:
+ unavailable = True
+ break
+ yield event
+ finally:
+ await driver.aclose()
+ if not unavailable or sending is not request:
+ return
+ # The pinned Source cannot serve this content: the same request once more, in portable form and
+ # unpinned, which the gateway fails over as any other (§3.5). Never the generic retry.
+ sending = portable_request(request)
+ hosted = frozenset()
+ prepared = await prepare_messages(
+ sending.messages,
+ target=endpoint_origin(sending.endpoint),
+ supports_images=sending.supports_images,
+ protocol=self.protocol,
+ media_loader=self._media_loader,
+ cancel=cancel,
+ endpoint=sending.endpoint,
+ )
+ if isinstance(prepared, ProviderError):
+ terminal = assembler.terminal(prepared)
+ if terminal is not None:
+ yield terminal
+ return
+ transformed_messages, loaded_images = prepared
+ wire = wire_request(sending, transformed_messages, gateway=self._gateway, loaded_images=loaded_images)
except Exception as exc:
terminal = assembler.terminal(assembler.exception(exc))
if terminal is not None:
@@ -1369,7 +1401,7 @@ def wire_request(
payload = build_responses_payload(request, messages, loaded_images=loaded_images)
headers = auth_headers(request.endpoint, provider="openai", gateway=gateway)
headers.setdefault("content-type", "application/json")
- headers.update(hosted_pin(request))
+ headers.update(hosted_pin(request, messages))
return WireRequest(join_endpoint_url(request.endpoint.base_url, "/responses"), headers, payload)
@@ -1412,6 +1444,9 @@ def _message_to_response(
"arguments": json.dumps(dict(block.arguments), ensure_ascii=False),
}
)
+ elif isinstance(block, HostedToolBlock):
+ # Its output items, verbatim (transform allowed it for this Source).
+ items.extend(copy.deepcopy(list(block.native.payload)))
return items or [{"role": "assistant", "content": ""}]
if isinstance(message, ToolResultMessage):
values = content_parts(message.content, include_images=supports_images, loaded_images=loaded_images)
diff --git a/core/agent_core/ai/registry.py b/core/agent_core/ai/registry.py
index 5c5322e46..81f95cb71 100644
--- a/core/agent_core/ai/registry.py
+++ b/core/agent_core/ai/registry.py
@@ -65,6 +65,7 @@ async def build_wire_request(
protocol=protocol,
media_loader=media_loader,
cancel=cancel or CancelToken(),
+ endpoint=request.endpoint,
)
if isinstance(prepared, ProviderError):
raise ValueError(prepared.message)
diff --git a/core/agent_core/ai/transform.py b/core/agent_core/ai/transform.py
index d69283204..d8548c695 100644
--- a/core/agent_core/ai/transform.py
+++ b/core/agent_core/ai/transform.py
@@ -13,6 +13,7 @@ from dataclasses import dataclass
from typing import Any, Mapping
from core.agent_core.ai.hosted import portable_hosted
+from core.agent_core.ai.provider import ModelEndpoint
from core.agent_core.messages import (
AssistantMessage,
AssistantContent,
@@ -71,16 +72,18 @@ def transform_messages(
target: Origin,
supports_images: bool = True,
protocol: str | None = None,
+ endpoint: ModelEndpoint | None = None,
) -> TransformResult:
"""Compile canonical history for one target origin.
- The returned map is per request. The transcript is never mutated.
+ The returned map is per request. The transcript is never mutated. ``endpoint`` is the hop the request goes to; a
+ response's hosted calls go back verbatim only to the Source that served them (``native_replay``).
"""
target_protocol = protocol or target.api
- # The request's last assistant message still awaits its turn's next response when it stopped for tools: its
- # hosted calls stay in place as text (§4.4); every earlier one becomes a synthetic call and result (§5).
- last_assistant = max((i for i, m in enumerate(messages) if isinstance(m, AssistantMessage)), default=-1)
+ # The response the request continues within its turn keeps its hosted calls in place, verbatim or as text (§4.4);
+ # every earlier one goes back verbatim with replay evidence or as a synthetic call and result (§5).
+ live = in_flight_position(messages)
id_map: dict[str, str] = {}
used_tool_ids: set[str] = set()
tool_id_occurrences: dict[str, int] = {}
@@ -123,8 +126,9 @@ def transform_messages(
same_origin = message.origin == target
content: list[AssistantContent] = []
turn_tool_ids: dict[str, list[str]] = {}
- in_flight = position == last_assistant and message.stop_reason == "tool_use"
- hosted = portable_hosted(message, in_flight=in_flight, interrupted=SYNTHETIC_TOOL_RESULT)
+ in_flight = position == live
+ verbatim = native_replay(message, in_flight=in_flight, endpoint=endpoint, target=target, protocol=target_protocol)
+ hosted = {} if verbatim else portable_hosted(message, in_flight=in_flight, interrupted=SYNTHETIC_TOOL_RESULT)
# The synthetic results of the current run of hosted calls, and the assistant parts they split off.
results: list[ToolResultMessage] = []
parts: list[Message] = []
@@ -137,6 +141,9 @@ def transform_messages(
content, results = [], []
for block in message.content:
+ if isinstance(block, HostedToolBlock) and verbatim:
+ content.append(block) # its native payload, rendered in place by the protocol's builder
+ continue
if isinstance(block, HostedToolBlock):
portable = hosted[id(block)]
if portable.kind == "in_place":
@@ -214,15 +221,64 @@ def transform_messages(
def _assistant_part(message: AssistantMessage, content: list[AssistantContent], *, stop_reason: str) -> AssistantMessage:
+ hosted = any(isinstance(block, HostedToolBlock) for block in content)
return AssistantMessage(
content=tuple(content),
origin=message.origin,
stop_reason=stop_reason, # type: ignore[arg-type]
usage=message.usage,
error_message=message.error_message,
+ hosted_summary=message.hosted_summary if hosted else None,
)
+def in_flight_position(messages: list[Message] | tuple[Message, ...]) -> int | None:
+ """The position of the response a request continues within its turn (§4.4), or None.
+
+ It is the request's last assistant message, stopped for tools, with nothing after it but tool results (a
+ ``pause_turn`` continuation has none). A user message after it means its turn ended, as one may right after its
+ tool results, so a later turn never counts as continuing it.
+ """
+
+ last = max((i for i, m in enumerate(messages) if isinstance(m, AssistantMessage)), default=None)
+ if last is None or messages[last].stop_reason != "tool_use": # type: ignore[union-attr]
+ return None
+ if any(not isinstance(message, ToolResultMessage) for message in messages[last + 1 :]):
+ return None
+ return last
+
+
+def native_replay(
+ message: AssistantMessage, *, in_flight: bool, endpoint: ModelEndpoint | None, target: Origin, protocol: str
+) -> bool:
+ """Whether a response's hosted calls go back verbatim, their native payloads in place (§4.4, §5).
+
+ Only to the hop the request goes to, when that hop's Source served them on the same origin: one hop then builds
+ the request and serves it (§3.5 as implemented; a moved hop gets the in-place form). The hop must still have each
+ tool they called and a Source, which a portable request has not, over a protocol with native hosted content. A
+ generated image never goes back verbatim: its stored item no longer holds the image.
+ * The response its turn continues (``in_flight``) needs no replay evidence: that is the provider's own
+ continuation contract.
+ * Any earlier response needs the hop's current ``replay`` evidence for every tool it called, and every one of its
+ calls finished.
+ """
+
+ blocks = [block for block in message.content if isinstance(block, HostedToolBlock)]
+ if not blocks or endpoint is None or not endpoint.source_id or message.origin != target:
+ return False
+ if protocol not in ("anthropic", "openai_responses"):
+ return False
+ if {block.native.source_id for block in blocks} != {endpoint.source_id}:
+ return False
+ for block in blocks:
+ route = endpoint.hosted_tools.get(block.tool)
+ if route is None or block.tool == "image_generation":
+ return False
+ if not in_flight and (not route.replay or block.record.status == "pending"):
+ return False
+ return True
+
+
def transform_messages_for_target(
messages: list[Message] | tuple[Message, ...],
target: Origin,
diff --git a/core/agent_core/harness/context.py b/core/agent_core/harness/context.py
index e7cf3ed23..60b958973 100644
--- a/core/agent_core/harness/context.py
+++ b/core/agent_core/harness/context.py
@@ -265,11 +265,12 @@ def message_tokens(message: Message) -> int:
if block.signature is not None:
payload = (payload or 0) + _utf8(block.signature)
elif isinstance(block, HostedToolBlock):
- # Replayed in portable form, never as its native payload (§5): the larger of its synthetic call and
- # result and its in-place text, so the estimate holds wherever the message sits.
+ # The largest form it can go back in (§5), so the estimate holds wherever the message sits and whatever
+ # hop it goes to: its synthetic call and result, its in-place text, or its native payload verbatim.
if hosted is None:
hosted = portable_sizes(message, interrupted=SYNTHETIC_TOOL_RESULT) # type: ignore[arg-type]
- hosted_bytes += hosted[id(block)]
+ native = json.dumps(list(block.native.payload), ensure_ascii=False, separators=(",", ":"))
+ hosted_bytes += max(hosted[id(block)], _utf8(native))
reasoning = 0 if payload is None else max(math.ceil(signed / 4), _reasoning(message, payload))
return math.ceil((size + hosted_bytes) / 4) + images * IMAGE_TOKENS + reasoning
diff --git a/docs/plans/agent-core-contracts/conversion-tables.md b/docs/plans/agent-core-contracts/conversion-tables.md
index 1a521ebf4..3901adac7 100644
--- a/docs/plans/agent-core-contracts/conversion-tables.md
+++ b/docs/plans/agent-core-contracts/conversion-tables.md
@@ -657,11 +657,26 @@ far:
turn is still waiting on (the request's last assistant message, stopped for tools) keeps each call in place as text.
So does a hosted call that follows a client tool call of the same response, because a split there would separate
that call from its result.
+- **Native replay and pins.** A response's hosted calls go back verbatim, their `native.payload` in place, only to
+ the hop the request goes to, and only when that hop's Source served them on the same origin. The protocol must be
+ Anthropic or Responses, the hop must still have each tool they called, and `image_generation` never goes back
+ verbatim. Such a request is pinned to the hop's Source.
+ - The response a request continues within its turn needs no replay evidence, and its request also names the
+ model that served it (`x-avibe-pin-model`, when that id is ASCII). That response is the request's last assistant
+ message, stopped for tools, with only tool results after it.
+ - Any earlier response needs the hop's current `replay` for every tool it called, and every one of its calls must
+ have finished.
+ - Otherwise the calls take the portable form above. A continuation whose fresh hop is another Source therefore
+ goes in place as text: one hop builds and serves each request.
+- **`pin_unavailable`.** The gateway's `409` `model_hub_pin_unavailable` / `pin_unavailable` answer to a pinned
+ request is never shown and never reaches the loop's retry: the adapter renders the same request once more in
+ portable form (proxy declarations, synthetic history, in-place text) and sends it unpinned. Whatever answers that
+ request reaches the loop as usual.
- **Proxy.** A hosted tool that a hop does not run natively is its canonical function, and a call to it runs on the
gateway's executor bound for the Turn. The result keeps the record on `ToolResultMessage.hosted`.
-Still to come: native verbatim replay, the `pin_unavailable` re-render, `pause_turn` and images.
+Still to come: `pause_turn` and images.
Until `pause_turn` lands, the Anthropic stop table above still maps it to `stop`. An Anthropic citation covers its
whole text block, so it carries no range.
@@ -675,7 +690,7 @@ whole text block, so it carries no range.
| Same-Source replay (target hop is `native.source_id`, same origin, and `hosted_tools[tool].replay` is true now) | `native.payload` blocks verbatim, in place; citations not sent | `native.payload` items verbatim, in place; annotations not sent; never for `image_generation` | — |
| Images | — | `image_generation_call` → file; history and model context hold the text path record (path, revised prompt, size, mode, cost); `result` base64 never stored; duplicate `result` in `response.completed` not decoded; the image-declaring stream gets a 32 MiB line cap | — |
| Other-origin replay | assistant `tool_use(name=<tool>, input=<per-action arguments>)` + user `tool_result(record as text)`, splitting the assistant message; a `failed`/`incomplete` record sets `is_error: true` | `function_call(name=<tool>, arguments)` + `function_call_output(record as text)`; a failed record's text starts `[<tool> failed: <error>]` | assistant `tool_calls` + `tool` message, failure as in Responses |
-| Pinning (any protocol) | a request with a native declaration, a `native.payload` or an in-flight continuation carries `x-avibe-pin-source`. A `409` `model_hub_pin_unavailable` / `pin_unavailable` answer is not shown: the same request is rendered again in portable form (proxy declarations, synthetic history, in-place text) and sent unpinned. | same | — |
+| Pinning (any protocol) | a request with a native declaration or a verbatim `native.payload` carries `x-avibe-pin-source: <hop source_id>`. A continuation whose calls go back verbatim also carries `x-avibe-pin-model: <its served model>`, the hop's own model. A `409` `model_hub_pin_unavailable` / `pin_unavailable` answer is not shown: the same request is rendered again in portable form (proxy declarations, synthetic history, in-place text) and sent unpinned, exactly once. | same | — |
| Citations at delivery | `TextBlock.citations` → `core/citations.py` builder → Markdown links + Web sidecar | same | — |
| `pause_turn` | not a stop: the adapter re-sends the request with the paused assistant content appended (no new user message), pinned to the paused response's Source (`x-avibe-pin-source`), and keeps streaming as one response, at most 5 continuations. `usage` is the sum of every continuation's counters. | — | — |
-| In-flight replay (same turn, pinned Source) | verbatim. On a narrow rejection or `pin_unavailable`, each server block pair is replaced in place by one text block; signed thinking is kept on the same origin. | verbatim | — |
+| In-flight replay (same turn, pinned Source) | verbatim when the fresh hop is the Source that served it, else in place as text. On `pin_unavailable`, which the gateway also answers for a narrow rejection of the replayed content (§3.5), each server block pair is replaced in place by one text block; signed thinking is kept on the same origin. | same | — |
diff --git a/docs/plans/agent-core-contracts/cross-provider.md b/docs/plans/agent-core-contracts/cross-provider.md
index 4bd5039b3..b92c591f9 100644
--- a/docs/plans/agent-core-contracts/cross-provider.md
+++ b/docs/plans/agent-core-contracts/cross-provider.md
@@ -29,7 +29,7 @@ Invariants:
`[tool call interrupted; no result recorded]`, with `is_error: true` (C-5 settles most such calls from the job handle
first).
- Responses API requests use `store: false` and never `previous_response_id`.
-- Hosted tool blocks (planned, [`../vibey-hosted-tools.md`](../vibey-hosted-tools.md) §5): `native.payload` is an
+- Hosted tool blocks ([`../vibey-hosted-tools.md`](../vibey-hosted-tools.md) §5): `native.payload` is an
opaque provider payload under every rule above, and its replay is further limited to the recorded Source while
that Source's current replay evidence is positive. The block never stores replay authorization. A different
origin loses page text: Anthropic returns it only encrypted, and OpenAI and xAI never return it. Within one
diff --git a/docs/plans/agent-core-contracts/provider.md b/docs/plans/agent-core-contracts/provider.md
index 9ed450c2c..feaffd545 100644
--- a/docs/plans/agent-core-contracts/provider.md
+++ b/docs/plans/agent-core-contracts/provider.md
@@ -65,6 +65,12 @@ is named, and a native hosted tool is forced with `"required"`, which needs it t
Anthropic request is never forced: current Claude models and extended thinking refuse a forced `tool` or `any`
choice.
+History follows the same Source rule. A response's hosted calls go back verbatim only to the hop the request goes to,
+when that hop's Source served them on the same origin (`conversion-tables.md`, Hosted tools): within their turn as a
+continuation, later with the hop's current `replay`, and pinned to that Source either way. The gateway answers a pinned request it cannot serve from that Source with
+`409 pin_unavailable`. That answer is not a `ProviderError`: the adapter sends the same request exactly once more in
+portable form and unpinned, so the loop's retry never sees it.
+
The loop's `ModelRouter` returns the `ModelEndpoint` together with its `ModelCapabilities`. Every capability has a
defined effect, including when it is unknown:
diff --git a/docs/plans/vibey-hosted-tools.md b/docs/plans/vibey-hosted-tools.md
index 96d72cb5a..5e29417b6 100644
--- a/docs/plans/vibey-hosted-tools.md
+++ b/docs/plans/vibey-hosted-tools.md
@@ -218,6 +218,13 @@ verified for X search.
The value is `HopResolution.source_id` for the first two. For a continuation it is the Source the previous
response came from, according to the served-hop report.
+
+ **As implemented (orchestrator decision, 2026-10-14):** every model attempt resolves a fresh hop (C-6 item 3), so
+ verbatim content goes only to the hop whose own Source served it, on the same origin, and every pin is
+ `HopResolution.source_id`. A continuation whose fresh hop is another Source takes the in-place text form (§4.4),
+ unpinned. Pinning it to the previous Source would build the request for one hop (declarations, model, efforts,
+ signature target) and serve it from another. A continuation also sends `x-avibe-pin-model` with its served model
+ when that id is ASCII. Without the header, the gateway takes the pinned Source's own model, which is the same hop.
- The gateway serves a pinned request only from that Source, with no failover and no recovery wait.
- The gateway answers the local error `pin_unavailable` in three cases:
- the Source cannot be admitted for this content, checked before invoking anything: it is cooling down, it was
diff --git a/tests/agent_core/agent/test_context.py b/tests/agent_core/agent/test_context.py
index dd386a3de..0cd4fd334 100644
--- a/tests/agent_core/agent/test_context.py
+++ b/tests/agent_core/agent/test_context.py
@@ -124,21 +124,31 @@ def test_the_estimate_counts_utf8_bytes_so_chinese_is_not_undercounted():
assert message_tokens(reply) == math.ceil(replayed / 4)
-def test_a_hosted_call_counts_as_the_call_and_result_it_is_replayed_as_never_as_its_opaque_payload():
- """A hosted call goes back as a synthetic call and its result text, not its native payload (§5), so that is what
- it costs: an opaque Anthropic search result of 18 KB would otherwise overcount and compact early, and the call's
- arguments, which repeat its query, would go uncounted."""
+ ("payload", "counted"),
+ [
+ # An OpenAI web_search_call item is smaller than the synthetic call and result it goes back as elsewhere.
+ ({"type": "web_search_call", "id": "ws_1"}, "portable"),
+ # An Anthropic search result is mostly its encrypted pages, which go back verbatim to the Source that served
+ # them (§4.4, §5).
+ ({"type": "web_search_tool_result", "encrypted_content": "x" * 18_000}, "native"),
+ ],
+)
+def test_a_hosted_call_counts_as_the_largest_form_it_can_go_back_in(payload, counted):
+ """Whether a hosted call goes back verbatim depends on the hop each request goes to, so its estimate is its largest
+ form: its native payload, or its synthetic call (whose arguments repeat its query) and result."""
search = HostedToolBlock(
id="srvtoolu_1",
tool="web_search",
action=HostedAction("search", queries=("q",)),
record=HostedRecord(status="completed", sources=(HostedSource(url="https://a.test"),)),
- native=HostedNative(source_id="src_served00001", payload=({"encrypted_content": "x" * 18_000},)),
+ native=HostedNative(source_id="src_served00001", payload=(payload,)),
)
reply = AssistantMessage((search,), ORIGIN, "stop", hosted_summary=HostedSummary())
- arguments = '{"query":"q"}'
- rendered = '[web_search: "q"]\n1. https://a.test'
- assert message_tokens(reply) == math.ceil((len("web_search") + len(arguments) + len(rendered)) / 4)
+ portable = len("web_search") + len('{"query":"q"}') + len('[web_search: "q"]\n1. https://a.test')
+ native = len(json.dumps([payload], separators=(",", ":")))
+ assert message_tokens(reply) == math.ceil((portable if counted == "portable" else native) / 4)
+ assert (native > portable) is (counted == "native")
def responses_item(reasoning: int, summary: str = "") -> ThinkingBlock:
diff --git a/tests/agent_core/ai/test_hosted_replay.py b/tests/agent_core/ai/test_hosted_replay.py
new file mode 100644
index 000000000..ac6beab15
--- /dev/null
+++ b/tests/agent_core/ai/test_hosted_replay.py
@@ -0,0 +1,264 @@
+"""Native hosted replay and pinning (``vibey-hosted-tools.md`` §3.5, §4.4, §5). Scenario MH-HOSTED-VIBEY-005.
+
+A hosted call goes back verbatim, its native payload in place, only to the Source that served it, on the same origin,
+and either within its turn or with the hop's current ``replay`` evidence. Such a request is pinned to that Source; an
+in-flight continuation also names the model that served it. When the gateway answers ``pin_unavailable``, the adapter
+sends the same request exactly once more, in portable form and unpinned.
+"""
+
+from __future__ import annotations
+
+import json
+from dataclasses import replace
+from typing import Any
+
+import httpx
+import pytest
+
+from core.agent_core.ai._common import PIN_MODEL_HEADER, PIN_SOURCE_HEADER
+from core.agent_core.ai.provider import Done, HostedToolRoute, ModelEndpoint, ModelRequest, ProviderError
+from core.agent_core.ai.registry import build_wire_request, create_adapter
+from core.agent_core.cancel import CancelToken
+from core.agent_core.messages import (
+ AssistantMessage,
+ HostedAction,
+ HostedNative,
+ HostedRecord,
+ HostedSource,
+ HostedSummary,
+ HostedToolBlock,
+ Origin,
+ TextBlock,
+ ToolCallBlock,
+ ToolResultMessage,
+ UserMessage,
+)
+from core.agent_core.tools.hosted import hosted_tool_spec
+
+SOURCE = "src_served00001"
+OTHER = "src_other000001"
+WEB = hosted_tool_spec("web_search")
+CALL_ITEM = {
+ "id": "ws_1",
+ "type": "web_search_call",
+ "status": "completed",
+ "action": {"type": "search", "query": "avibe release", "sources": [{"type": "url", "url": "https://avibe.bot/r"}]},
+}
+USE = {"type": "server_tool_use", "id": "srvtoolu_1", "name": "web_search", "input": {"query": "avibe release"}}
+RESULT = {
+ "type": "web_search_tool_result",
+ "tool_use_id": "srvtoolu_1",
+ "content": [{"type": "web_search_result", "url": "https://avibe.bot/r", "title": "R", "encrypted_content": "opaque"}],
+}
+PAYLOADS = {"openai_responses": (CALL_ITEM,), "anthropic": (USE, RESULT)}
+MODELS = {
+ "openai_responses": ("xai", "grok-4.6"),
+ "anthropic": ("anthropic", "claude-opus-5-5"),
+ "openai_chat": ("google", "gemini-3-pro"),
+}
+
+
+def _endpoint(protocol: str, *, replay: bool, native: bool = True, source_id: str | None = SOURCE) -> ModelEndpoint:
+ provider, model = MODELS[protocol]
+ declaration = {"type": "web_search_20250305", "name": "web_search"} if protocol == "anthropic" else {"type": "web_search"}
+ route = (
+ HostedToolRoute("native", None, replay, declaration=declaration)
+ if native
+ else HostedToolRoute("proxy", None, replay)
+ )
+ return ModelEndpoint(
+ protocol, # type: ignore[arg-type]
+ "http://hub.invalid/vibey/v1",
+ model,
+ "hub-token",
+ provider=provider,
+ source_id=source_id,
+ hosted_tools={"web_search": route},
+ )
+
+
+def _searched(protocol: str, *, served_by: str = SOURCE, stop_reason: str = "stop", extra=()) -> AssistantMessage:
+ provider, model = MODELS[protocol]
+ call = HostedToolBlock(
+ id="ws_1" if protocol == "openai_responses" else "srvtoolu_1",
+ tool="web_search",
+ action=HostedAction("search", queries=("avibe release",)),
+ record=HostedRecord(status="completed", sources=(HostedSource(url="https://avibe.bot/r"),)),
+ native=HostedNative(source_id=served_by, payload=PAYLOADS[protocol]),
+ )
+ return AssistantMessage(
+ (call, TextBlock(text="found it"), *extra), Origin(provider, protocol, model), stop_reason, hosted_summary=HostedSummary()
+ )
+
+
+def _request(endpoint: ModelEndpoint, *messages: Any) -> ModelRequest:
+ return ModelRequest(
+ endpoint=endpoint,
+ system="system",
+ messages=(UserMessage((TextBlock("search"),)), *messages),
+ tools=(WEB,),
+ max_tokens=256,
+ cache="none",
+ )
+
+
+def _history_items(protocol: str, body: dict[str, Any]) -> list[dict[str, Any]]:
+ if protocol == "openai_responses":
+ return list(body["input"])
+ return [block for message in body["messages"] if isinstance(message["content"], list) for block in message["content"]]
+
+
+def _verbatim(protocol: str, body: dict[str, Any]) -> bool:
+ items = _history_items(protocol, body)
+ return all(item in items for item in PAYLOADS[protocol])
+
+
[email protected]("protocol", ["openai_responses", "anthropic"])
+ ("replay", "served_by", "verbatim"),
+ [(True, SOURCE, True), (False, SOURCE, False), (True, OTHER, False)],
+ ids=["same-source-with-replay-evidence", "no-replay-evidence", "another-source"],
+)
+async def test_a_hosted_call_goes_back_verbatim_and_pinned_only_to_its_own_source_with_replay_evidence(
+ protocol, replay, served_by, verbatim
+):
+ request = _request(
+ _endpoint(protocol, replay=replay, native=False),
+ _searched(protocol, served_by=served_by),
+ UserMessage((TextBlock("and then?"),)),
+ )
+
+ wire = await build_wire_request(request, gateway=True)
+
+ assert _verbatim(protocol, wire.body) is verbatim
+ # The request carries no native declaration here (a proxied route), so only a verbatim payload pins it.
+ assert (wire.headers.get(PIN_SOURCE_HEADER) == SOURCE) is verbatim
+ assert PIN_MODEL_HEADER not in wire.headers
+
+
[email protected]("protocol", ["openai_responses", "anthropic"])
+ ("hop_source", "after", "continued"),
+ [
+ (SOURCE, (), True),
+ (OTHER, (), False),
+ (SOURCE, (UserMessage((TextBlock("a new turn"),)),), False),
+ ],
+ ids=["on-the-hop-that-served-it", "after-the-hop-moved", "after-its-turn-ended"],
+)
+async def test_a_continuation_goes_back_verbatim_only_to_the_hop_that_served_it(protocol, hop_source, after, continued):
+ """Within its turn the provider's own continuation contract applies: no replay evidence is needed, and the request
+ is pinned to its hop's Source and the model that served the response it continues. A fresh hop that is another
+ Source gets the in-place form instead (§4.4), so one hop builds and serves the request. A turn can end right after
+ its tool results; a later turn is no continuation, so without replay evidence its calls go back portable."""
+
+ read = ToolCallBlock(id="toolu_1", name="read", arguments={"path": "a"})
+ request = _request(
+ _endpoint(protocol, replay=False, source_id=hop_source),
+ _searched(protocol, stop_reason="tool_use", extra=(read,)),
+ ToolResultMessage("toolu_1", "read", (TextBlock("contents"),)),
+ *after,
+ )
+
+ wire = await build_wire_request(request, gateway=True)
+
+ assert _verbatim(protocol, wire.body) is continued
+ # The hop's native declaration pins every case to the hop's own Source.
+ assert wire.headers[PIN_SOURCE_HEADER] == hop_source
+ assert (wire.headers.get(PIN_MODEL_HEADER) == MODELS[protocol][1]) is continued
+ if hop_source == OTHER:
+ in_place = json.dumps(wire.body)
+ assert '[web_search: \\"avibe release\\"]' in in_place
+
+
[email protected]("model", ["grok-4.6-é", "grok-4.6\nvariant", "grok-4.6\x00", " grok-4.6"])
+async def test_a_continuation_of_a_model_whose_id_is_no_header_value_is_pinned_to_its_source_alone(model):
+ """A header carries only printable ASCII: the continuation still goes out verbatim, pinned to its hop's Source,
+ whose own model the gateway takes."""
+
+ read = ToolCallBlock(id="toolu_1", name="read", arguments={"path": "a"})
+ searched = _searched("openai_responses", stop_reason="tool_use", extra=(read,))
+ endpoint = replace(_endpoint("openai_responses", replay=False), model_id=model)
+ request = _request(
+ endpoint,
+ replace(searched, origin=replace(searched.origin, model=model)),
+ ToolResultMessage("toolu_1", "read", (TextBlock("contents"),)),
+ )
+
+ wire = await build_wire_request(request, gateway=True)
+
+ assert _verbatim("openai_responses", wire.body)
+ assert wire.headers[PIN_SOURCE_HEADER] == SOURCE and PIN_MODEL_HEADER not in wire.headers
+ httpx.Request("POST", wire.url, headers=wire.headers, json=wire.body)
+
+
+_PIN_UNAVAILABLE = {"type": "error", "error": {"type": "model_hub_pin_unavailable", "code": "pin_unavailable"}}
+_ANSWERED = {
+ "openai_responses": (
+ {"type": "response.created", "response": {"status": "in_progress"}},
+ {"type": "response.output_item.added", "output_index": 0, "item": {"id": "msg_1", "type": "message", "status": "in_progress", "content": []}},
+ {"type": "response.output_text.delta", "output_index": 0, "delta": "ok"},
+ {
+ "type": "response.output_item.done",
+ "output_index": 0,
+ "item": {"id": "msg_1", "type": "message", "content": [{"type": "output_text", "text": "ok", "annotations": []}]},
+ },
+ {"type": "response.completed", "response": {"status": "completed", "output": None, "usage": {"input_tokens": 5, "output_tokens": 1}}},
+ ),
+ "anthropic": (
+ {"type": "message_start", "message": {"usage": {"input_tokens": 5}}},
+ {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}},
+ {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "ok"}},
+ {"type": "content_block_stop", "index": 0},
+ {"type": "message_delta", "delta": {"stop_reason": "end_turn"}, "usage": {"output_tokens": 1}},
+ {"type": "message_stop"},
+ ),
+ "openai_chat": (
+ {"choices": [{"delta": {"content": "ok"}}]},
+ {"choices": [{"delta": {}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 5, "completion_tokens": 1}},
+ ),
+}
+
+
+def _tool_name(tool: dict[str, Any]) -> str:
+ return tool.get("name") or tool["function"]["name"]
+
+
[email protected]("protocol", ["openai_responses", "anthropic", "openai_chat"])
[email protected]("second", ["served", "pin_unavailable"])
+async def test_pin_unavailable_gets_exactly_one_portable_resend_and_never_the_generic_retry(protocol, second):
+ """MH-HOSTED-VIBEY-005: the pinned request carries a native declaration and, where the protocol replays one, a
+ verbatim payload. Its one resend carries neither and no pin; that resend's own answer is what the loop sees."""
+
+ replayed = protocol in PAYLOADS
+ history = (_searched(protocol), UserMessage((TextBlock("and then?"),))) if replayed else ()
+ endpoint = _endpoint(protocol, replay=True)
+ request = _request(endpoint, *history)
+ provider, model = MODELS[protocol]
+ served = json.dumps({"provider": provider, "api": protocol, "model": model, "source": OTHER}, separators=(",", ":"))
+ sent: list[httpx.Request] = []
+
+ def gateway(wire: httpx.Request) -> httpx.Response:
+ sent.append(wire)
+ if len(sent) == 1 or second == "pin_unavailable":
+ return httpx.Response(409, json=_PIN_UNAVAILABLE)
+ body = "".join(f"data: {json.dumps(event)}\n\n" for event in _ANSWERED[protocol])
+ body += "data: [DONE]\n\n" if protocol == "openai_chat" else ""
+ return httpx.Response(200, headers={"content-type": "text/event-stream", "x-avibe-served-hop": served}, text=body)
+
+ async with httpx.AsyncClient(transport=httpx.MockTransport(gateway)) as client:
+ adapter = create_adapter(protocol, client=client, gateway=True) # type: ignore[arg-type]
+ events = [event async for event in adapter.stream(request, CancelToken())]
+
+ assert len(sent) == 2
+ pinned, portable = (json.loads(wire.content) for wire in sent)
+ assert sent[0].headers[PIN_SOURCE_HEADER] == SOURCE and PIN_SOURCE_HEADER not in sent[1].headers
+ assert pinned["tools"] == [dict(endpoint.hosted_tools["web_search"].declaration)]
+ assert [_tool_name(tool) for tool in portable["tools"]] == ["web_search"] and portable["tools"] != pinned["tools"]
+ if replayed:
+ assert _verbatim(protocol, pinned) and not _verbatim(protocol, portable)
+ if second == "served":
+ assert isinstance(events[-1], Done)
+ else:
+ # A 409 to an unpinned request is an ordinary error: there is no second portable resend.
+ assert isinstance(events[-1], ProviderError) and events[-1].status == 409
diff --git a/tests/scenarios/INDEX.yaml b/tests/scenarios/INDEX.yaml
index 6355bf5b2..29acb1479 100644
--- a/tests/scenarios/INDEX.yaml
+++ b/tests/scenarios/INDEX.yaml
@@ -57,6 +57,7 @@ capabilities:
- tests/agent_core/ai/test_hosted_requests.py
- tests/agent_core/ai/test_hosted_parsing.py
- tests/agent_core/ai/test_hosted_transform.py
+ - tests/agent_core/ai/test_hosted_replay.py
- tests/test_vibey_agent.py
- tests/test_model_hub_evidence_rules.py
- tests/test_model_hub_admission.py
diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yaml
index 0c594313e..af69d9ece 100644
--- a/tests/scenarios/model_hub/catalog.yaml
+++ b/tests/scenarios/model_hub/catalog.yaml
@@ -15,6 +15,7 @@ capability:
- tests/agent_core/ai/test_hosted_requests.py
- tests/agent_core/ai/test_hosted_parsing.py
- tests/agent_core/ai/test_hosted_transform.py
+ - tests/agent_core/ai/test_hosted_replay.py
- tests/test_vibey_agent.py
- tests/test_model_hub_evidence_rules.py
- tests/test_model_hub_config.py
@@ -303,13 +304,22 @@ scenarios:
- tests/agent_core/ai/test_hosted_transform.py::test_a_response_its_turn_still_waits_on_keeps_each_call_in_place_as_text
- tests/agent_core/ai/test_hosted_transform.py::test_every_hosted_call_is_one_result_that_shows_its_own_status
- tests/agent_core/ai/test_hosted_transform.py::test_the_posts_an_answer_cites_show_on_a_call_kept_in_place
- - tests/agent_core/agent/test_context.py::test_a_hosted_call_counts_as_the_call_and_result_it_is_replayed_as_never_as_its_opaque_payload
+ - tests/agent_core/agent/test_context.py::test_a_hosted_call_counts_as_the_largest_form_it_can_go_back_in
- id: MH-HOSTED-VIBEY-004
name: A proxied hosted call runs on the executor bound for the Turn; its record and execution stay on the tool result and the model reads the record as text, a call that reached no executor as a failure
status: covered
kind: contract
layer: contract
test: tests/test_vibey_agent.py::test_a_proxied_hosted_call_runs_on_the_bound_executor_and_keeps_its_record
+ - id: MH-HOSTED-VIBEY-005
+ name: A hosted call goes back verbatim and pinned only to the Source that served it, within its turn or with current replay evidence; pin_unavailable gets exactly one portable, unpinned resend
+ status: covered
+ kind: contract
+ layer: contract
+ test: tests/agent_core/ai/test_hosted_replay.py::test_pin_unavailable_gets_exactly_one_portable_resend_and_never_the_generic_retry
+ related_tests:
+ - tests/agent_core/ai/test_hosted_replay.py::test_a_hosted_call_goes_back_verbatim_and_pinned_only_to_its_own_source_with_replay_evidence
+ - tests/agent_core/ai/test_hosted_replay.py::test_a_continuation_goes_back_verbatim_only_to_the_hop_that_served_it
- id: MH-VIBEY-007
name: Vibey starts once with the user's Sources and built-in Agent models, seeded when its first Source exists
status: covered