Files
wehub-resource-sync 4b6817381b
Benchmark image — build + push to ECR (any adapter) / build + push (push) Waiting to run
CI / quality (ubuntu-latest) (push) Waiting to run
CI / test (tools-runtime) (push) Waiting to run
CI / test (e2e-general) (push) Waiting to run
CI / test (cli-runtime) (push) Waiting to run
CI / test (e2e-provider-and-openclaw) (push) Waiting to run
CI / test (integrations-and-misc) (push) Waiting to run
CI / coverage-report (push) Blocked by required conditions
CI / test-kubernetes (push) Waiting to run
CI / should-run-thorough (push) Waiting to run
CI / test-thorough (cloudwatch-demo) (push) Blocked by required conditions
CI / test-thorough (flink-ecs) (push) Blocked by required conditions
CI / test-thorough (upstream-lambda) (push) Blocked by required conditions
CI / test-thorough (prefect-ecs-fargate) (push) Blocked by required conditions
CodeQL / Analyze (python) (push) Waiting to run
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Blocked by required conditions
Release / publish-release (push) Blocked by required conditions
Release / publish-main-release (push) Blocked by required conditions
Release / prepare (push) Waiting to run
Release / verify (push) Blocked by required conditions
Release / build-python-dist (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Blocked by required conditions
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Waiting to run
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:10:45 +08:00

66 lines
2.3 KiB
Python

"""What the ReAct loop needs from whoever runs it.
The loop calls back out for a handful of things — emitting events, narrowing the
tool list, deciding when to stop, and the optional provider hooks. ``LoopHost``
is that set of callbacks as a ``Protocol``: ``run_react_loop`` depends only on it
(plus an ``AgentRunInput``), so it never has to know about ``Agent`` — any object
with these methods can drive the loop. ``Agent`` is the usual one.
"""
from __future__ import annotations
from typing import Any, Protocol
from core.events import RuntimeEvent
from core.execution import ToolExecutionHooks
from core.messages import ProviderMessage, RuntimeMessage
from core.provider import ProviderRequest
from core.types import RuntimeTool
class LoopHost[RuntimeToolT: RuntimeTool](Protocol):
"""The narrow set of hooks ``run_react_loop`` calls back into.
``core.agent.Agent`` implements this via ``EventEmitterMixin``,
``ToolFilterMixin``, ``SteeringMixin`` (``core.agent.mixins``), and its own
``_should_accept_conclusion`` override hook plus thin ``ProviderHookDelegate``
forwarders (``_transform_messages``/``_convert_to_llm``/``_before_request``/
``_after_response``). The provider-hook delegate's concrete type is
deliberately *not* part of this contract — only the method calls are —
so a host can wire the four seams however it likes.
"""
_tool_hooks: ToolExecutionHooks
def _filter_tools(self, tools: list[RuntimeToolT]) -> list[RuntimeToolT]:
pass
def _emit_runtime(self, event: RuntimeEvent) -> None:
pass
def _drain_steering_messages(self, messages: list[RuntimeMessage]) -> None:
pass
def _pop_follow_up_message(self) -> str | None:
pass
def _should_accept_conclusion(
self, *, evidence_count: int, iteration: int
) -> tuple[bool, str | None]:
pass
def _transform_messages(self, messages: list[RuntimeMessage]) -> list[RuntimeMessage]:
pass
def _convert_to_llm(self, llm: Any, messages: list[RuntimeMessage]) -> list[ProviderMessage]:
pass
def _before_request(self, request: ProviderRequest) -> ProviderRequest:
pass
def _after_response(self, request: ProviderRequest, response: Any) -> Any:
pass
__all__ = ["LoopHost"]