fix: Respect use_system_prompt in Converter regeneration

Fixes #2571

Co-authored-by: Devin AI <devin-ai-integration[bot]@users.noreply.github.com>

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-04-10 15:49:25 +00:00
parent c9f47e6a37
commit 44abceffaa
49 changed files with 599 additions and 2464 deletions

View File

@@ -54,7 +54,7 @@ def test_agent_with_deterministic_fingerprint():
role="Researcher",
goal="Research quantum computing",
backstory="Expert in quantum physics",
security_config=security_config
security_config=security_config,
)
# Create another agent with the same security config
@@ -62,7 +62,7 @@ def test_agent_with_deterministic_fingerprint():
role="Completely different role",
goal="Different goal",
backstory="Different backstory",
security_config=security_config
security_config=security_config,
)
# Both agents should have the same fingerprint UUID
@@ -84,9 +84,7 @@ def test_task_with_deterministic_fingerprint():
# Create an agent first (required for tasks)
agent = Agent(
role="Assistant",
goal="Help with tasks",
backstory="Helpful AI assistant"
role="Assistant", goal="Help with tasks", backstory="Helpful AI assistant"
)
# Create a task with the deterministic fingerprint
@@ -94,7 +92,7 @@ def test_task_with_deterministic_fingerprint():
description="Analyze data",
expected_output="Data analysis report",
agent=agent,
security_config=security_config
security_config=security_config,
)
# Create another task with the same security config
@@ -102,7 +100,7 @@ def test_task_with_deterministic_fingerprint():
description="Different task description",
expected_output="Different expected output",
agent=agent,
security_config=security_config
security_config=security_config,
)
# Both tasks should have the same fingerprint UUID
@@ -119,36 +117,18 @@ def test_crew_with_deterministic_fingerprint():
# Create agents for the crew
agent1 = Agent(
role="Researcher",
goal="Research information",
backstory="Expert researcher"
role="Researcher", goal="Research information", backstory="Expert researcher"
)
agent2 = Agent(
role="Writer",
goal="Write reports",
backstory="Expert writer"
)
agent2 = Agent(role="Writer", goal="Write reports", backstory="Expert writer")
# Create a crew with the deterministic fingerprint
crew1 = Crew(
agents=[agent1, agent2],
tasks=[],
security_config=security_config
)
crew1 = Crew(agents=[agent1, agent2], tasks=[], security_config=security_config)
# Create another crew with the same security config but different agents
agent3 = Agent(
role="Analyst",
goal="Analyze data",
backstory="Expert analyst"
)
agent3 = Agent(role="Analyst", goal="Analyze data", backstory="Expert analyst")
crew2 = Crew(
agents=[agent3],
tasks=[],
security_config=security_config
)
crew2 = Crew(agents=[agent3], tasks=[], security_config=security_config)
# Both crews should have the same fingerprint UUID
assert crew1.fingerprint.uuid_str == crew2.fingerprint.uuid_str
@@ -168,7 +148,7 @@ def test_recreating_components_with_same_seed():
role="Researcher",
goal="Research topic",
backstory="Expert researcher",
security_config=security_config1
security_config=security_config1,
)
uuid_from_first_session = agent1.fingerprint.uuid_str
@@ -181,7 +161,7 @@ def test_recreating_components_with_same_seed():
role="Researcher",
goal="Research topic",
backstory="Expert researcher",
security_config=security_config2
security_config=security_config2,
)
# Should have same UUID across sessions
@@ -209,7 +189,7 @@ def test_security_config_with_seed_string():
role="Tester",
goal="Test fingerprints",
backstory="Expert tester",
security_config=security_config
security_config=security_config,
)
# Agent should have the same fingerprint UUID
@@ -236,7 +216,7 @@ def test_complex_component_hierarchy_with_deterministic_fingerprints():
role="Complex Test Agent",
goal="Test complex fingerprint scenarios",
backstory="Expert in testing",
security_config=agent_config
security_config=agent_config,
)
# Create a task
@@ -244,15 +224,11 @@ def test_complex_component_hierarchy_with_deterministic_fingerprints():
description="Test complex fingerprinting",
expected_output="Verification of fingerprint stability",
agent=agent,
security_config=task_config
security_config=task_config,
)
# Create a crew
crew = Crew(
agents=[agent],
tasks=[task],
security_config=crew_config
)
crew = Crew(agents=[agent], tasks=[task], security_config=crew_config)
# Each component should have its own deterministic fingerprint
assert agent.fingerprint.uuid_str == agent_fingerprint.uuid_str
@@ -271,4 +247,4 @@ def test_complex_component_hierarchy_with_deterministic_fingerprints():
assert agent_fingerprint.uuid_str == agent_fingerprint2.uuid_str
assert task_fingerprint.uuid_str == task_fingerprint2.uuid_str
assert crew_fingerprint.uuid_str == crew_fingerprint2.uuid_str
assert crew_fingerprint.uuid_str == crew_fingerprint2.uuid_str

View File

@@ -170,7 +170,7 @@ def test_fingerprint_from_dict():
fingerprint_dict = {
"uuid_str": uuid_str,
"created_at": created_at_iso,
"metadata": metadata
"metadata": metadata,
}
fingerprint = Fingerprint.from_dict(fingerprint_dict)
@@ -207,11 +207,7 @@ def test_invalid_uuid_str():
uuid_str = "not-a-valid-uuid"
created_at = datetime.now().isoformat()
fingerprint_dict = {
"uuid_str": uuid_str,
"created_at": created_at,
"metadata": {}
}
fingerprint_dict = {"uuid_str": uuid_str, "created_at": created_at, "metadata": {}}
# The Fingerprint.from_dict method accepts even invalid UUIDs
# This seems to be the current behavior
@@ -243,7 +239,7 @@ def test_fingerprint_metadata_mutation():
expected_metadata = {
"version": "1.0",
"status": "published",
"author": "Test Author"
"author": "Test Author",
}
assert fingerprint.metadata == expected_metadata
@@ -260,4 +256,4 @@ def test_fingerprint_metadata_mutation():
# Ensure immutable fields remain unchanged
assert fingerprint.uuid_str == uuid_str
assert fingerprint.created_at == created_at
assert fingerprint.created_at == created_at

View File

@@ -15,7 +15,7 @@ def test_agent_with_security_config():
role="Tester",
goal="Test fingerprinting",
backstory="Testing fingerprinting",
security_config=security_config
security_config=security_config,
)
assert agent.security_config is not None
@@ -28,9 +28,7 @@ def test_agent_fingerprint_property():
"""Test the fingerprint property on Agent."""
# Create agent without security_config
agent = Agent(
role="Tester",
goal="Test fingerprinting",
backstory="Testing fingerprinting"
role="Tester", goal="Test fingerprinting", backstory="Testing fingerprinting"
)
# Fingerprint should be automatically generated
@@ -45,21 +43,14 @@ def test_crew_with_security_config():
security_config = SecurityConfig()
agent1 = Agent(
role="Tester1",
goal="Test fingerprinting",
backstory="Testing fingerprinting"
role="Tester1", goal="Test fingerprinting", backstory="Testing fingerprinting"
)
agent2 = Agent(
role="Tester2",
goal="Test fingerprinting",
backstory="Testing fingerprinting"
role="Tester2", goal="Test fingerprinting", backstory="Testing fingerprinting"
)
crew = Crew(
agents=[agent1, agent2],
security_config=security_config
)
crew = Crew(agents=[agent1, agent2], security_config=security_config)
assert crew.security_config is not None
assert crew.security_config == security_config
@@ -71,15 +62,11 @@ def test_crew_fingerprint_property():
"""Test the fingerprint property on Crew."""
# Create crew without security_config
agent1 = Agent(
role="Tester1",
goal="Test fingerprinting",
backstory="Testing fingerprinting"
role="Tester1", goal="Test fingerprinting", backstory="Testing fingerprinting"
)
agent2 = Agent(
role="Tester2",
goal="Test fingerprinting",
backstory="Testing fingerprinting"
role="Tester2", goal="Test fingerprinting", backstory="Testing fingerprinting"
)
crew = Crew(agents=[agent1, agent2])
@@ -96,16 +83,14 @@ def test_task_with_security_config():
security_config = SecurityConfig()
agent = Agent(
role="Tester",
goal="Test fingerprinting",
backstory="Testing fingerprinting"
role="Tester", goal="Test fingerprinting", backstory="Testing fingerprinting"
)
task = Task(
description="Test task",
expected_output="Testing output",
agent=agent,
security_config=security_config
security_config=security_config,
)
assert task.security_config is not None
@@ -118,16 +103,10 @@ def test_task_fingerprint_property():
"""Test the fingerprint property on Task."""
# Create task without security_config
agent = Agent(
role="Tester",
goal="Test fingerprinting",
backstory="Testing fingerprinting"
role="Tester", goal="Test fingerprinting", backstory="Testing fingerprinting"
)
task = Task(
description="Test task",
expected_output="Testing output",
agent=agent
)
task = Task(description="Test task", expected_output="Testing output", agent=agent)
# Fingerprint should be automatically generated
assert task.fingerprint is not None
@@ -139,33 +118,20 @@ def test_end_to_end_fingerprinting():
"""Test end-to-end fingerprinting across Agent, Crew, and Task."""
# Create components with auto-generated fingerprints
agent1 = Agent(
role="Researcher",
goal="Research information",
backstory="Expert researcher"
role="Researcher", goal="Research information", backstory="Expert researcher"
)
agent2 = Agent(
role="Writer",
goal="Write content",
backstory="Expert writer"
)
agent2 = Agent(role="Writer", goal="Write content", backstory="Expert writer")
task1 = Task(
description="Research topic",
expected_output="Research findings",
agent=agent1
description="Research topic", expected_output="Research findings", agent=agent1
)
task2 = Task(
description="Write article",
expected_output="Written article",
agent=agent2
description="Write article", expected_output="Written article", agent=agent2
)
crew = Crew(
agents=[agent1, agent2],
tasks=[task1, task2]
)
crew = Crew(agents=[agent1, agent2], tasks=[task1, task2])
# Verify all fingerprints were automatically generated
assert agent1.fingerprint is not None
@@ -180,18 +146,18 @@ def test_end_to_end_fingerprinting():
agent2.fingerprint.uuid_str,
task1.fingerprint.uuid_str,
task2.fingerprint.uuid_str,
crew.fingerprint.uuid_str
crew.fingerprint.uuid_str,
]
assert len(fingerprints) == len(set(fingerprints)), "All fingerprints should be unique"
assert len(fingerprints) == len(
set(fingerprints)
), "All fingerprints should be unique"
def test_fingerprint_persistence():
"""Test that fingerprints persist and don't change."""
# Create an agent and check its fingerprint
agent = Agent(
role="Tester",
goal="Test fingerprinting",
backstory="Testing fingerprinting"
role="Tester", goal="Test fingerprinting", backstory="Testing fingerprinting"
)
# Get initial fingerprint
@@ -201,11 +167,7 @@ def test_fingerprint_persistence():
assert agent.fingerprint.uuid_str == initial_fingerprint
# Create a task with the agent
task = Task(
description="Test task",
expected_output="Testing output",
agent=agent
)
task = Task(description="Test task", expected_output="Testing output", agent=agent)
# Check that task has its own unique fingerprint
assert task.fingerprint is not None
@@ -223,27 +185,25 @@ def test_shared_security_config_fingerprints():
role="Researcher",
goal="Research information",
backstory="Expert researcher",
security_config=shared_security_config
security_config=shared_security_config,
)
agent2 = Agent(
role="Writer",
goal="Write content",
backstory="Expert writer",
security_config=shared_security_config
security_config=shared_security_config,
)
task = Task(
description="Write article",
expected_output="Written article",
agent=agent1,
security_config=shared_security_config
security_config=shared_security_config,
)
crew = Crew(
agents=[agent1, agent2],
tasks=[task],
security_config=shared_security_config
agents=[agent1, agent2], tasks=[task], security_config=shared_security_config
)
# Verify all components have the same fingerprint UUID
@@ -256,4 +216,4 @@ def test_shared_security_config_fingerprints():
assert agent1.fingerprint is shared_security_config.fingerprint
assert agent2.fingerprint is shared_security_config.fingerprint
assert task.fingerprint is shared_security_config.fingerprint
assert crew.fingerprint is shared_security_config.fingerprint
assert crew.fingerprint is shared_security_config.fingerprint

View File

@@ -63,13 +63,11 @@ def test_security_config_from_dict():
fingerprint_dict = {
"uuid_str": "b723c6ff-95de-5e87-860b-467b72282bd8",
"created_at": datetime.now().isoformat(),
"metadata": {"version": "1.0"}
"metadata": {"version": "1.0"},
}
# Create a config dict with just the fingerprint
config_dict = {
"fingerprint": fingerprint_dict
}
config_dict = {"fingerprint": fingerprint_dict}
# Create config manually since from_dict has a specific implementation
config = SecurityConfig()
@@ -115,4 +113,4 @@ def test_security_config_json_serialization():
new_config.fingerprint = new_fingerprint
# Check the new config has the same fingerprint metadata
assert new_config.fingerprint.metadata == {"version": "1.0"}
assert new_config.fingerprint.metadata == {"version": "1.0"}