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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(vibey): run proxied hosted calls concurrently (#3002)
Call White89ca37ca549b
diff --git a/docs/plans/vibey-hosted-tools.md b/docs/plans/vibey-hosted-tools.mdindex cf0facc00..80c0394aa 100644--- a/docs/plans/vibey-hosted-tools.md+++ b/docs/plans/vibey-hosted-tools.md@@ -378,6 +378,7 @@ failover, and is refused unpinned (C-6 item 7). What changes is what happens aftthe same-named function. It never declares a hosted image tool.- Nothing forces a tool: `ModelRequest.tool_choice` and `forced_tool` existed only for probes and go (§11).- Its four local tools are unchanged (C-7).+- Proxied search and fetch calls from one response run concurrently in the tool runtime; `image_generate` remains exclusive because it writes media.### 4.2 Parsing: the C-1 blocksdiff --git a/modules/agents/vibey/tools.py b/modules/agents/vibey/tools.pyindex 4167283ae..36d27b79b 100644--- a/modules/agents/vibey/tools.py+++ b/modules/agents/vibey/tools.py@@ -139,6 +139,10 @@ class HostedTool:text the model reads, with the same function that renders a replayed call."""+ # Proxied search and fetch calls are read-only and have per-call records, so+ # neighbouring calls from one response may share the loop's concurrent group.+ concurrent = True+spec: ToolSpec#: The hop the Turn runs on now: where the executor endpoint lives, and the token and headers that authorize the#: call. A re-resolve can move the Turn to another Source, and the gateway answers only the hop it now holds.diff --git a/tests/agent_core/agent/test_loop.py b/tests/agent_core/agent/test_loop.pyindex 039577a17..2690005d6 100644--- a/tests/agent_core/agent/test_loop.py+++ b/tests/agent_core/agent/test_loop.py@@ -38,6 +38,8 @@ from core.agent_core.agent.loop import Agentfrom core.agent_core.agent.models import RetryPolicyfrom core.agent_core.ai.provider import (Done,+ ImageModel,+ ImageModels,ModelCapabilities,ModelRequest,ProviderError,@@ -54,9 +56,11 @@ from core.agent_core.messages import (HostedImage,HostedNative,HostedRecord,+ HostedResult,HostedSource,HostedSummary,HostedToolBlock,+ ProxyExecution,ThinkingBlock,ToolCallBlock,ToolResultMessage,@@ -65,6 +69,8 @@ from core.agent_core.messages import (text,)from core.agent_core.tools.base import CallInstance, ToolResult+from core.agent_core.tools.hosted import hosted_tool_spec, image_generate_spec+from modules.agents.vibey.tools import HostedTool, ImageGenerateToolfrom tests.agent_core.fakes import (ORIGIN,FakeJobHost,@@ -1905,6 +1911,95 @@ async def committed_results(agent) -> list[tuple[str, str, bool]]:][email protected]("name", ["web_search", "x_search", "web_fetch"])+async def test_each_proxied_read_only_hosted_tool_is_concurrent(name):+ tool = HostedTool(hosted_tool_spec(name), lambda: ENDPOINT)++ assert tool.concurrent is True+++async def test_proxied_hosted_calls_run_concurrently_and_commit_in_call_order(monkeypatch):+ """A response's proxied hosted calls overlap, while durable results follow response call order."""+ gathering, finished = Gathering(3), []++ async def gateway_call(endpoint, client, tool, arguments):+ query = arguments["query"]+ await gathering.arrive(query)+ if query == "q1":+ while len(finished) < 2:+ await asyncio.sleep(0)+ finished.append(query)+ return HostedResult(+ HostedRecord(status="completed"),+ ProxyExecution(ORIGIN, "src_executor01", "metered"),+ ), None++ monkeypatch.setattr("modules.agents.vibey.tools._gateway_call", gateway_call)+ hosted = HostedTool(hosted_tool_spec("web_search"), lambda: ENDPOINT)+ agent = tool_agent(+ [+ ToolCallBlock("a", "web_search", {"query": "q1"}),+ ToolCallBlock("b", "web_search", {"query": "q2"}),+ ToolCallBlock("c", "web_search", {"query": "q3"}),+ ],+ [hosted],+ )++ await asyncio.wait_for(collect(agent), 5)++ assert finished[-1] == "q1"+ assert [row[0] for row in await committed_results(agent)] == ["a", "b", "c"]+++async def test_proxied_hosted_search_and_read_share_a_concurrent_group(monkeypatch):+ """A proxied hosted read-only call may overlap the ordinary concurrent ``read`` tool."""+ gathering = Gathering(2)++ async def gateway_call(endpoint, client, tool, arguments):+ await gathering.arrive("hosted")+ return HostedResult(+ HostedRecord(status="completed"),+ ProxyExecution(ORIGIN, "src_executor01", "metered"),+ ), None++ async def read(arguments, ctx):+ await gathering.arrive("read")+ return ToolResult((text("read done"),))++ monkeypatch.setattr("modules.agents.vibey.tools._gateway_call", gateway_call)+ hosted = HostedTool(hosted_tool_spec("web_search"), lambda: ENDPOINT)+ agent = tool_agent(+ [+ ToolCallBlock("hosted", "web_search", {"query": "q"}),+ ToolCallBlock("read", "read", {}),+ ],+ [hosted, ConcurrentTool("read", execute=read)],+ )++ events = await asyncio.wait_for(collect(agent), 5)++ assert tool_events(events)[:2] == [("started", "hosted"), ("started", "read")]+ assert [row[0] for row in await committed_results(agent)] == ["hosted", "read"]+++async def test_image_generate_stays_exclusive_next_to_concurrent_hosted_calls():+ models = ImageModels((ImageModel("src_image01", "gpt-image-2", "test", (), ()),))+ hosted = HostedTool(hosted_tool_spec("web_search"), lambda: ENDPOINT)+ image = ImageGenerateTool(image_generate_spec(models), models, lambda: ENDPOINT)++ groups = Agent._groups(+ [+ ToolCallBlock("before", "web_search", {"query": "q"}),+ ToolCallBlock("image", "image_generate", {"model": "gpt-image-2", "prompt": "p"}),+ ToolCallBlock("after", "web_search", {"query": "q2"}),+ ],+ {"web_search": hosted, "image_generate": image},+ )++ assert [[call.id for call in group] for group in groups] == [["before"], ["image"], ["after"]]+ assert getattr(image, "concurrent", False) is not True++async def test_neighbouring_concurrent_calls_start_together_and_commit_in_call_order():gathering, finished, others_finished = Gathering(3), [], asyncio.Event()