Skip to content

Commit 1119dc9

Browse files
authored
Resolve warnings in test_middleware.py (#77)
1 parent 6204403 commit 1119dc9

1 file changed

Lines changed: 18 additions & 25 deletions

File tree

tests/integration/ai/test_middleware.py

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -305,29 +305,23 @@ async def test_agent_class_middleware_model_tool_subagent(self) -> None:
305305
class ExampleMiddleware(AgentMiddleware):
306306
@override
307307
async def model_middleware(
308-
self,
309-
request: ModelRequest,
310-
handler: ModelMiddlewareHandler,
308+
self, request: ModelRequest, handler: ModelMiddlewareHandler
311309
) -> AIMessage:
312310
nonlocal model_called
313311
model_called = True
314312
return await handler(request)
315313

316314
@override
317315
async def tool_middleware(
318-
self,
319-
request: ToolRequest,
320-
handler: ToolMiddlewareHandler,
316+
self, request: ToolRequest, handler: ToolMiddlewareHandler
321317
) -> ToolResponse:
322318
nonlocal tool_called
323319
tool_called = True
324320
return await handler(request)
325321

326322
@override
327323
async def subagent_middleware(
328-
self,
329-
request: SubagentRequest,
330-
handler: SubagentMiddlewareHandler,
324+
self, request: SubagentRequest, handler: SubagentMiddlewareHandler
331325
) -> SubagentResponse:
332326
nonlocal subagent_called
333327
subagent_called = True
@@ -337,7 +331,7 @@ async def subagent_middleware(
337331

338332
async with Agent(
339333
model=await self.model(),
340-
system_prompt="You are a helpful assistant",
334+
system_prompt="You are a helpful assistant.",
341335
service=self.service,
342336
middleware=[middleware],
343337
use_mcp_tools=True,
@@ -354,12 +348,12 @@ class NicknameGeneratorInput(BaseModel):
354348
Agent(
355349
model=await self.model(),
356350
system_prompt=(
357-
"You are a helpful assistant that generates nicknames."
358-
"If prompted for nickname you MUST append '-zilla' to provided name."
351+
"You are a helpful assistant that generates nicknames. A valid "
352+
+ "nickname consists of the provided name suffixed with '-zilla.'"
359353
),
360354
service=self.service,
361355
name="NicknameGeneratorAgent",
362-
description="Generates nicknames for people. Pass a name and get a nickname",
356+
description="Pass a name and get a nickname",
363357
input_schema=NicknameGeneratorInput,
364358
) as subagent,
365359
Agent(
@@ -410,13 +404,12 @@ async def test_middleware(
410404
Agent(
411405
model=await self.model(),
412406
system_prompt=(
413-
"You are a helpful assistant that generates nicknames"
414-
"If prompted for nickname you MUST append '-zilla' to provided name to create nickname."
415-
"Remember the dash and lowercase zilla. Example: Stefan -> Stefan-zilla"
407+
"You are a helpful assistant that generates nicknames. A valid "
408+
+ "nickname consists of the provided name suffixed with '-zilla.'"
416409
),
417410
service=self.service,
418411
name="NicknameGeneratorAgent",
419-
description="Generates nicknames for people. Pass a name and get a nickname",
412+
description="Pass a name and get a nickname",
420413
input_schema=NicknameGeneratorInput,
421414
) as subagent,
422415
Agent(
@@ -430,7 +423,7 @@ async def test_middleware(
430423
result = await supervisor.invoke(
431424
[
432425
HumanMessage(
433-
content="Hi, my name is Chris. Generate a nickname for me."
426+
content="hi, my name is Chris. Generate a nickname for me"
434427
)
435428
]
436429
)
@@ -469,12 +462,12 @@ async def test_middleware(
469462
Agent(
470463
model=await self.model(),
471464
system_prompt=(
472-
"You are a helpful assistant that generates nicknames"
473-
+ "If prompted for nickname you MUST append '-zilla' to provided name to create nickname."
465+
"You are a helpful assistant that generates nicknames. A valid "
466+
+ "nickname consists of the provided name suffixed with '-zilla.'"
474467
),
475468
service=self.service,
476469
name="NicknameGeneratorAgent",
477-
description="Generates nicknames for people. Pass a name and get a nickname",
470+
description="Pass a name and get a nickname",
478471
input_schema=NicknameGeneratorInput,
479472
) as subagent,
480473
Agent(
@@ -541,7 +534,7 @@ async def test_middleware(
541534
model=await self.model(),
542535
system_prompt=(
543536
"You are a helpful assistant. "
544-
"You MUST use available tools when asked about weather."
537+
+ "You MUST use available tools when asked about weather."
545538
),
546539
service=self.service,
547540
middleware=[test_middleware],
@@ -597,12 +590,12 @@ async def test_middleware(
597590
Agent(
598591
model=await self.model(),
599592
system_prompt=(
600-
"You are a helpful assistant that generates nicknames."
601-
"If prompted for nickname you MUST append '-zilla' to provided name."
593+
"You are a helpful assistant that generates nicknames. A valid "
594+
+ "nickname consists of the provided name suffixed with '-zilla.'"
602595
),
603596
service=self.service,
604597
name="NicknameGeneratorAgent",
605-
description="Generates nicknames for people. Pass a name and get a nickname",
598+
description="Pass a name and get a nickname",
606599
input_schema=NicknameGeneratorInput,
607600
) as subagent,
608601
Agent(

0 commit comments

Comments
 (0)