Skip to content

Commit 443101e

Browse files
authored
test: Increase robustness of PipelineTool integration tests (#9779)
* Add system prompt to encourage model to use the tool * Increase robustness
1 parent 0d09f7b commit 443101e

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

test/tools/test_pipeline_tool.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,16 @@ def test_live_pipeline_tool(self):
290290
)
291291

292292
# Create an Agent with the tool
293-
agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-4.1-mini"), tools=[retriever_tool])
293+
agent = Agent(
294+
chat_generator=OpenAIChatGenerator(model="gpt-4.1-mini"),
295+
system_prompt="For any questions about Nikola Tesla, always use the document_retriever.",
296+
tools=[retriever_tool],
297+
)
294298

295299
# Let the Agent handle a query
296300
result = agent.run([ChatMessage.from_user("Who was Nikola Tesla?")])
297301

298-
assert len(result["messages"]) == 4 # User message, Agent message, Tool call result, Agent message
302+
assert len(result["messages"]) == 5 # System msg, User msg, Agent msg, Tool call result, Agent mgs
299303
assert "nikola" in result["messages"][-1].text.lower()
300304

301305
@pytest.mark.asyncio
@@ -332,10 +336,14 @@ async def test_live_async_pipeline_tool(self):
332336
)
333337

334338
# Create an Agent with the tool
335-
agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-4.1-mini"), tools=[retriever_tool])
339+
agent = Agent(
340+
chat_generator=OpenAIChatGenerator(model="gpt-4.1-mini"),
341+
system_prompt="For any questions about Nikola Tesla, always use the document_retriever.",
342+
tools=[retriever_tool],
343+
)
336344

337345
# Let the Agent handle a query
338346
result = await agent.run_async([ChatMessage.from_user("Who was Nikola Tesla?")])
339347

340-
assert len(result["messages"]) == 4 # User message, Agent message, Tool call result, Agent message
348+
assert len(result["messages"]) == 5 # System msg, User msg, Agent msg, Tool call result, Agent mgs
341349
assert "nikola" in result["messages"][-1].text.lower()

0 commit comments

Comments
 (0)