mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-15 11:08:33 +00:00
give up on agent
This commit is contained in:
@@ -1797,46 +1797,3 @@ def test_litellm_anthropic_error_handling():
|
||||
|
||||
# Verify the LLM call was only made once (no retries)
|
||||
mock_llm_call.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||
def test_agent_streaming_with_tool_calling():
|
||||
"""Test that streaming works correctly with tool calling."""
|
||||
|
||||
# Define a tool that will be called
|
||||
@tool
|
||||
def retrieve_secret_information() -> str:
|
||||
"""Retrieve the super secret password from the secure database."""
|
||||
return "SuperSecretPassword123!"
|
||||
|
||||
# Create an LLM with streaming enabled
|
||||
llm = LLM(
|
||||
model="gpt-4o-mini",
|
||||
stream=True,
|
||||
)
|
||||
|
||||
# Create a secret agent
|
||||
secret_agent = Agent(
|
||||
role="Secret Information Specialist",
|
||||
goal="Retrieve classified information securely",
|
||||
backstory="A highly trained operative with clearance to access confidential data",
|
||||
tools=[retrieve_secret_information],
|
||||
llm=llm,
|
||||
max_iter=3, # Limit iterations to prevent infinite loops
|
||||
max_execution_time=60, # Add timeout of 60 seconds
|
||||
)
|
||||
|
||||
# Create a secret retrieval task
|
||||
secret_task = Task(
|
||||
description="Retrieve the super secret password using the appropriate tool",
|
||||
agent=secret_agent,
|
||||
expected_output="The retrieved super secret password",
|
||||
)
|
||||
|
||||
# Execute the task directly with the agent
|
||||
output = secret_agent.execute_task(task=secret_task)
|
||||
|
||||
# Verify the output contains the secret password
|
||||
assert (
|
||||
"SuperSecretPassword123!" in output
|
||||
), f"Expected secret password not found in output: {output}"
|
||||
|
||||
Reference in New Issue
Block a user