Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions src/bub/builtin/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,6 @@ async def generator() -> AsyncIterator[StreamEvent]:

return AsyncStreamEvents(generator(), state=events._state)

async def run(
self,
*,
session_id: str,
prompt: str | list[dict],
state: State,
model: str | None = None,
allowed_skills: Collection[str] | None = None,
allowed_tools: Collection[str] | None = None,
) -> str:
output: list[str] = []
stream = await self.run_stream(
session_id=session_id,
prompt=prompt,
state=state,
model=model,
allowed_skills=allowed_skills,
allowed_tools=allowed_tools,
)
async for event in stream:
if event.kind == "text":
output.append(str(event.data.get("delta", "")))
return "".join(output)

async def run_stream(
self,
*,
Expand Down
4 changes: 0 additions & 4 deletions src/bub/builtin/hook_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ async def build_prompt(self, message: ChannelMessage, session_id: str, state: St
return [{"type": "text", "text": text}, *media_parts]
return text

@hookimpl
async def run_model(self, prompt: str | list[dict], session_id: str, state: State) -> str:
return await self._get_agent().run(session_id=session_id, prompt=prompt, state=state)

@hookimpl
async def run_model_stream(self, prompt: str | list[dict], session_id: str, state: State) -> AsyncStreamEvents:
return await self._get_agent().run_stream(session_id=session_id, prompt=prompt, state=state)
Expand Down
12 changes: 0 additions & 12 deletions tests/test_builtin_hook_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,6 @@ async def test_build_prompt_uses_system_timezone_for_context_date(
time.tzset()


@pytest.mark.asyncio
async def test_run_model_delegates_to_agent(tmp_path: Path) -> None:
_, impl, agent = _build_impl(tmp_path)
state = {"context": "ctx"}

result = await impl.run_model(prompt="prompt", session_id="session", state=state)

assert result == "agent-output"
assert agent.run_calls == [("session", "prompt", state)]
assert agent.run_stream_calls == []


@pytest.mark.asyncio
async def test_run_model_stream_delegates_to_agent(tmp_path: Path) -> None:
_, impl, agent = _build_impl(tmp_path)
Expand Down
Loading