mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-06-13 14:23:58 +00:00
refactor(codex): name progress delta capability semantically
Use a provider capability name that describes user-visible progress delta support instead of the runner implementation detail. Made-with: Cursor
This commit is contained in:
parent
ae14142a87
commit
fdfecd3ba6
@ -612,7 +612,7 @@ class AgentRunner:
|
|||||||
wants_progress_streaming = (
|
wants_progress_streaming = (
|
||||||
not wants_streaming
|
not wants_streaming
|
||||||
and spec.progress_callback is not None
|
and spec.progress_callback is not None
|
||||||
and getattr(self.provider, "stream_progress_via_chat_stream", False) is True
|
and getattr(self.provider, "supports_progress_deltas", False) is True
|
||||||
)
|
)
|
||||||
|
|
||||||
if wants_streaming:
|
if wants_streaming:
|
||||||
|
|||||||
@ -91,7 +91,7 @@ _SYNTHETIC_USER_CONTENT = "(conversation continued)"
|
|||||||
class LLMProvider(ABC):
|
class LLMProvider(ABC):
|
||||||
"""Base class for LLM providers."""
|
"""Base class for LLM providers."""
|
||||||
|
|
||||||
stream_progress_via_chat_stream = False
|
supports_progress_deltas = False
|
||||||
|
|
||||||
_CHAT_RETRY_DELAYS = (1, 2, 4)
|
_CHAT_RETRY_DELAYS = (1, 2, 4)
|
||||||
_PERSISTENT_MAX_DELAY = 60
|
_PERSISTENT_MAX_DELAY = 60
|
||||||
|
|||||||
@ -26,7 +26,7 @@ DEFAULT_ORIGINATOR = "nanobot"
|
|||||||
class OpenAICodexProvider(LLMProvider):
|
class OpenAICodexProvider(LLMProvider):
|
||||||
"""Use Codex OAuth to call the Responses API."""
|
"""Use Codex OAuth to call the Responses API."""
|
||||||
|
|
||||||
stream_progress_via_chat_stream = True
|
supports_progress_deltas = True
|
||||||
|
|
||||||
def __init__(self, default_model: str = "openai-codex/gpt-5.1-codex"):
|
def __init__(self, default_model: str = "openai-codex/gpt-5.1-codex"):
|
||||||
super().__init__(api_key=None, api_base=None)
|
super().__init__(api_key=None, api_base=None)
|
||||||
|
|||||||
@ -137,7 +137,7 @@ class TestToolEventProgress:
|
|||||||
"""Providers that opt in can stream content deltas through _progress messages."""
|
"""Providers that opt in can stream content deltas through _progress messages."""
|
||||||
bus = MessageBus()
|
bus = MessageBus()
|
||||||
provider = MagicMock()
|
provider = MagicMock()
|
||||||
provider.stream_progress_via_chat_stream = True
|
provider.supports_progress_deltas = True
|
||||||
provider.get_default_model.return_value = "openai-codex/gpt-5.5"
|
provider.get_default_model.return_value = "openai-codex/gpt-5.5"
|
||||||
|
|
||||||
async def chat_stream_with_retry(*, on_content_delta, **kwargs):
|
async def chat_stream_with_retry(*, on_content_delta, **kwargs):
|
||||||
@ -175,7 +175,7 @@ class TestToolEventProgress:
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""If content was already streamed as progress, tool setup should not repeat it."""
|
"""If content was already streamed as progress, tool setup should not repeat it."""
|
||||||
loop = _make_loop(tmp_path)
|
loop = _make_loop(tmp_path)
|
||||||
loop.provider.stream_progress_via_chat_stream = True
|
loop.provider.supports_progress_deltas = True
|
||||||
tool_call = ToolCallRequest(id="call1", name="custom_tool", arguments={"path": "foo.txt"})
|
tool_call = ToolCallRequest(id="call1", name="custom_tool", arguments={"path": "foo.txt"})
|
||||||
calls = iter([
|
calls = iter([
|
||||||
LLMResponse(content="I will inspect it.", tool_calls=[tool_call]),
|
LLMResponse(content="I will inspect it.", tool_calls=[tool_call]),
|
||||||
|
|||||||
@ -43,7 +43,7 @@ def test_explicit_provider_import_still_works(monkeypatch) -> None:
|
|||||||
assert "nanobot.providers.anthropic_provider" in sys.modules
|
assert "nanobot.providers.anthropic_provider" in sys.modules
|
||||||
|
|
||||||
|
|
||||||
def test_openai_codex_opts_into_progress_streaming() -> None:
|
def test_openai_codex_supports_progress_deltas() -> None:
|
||||||
from nanobot.providers.openai_codex_provider import OpenAICodexProvider
|
from nanobot.providers.openai_codex_provider import OpenAICodexProvider
|
||||||
|
|
||||||
assert OpenAICodexProvider.stream_progress_via_chat_stream is True
|
assert OpenAICodexProvider.supports_progress_deltas is True
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user