Skip to content

Commit cb42e92

Browse files
authored
fix: remove deprecated run method from Agent and its hook implementation (#237)
Signed-off-by: Frost Ming <me@frostming.com>
1 parent d8787c9 commit cb42e92

3 files changed

Lines changed: 0 additions & 40 deletions

File tree

src/bub/builtin/agent.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -93,30 +93,6 @@ async def generator() -> AsyncIterator[StreamEvent]:
9393

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

96-
async def run(
97-
self,
98-
*,
99-
session_id: str,
100-
prompt: str | list[dict],
101-
state: State,
102-
model: str | None = None,
103-
allowed_skills: Collection[str] | None = None,
104-
allowed_tools: Collection[str] | None = None,
105-
) -> str:
106-
output: list[str] = []
107-
stream = await self.run_stream(
108-
session_id=session_id,
109-
prompt=prompt,
110-
state=state,
111-
model=model,
112-
allowed_skills=allowed_skills,
113-
allowed_tools=allowed_tools,
114-
)
115-
async for event in stream:
116-
if event.kind == "text":
117-
output.append(str(event.data.get("delta", "")))
118-
return "".join(output)
119-
12096
async def run_stream(
12197
self,
12298
*,

src/bub/builtin/hook_impl.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ async def build_prompt(self, message: ChannelMessage, session_id: str, state: St
155155
return [{"type": "text", "text": text}, *media_parts]
156156
return text
157157

158-
@hookimpl
159-
async def run_model(self, prompt: str | list[dict], session_id: str, state: State) -> str:
160-
return await self._get_agent().run(session_id=session_id, prompt=prompt, state=state)
161-
162158
@hookimpl
163159
async def run_model_stream(self, prompt: str | list[dict], session_id: str, state: State) -> AsyncStreamEvents:
164160
return await self._get_agent().run_stream(session_id=session_id, prompt=prompt, state=state)

tests/test_builtin_hook_impl.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,6 @@ async def test_build_prompt_uses_system_timezone_for_context_date(
151151
time.tzset()
152152

153153

154-
@pytest.mark.asyncio
155-
async def test_run_model_delegates_to_agent(tmp_path: Path) -> None:
156-
_, impl, agent = _build_impl(tmp_path)
157-
state = {"context": "ctx"}
158-
159-
result = await impl.run_model(prompt="prompt", session_id="session", state=state)
160-
161-
assert result == "agent-output"
162-
assert agent.run_calls == [("session", "prompt", state)]
163-
assert agent.run_stream_calls == []
164-
165-
166154
@pytest.mark.asyncio
167155
async def test_run_model_stream_delegates_to_agent(tmp_path: Path) -> None:
168156
_, impl, agent = _build_impl(tmp_path)

0 commit comments

Comments
 (0)