Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

improving guardrails

João Moura440883e9e8d4
diff --git a/src/crewai/task.py b/src/crewai/task.py
index d55373e28..78538ebee 100644
--- a/src/crewai/task.py
+++ b/src/crewai/task.py
@@ -41,6 +41,7 @@ from crewai.tools.base_tool import BaseTool
from crewai.utilities.config import process_config
from crewai.utilities.converter import Converter, convert_to_model
from crewai.utilities.i18n import I18N
+from crewai.utilities.printer import Printer
class Task(BaseModel):
@@ -394,6 +395,11 @@ class Task(BaseModel):
guardrail_result_error=guardrail_result.error,
task_output=task_output.raw
)
+ printer = Printer()
+ printer.print(
+ content=f"Guardrail blocked, retrying, due to:{guardrail_result.error}\n",
+ color="yellow",
+ )
return self._execute_core(agent, context, tools)
if guardrail_result.result is None:
diff --git a/tests/cassettes/test_crew_with_failing_task_guardrails.yaml b/tests/cassettes/test_crew_with_failing_task_guardrails.yaml
new file mode 100644
index 000000000..b99812237
--- /dev/null
+++ b/tests/cassettes/test_crew_with_failing_task_guardrails.yaml
@@ -0,0 +1,988 @@
+interactions:
+- request:
+ body: !!binary |
+ CpotCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkS8SwKEgoQY3Jld2FpLnRl
+ bGVtZXRyeRLrCQoQmqG4kmRspGSV9KSDE2WH2hIInKDQhtLNgqEqDENyZXcgQ3JlYXRlZDABOeCb
+ nCGokxcYQYDspiGokxcYShoKDmNyZXdhaV92ZXJzaW9uEggKBjAuOTUuMEoaCg5weXRob25fdmVy
+ c2lvbhIICgYzLjExLjdKLgoIY3Jld19rZXkSIgogY2FhMWFlYjNkZDQzNjM4NjU2OGE1YzNmZTIx
+ MDFhZjVKMQoHY3Jld19pZBImCiQxOWRmM2Y3MS1kYzk0LTQ0ZjYtYmY0Zi0zNjBjZjY2YjJiYWZK
+ HAoMY3Jld19wcm9jZXNzEgwKCnNlcXVlbnRpYWxKEQoL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2MC05NTczLTJlOWZjOWEzMDFhNUouCgh0YXNrX2tleRIiCiBiNzEz
+ YzgyZmViOTJjOWY1YzU4YjQwYTk3NTU2YjdhY0oxCgd0YXNrX2lkEiYKJGFmMWE5NjE4LTkyNGEt
+ NGU3OS1iNmViLTU4ZGExMzY5NTljNXoCGAGFAQABAAA=
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '5789'
+ Content-Type:
+ - application/x-protobuf
+ User-Agent:
+ - OTel-OTLP-Exporter-Python/1.27.0
+ method: POST
+ uri: https://telemetry.crewai.com:4319/v1/traces
+ response:
+ body:
+ string: "\n\0"
+ headers:
+ Content-Length:
+ - '2'
+ Content-Type:
+ - application/x-protobuf
+ Date:
+ - Sat, 04 Jan 2025 19:22:17 GMT
+ status:
+ code: 200
+ message: OK
+- request:
+ body: '{"messages": [{"role": "system", "content": "You are Report Writer. You''re
+ an expert at writing structured reports.\nYour personal goal is: Create properly
+ formatted reports\nTo give my best complete final answer to the task use the
+ exact following format:\n\nThought: I now can give a great answer\nFinal Answer:
+ Your final answer must be the great and the most complete as possible, it must
+ be outcome described.\n\nI MUST use these formats, my job depends on it!"},
+ {"role": "user", "content": "\nCurrent Task: Write a report about AI with exactly
+ 3 key points.\n\nThis is the expect criteria for your final answer: A properly
+ formatted report\nyou MUST return the actual complete content as the final answer,
+ not a summary.\n\nBegin! This is VERY important to you, use the tools available
+ and give your best Final Answer, your job depends on it!\n\nThought:"}], "model":
+ "gpt-4o-mini", "stop": ["\nObservation:"], "stream": false}'
+ headers:
+ accept:
+ - application/json
+ accept-encoding:
+ - gzip, deflate
+ connection:
+ - keep-alive
+ content-length:
+ - '934'
+ content-type:
+ - application/json
+ cookie:
+ - _cfuvid=v_wJZ5m7qCjrnRfks0gT2GAk9yR14BdIDAQiQR7xxI8-1735266215000-0.0.1.1-604800000
+ host:
+ - api.openai.com
+ user-agent:
+ - OpenAI/Python 1.52.1
+ x-stainless-arch:
+ - arm64
+ x-stainless-async:
+ - 'false'
+ x-stainless-lang:
+ - python
+ x-stainless-os:
+ - MacOS
+ x-stainless-package-version:
+ - 1.52.1
+ x-stainless-raw-response:
+ - 'true'
+ x-stainless-retry-count:
+ - '0'
+ x-stainless-runtime:
+ - CPython
+ x-stainless-runtime-version:
+ - 3.11.7
+ method: POST
+ uri: https://api.openai.com/v1/chat/completions
+ response:
+ content: "{\n \"id\": \"chatcmpl-Am40qBAFJtuaFsOlTsBHFCoYUvLhN\",\n \"object\":
+ \"chat.completion\",\n \"created\": 1736018532,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
+ \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
+ \"assistant\",\n \"content\": \"I now can give a great answer. \\nFinal
+ Answer: \\n\\n# Report on Artificial Intelligence (AI)\\n\\n## Introduction\\nArtificial
+ Intelligence (AI) is a rapidly evolving technology that simulates human intelligence
+ processes by machines, particularly computer systems. AI has a profound impact
+ on various sectors, enhancing efficiency, improving decision-making, and leading
+ to groundbreaking innovations. This report highlights three key points regarding
+ the significance and implications of AI technology.\\n\\n## Key Point 1: Transformative
+ Potential in Various Industries\\nAI's transformative potential is evident across
+ multiple industries, including healthcare, finance, transportation, and agriculture.
+ In healthcare, AI algorithms can analyze complex medical data, leading to improved
+ diagnostics, personalized medicine, and predictive analytics, thereby enhancing
+ patient outcomes. The financial sector employs AI for risk management, fraud
+ detection, and automated trading, which increases operational efficiency and
+ minimizes human error. In transportation, AI is integral to the development
+ of autonomous vehicles and smart traffic systems, optimizing routes and reducing
+ congestion. Furthermore, agriculture benefits from AI applications through precision
+ farming, which maximizes yield while minimizing environmental impact.\\n\\n##
+ Key Point 2: Ethical Considerations and Challenges\\nAs AI technologies become
+ more pervasive, ethical considerations arise regarding their implementation
+ and use. Concerns include data privacy, algorithmic bias, and the displacement
+ of jobs due to automation. Ensuring that AI systems are transparent, fair, and
+ accountable is crucial in addressing these issues. Organizations must develop
+ comprehensive guidelines and regulatory frameworks to mitigate bias in AI algorithms
+ and protect user data. Moreover, addressing the social implications of AI, such
+ as potential job displacement, is essential, necessitating investment in workforce
+ retraining and education to prepare for an AI-driven economy.\\n\\n## Key Point
+ 3: Future Directions and Developments\\nLooking ahead, the future of AI promises
+ continued advancements and integration into everyday life. Emerging trends include
+ the development of explainable AI (XAI), enhancing interpretability and understanding
+ of AI decision-making processes. Advances in natural language processing (NLP)
+ will facilitate better human-computer interactions, allowing for more intuitive
+ applications. Additionally, as AI technology becomes increasingly sophisticated,
+ its role in addressing global challenges, such as climate change and healthcare
+ disparities, is expected to expand. Stakeholders must collaborate to ensure
+ that these developments align with ethical standards and societal needs, fostering
+ a responsible AI future.\\n\\n## Conclusion\\nArtificial Intelligence stands
+ at the forefront of technological innovation, with the potential to revolutionize
+ industries and address complex global challenges. However, it is imperative
+ to navigate the ethical considerations and challenges it poses. By fostering
+ responsible AI development, we can harness its transformative power while ensuring
+ equitability and transparency for future generations.\",\n \"refusal\":
+ null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n
+ \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 170,\n \"completion_tokens\":
+ 524,\n \"total_tokens\": 694,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
+ 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\": {\n
+ \ \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
+ 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"system_fingerprint\":
+ \"fp_0aa8d3e20b\"\n}\n"
+ headers:
+ CF-Cache-Status:
+ - DYNAMIC
+ CF-RAY:
+ - 8fcd9890790e0133-GRU
+ Connection:
+ - keep-alive
+ Content-Encoding:
+ - gzip
+ Content-Type:
+ - application/json
+ Date:
+ - Sat, 04 Jan 2025 19:22:19 GMT
+ Server:
+ - cloudflare
+ Set-Cookie:
+ - __cf_bm=pumYGlf1gsbVoFNTM1vh9Okj41SgxP3y65T5YWWPU1U-1736018539-1.0.1.1-wmaotkWMviN4lKh6M3P04A8p61Ehm.rTehDpsJhxYhNBNU5.kznMCa3cNXePaEbsKkk4PU2QcWjHj2C7yDrjkw;
+ path=/; expires=Sat, 04-Jan-25 19:52:19 GMT; domain=.api.openai.com; HttpOnly;
+ Secure; SameSite=None
+ - _cfuvid=SlnUP7AT9jJlQiN.Fm1c7MDyo78_hBRAz8PoabvHVSU-1736018539826-0.0.1.1-604800000;
+ path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ access-control-expose-headers:
+ - X-Request-ID
+ alt-svc:
+ - h3=":443"; ma=86400
+ openai-organization:
+ - crewai-iuxna1
+ openai-processing-ms:
+ - '7717'
+ openai-version:
+ - '2020-10-01'
+ strict-transport-security:
+ - max-age=31536000; includeSubDomains; preload
+ x-ratelimit-limit-requests:
+ - '30000'
+ x-ratelimit-limit-tokens:
+ - '150000000'
+ x-ratelimit-remaining-requests:
+ - '29999'
+ x-ratelimit-remaining-tokens:
+ - '149999790'
+ x-ratelimit-reset-requests:
+ - 2ms
+ x-ratelimit-reset-tokens:
+ - 0s
+ x-request-id:
+ - req_08d237d56b0168a0f4512417380485db
+ http_version: HTTP/1.1
+ status_code: 200
+- request:
+ body: !!binary |
+ Cs4CCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkSpQIKEgoQY3Jld2FpLnRl
+ bGVtZXRyeRKOAgoQw9qUJPsh6jiJZX4qW3ry4hIIT7E0SNH7Ub4qDFRhc2sgQ3JlYXRlZDABOQBO
+ BAmqkxcYQQgdBQmqkxcYSi4KCGNyZXdfa2V5EiIKIDAwYjk0NmJlNDQzNzE0YjNhNDdjMjAxMDFl
+ YjAyZDY2SjEKB2NyZXdfaWQSJgokNzJkZTEwZTQtNDkwZC00NDYwLTk1NzMtMmU5ZmM5YTMwMWE1
+ Si4KCHRhc2tfa2V5EiIKIGI3MTNjODJmZWI5MmM5ZjVjNThiNDBhOTc1NTZiN2FjSjEKB3Rhc2tf
+ aWQSJgokYWYxYTk2MTgtOTI0YS00ZTc5LWI2ZWItNThkYTEzNjk1OWM1egIYAYUBAAEAAA==
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '337'
+ Content-Type:
+ - application/x-protobuf
+ User-Agent:
+ - OTel-OTLP-Exporter-Python/1.27.0
+ method: POST
+ uri: https://telemetry.crewai.com:4319/v1/traces
+ response:
+ body:
+ string: "\n\0"
+ headers:
+ Content-Length:
+ - '2'
+ Content-Type:
+ - application/x-protobuf
+ Date:
+ - Sat, 04 Jan 2025 19:22:22 GMT
+ status:
+ code: 200
+ message: OK
+- request:
+ body: '{"messages": [{"role": "system", "content": "You are Report Writer. You''re
+ an expert at writing structured reports.\nYour personal goal is: Create properly
+ formatted reports\nTo give my best complete final answer to the task use the
+ exact following format:\n\nThought: I now can give a great answer\nFinal Answer:
+ Your final answer must be the great and the most complete as possible, it must
+ be outcome described.\n\nI MUST use these formats, my job depends on it!"},
+ {"role": "user", "content": "\nCurrent Task: Write a report about AI with exactly
+ 3 key points.\n\nThis is the expect criteria for your final answer: A properly
+ formatted report\nyou MUST return the actual complete content as the final answer,
+ not a summary.\n\nThis is the context you''re working with:\n### Previous attempt
+ failed validation: Output must start with ''REPORT:'' no formatting, just the
+ word REPORT\n\n\n### Previous result:\n# Report on Artificial Intelligence (AI)\n\n##
+ Introduction\nArtificial Intelligence (AI) is a rapidly evolving technology
+ that simulates human intelligence processes by machines, particularly computer
+ systems. AI has a profound impact on various sectors, enhancing efficiency,
+ improving decision-making, and leading to groundbreaking innovations. This report
+ highlights three key points regarding the significance and implications of AI
+ technology.\n\n## Key Point 1: Transformative Potential in Various Industries\nAI''s
+ transformative potential is evident across multiple industries, including healthcare,
+ finance, transportation, and agriculture. In healthcare, AI algorithms can analyze
+ complex medical data, leading to improved diagnostics, personalized medicine,
+ and predictive analytics, thereby enhancing patient outcomes. The financial
+ sector employs AI for risk management, fraud detection, and automated trading,
+ which increases operational efficiency and minimizes human error. In transportation,
+ AI is integral to the development of autonomous vehicles and smart traffic systems,
+ optimizing routes and reducing congestion. Furthermore, agriculture benefits
+ from AI applications through precision farming, which maximizes yield while
+ minimizing environmental impact.\n\n## Key Point 2: Ethical Considerations and
+ Challenges\nAs AI technologies become more pervasive, ethical considerations
+ arise regarding their implementation and use. Concerns include data privacy,
+ algorithmic bias, and the displacement of jobs due to automation. Ensuring that
+ AI systems are transparent, fair, and accountable is crucial in addressing these
+ issues. Organizations must develop comprehensive guidelines and regulatory frameworks
+ to mitigate bias in AI algorithms and protect user data. Moreover, addressing
+ the social implications of AI, such as potential job displacement, is essential,
+ necessitating investment in workforce retraining and education to prepare for
+ an AI-driven economy.\n\n## Key Point 3: Future Directions and Developments\nLooking
+ ahead, the future of AI promises continued advancements and integration into
+ everyday life. Emerging trends include the development of explainable AI (XAI),
+ enhancing interpretability and understanding of AI decision-making processes.
+ Advances in natural language processing (NLP) will facilitate better human-computer
+ interactions, allowing for more intuitive applications. Additionally, as AI
+ technology becomes increasingly sophisticated, its role in addressing global
+ challenges, such as climate change and healthcare disparities, is expected to
+ expand. Stakeholders must collaborate to ensure that these developments align
+ with ethical standards and societal needs, fostering a responsible AI future.\n\n##
+ Conclusion\nArtificial Intelligence stands at the forefront of technological
+ innovation, with the potential to revolutionize industries and address complex
+ global challenges. However, it is imperative to navigate the ethical considerations
+ and challenges it poses. By fostering responsible AI development, we can harness
+ its transformative power while ensuring equitability and transparency for future
+ generations.\n\n\nTry again, making sure to address the validation error.\n\nBegin!
+ This is VERY important to you, use the tools available and give your best Final
+ Answer, your job depends on it!\n\nThought:"}], "model": "gpt-4o-mini", "stop":
+ ["\nObservation:"], "stream": false}'
+ headers:
+ accept:
+ - application/json
+ accept-encoding:
+ - gzip, deflate
+ connection:
+ - keep-alive
+ content-length:
+ - '4351'
+ content-type:
+ - application/json
+ cookie:
+ - _cfuvid=SlnUP7AT9jJlQiN.Fm1c7MDyo78_hBRAz8PoabvHVSU-1736018539826-0.0.1.1-604800000;
+ __cf_bm=pumYGlf1gsbVoFNTM1vh9Okj41SgxP3y65T5YWWPU1U-1736018539-1.0.1.1-wmaotkWMviN4lKh6M3P04A8p61Ehm.rTehDpsJhxYhNBNU5.kznMCa3cNXePaEbsKkk4PU2QcWjHj2C7yDrjkw
+ host:
+ - api.openai.com
+ user-agent:
+ - OpenAI/Python 1.52.1
+ x-stainless-arch:
+ - arm64
+ x-stainless-async:
+ - 'false'
+ x-stainless-lang:
+ - python
+ x-stainless-os:
+ - MacOS
+ x-stainless-package-version:
+ - 1.52.1
+ x-stainless-raw-response:
+ - 'true'
+ x-stainless-retry-count:
+ - '0'
+ x-stainless-runtime:
+ - CPython
+ x-stainless-runtime-version:
+ - 3.11.7
+ method: POST
+ uri: https://api.openai.com/v1/chat/completions
+ response:
+ content: "{\n \"id\": \"chatcmpl-Am40yJsMPHsTOmn9Obwyx2caqoJ1R\",\n \"object\":
+ \"chat.completion\",\n \"created\": 1736018540,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
+ \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
+ \"assistant\",\n \"content\": \"I now can give a great answer \\nFinal
+ Answer: \\nREPORT: \\n\\n# Report on Artificial Intelligence (AI)\\n\\n##
+ Introduction\\nArtificial Intelligence (AI) is a rapidly evolving technology
+ that simulates human intelligence processes by machines, particularly computer
+ systems. AI has a profound impact on various sectors, enhancing efficiency,
+ improving decision-making, and leading to groundbreaking innovations. This report
+ highlights three key points regarding the significance and implications of AI
+ technology.\\n\\n## Key Point 1: Transformative Potential in Various Industries\\nAI's
+ transformative potential is evident across multiple industries, including healthcare,
+ finance, transportation, and agriculture. In healthcare, AI algorithms can analyze
+ complex medical data, leading to improved diagnostics, personalized medicine,
+ and predictive analytics, thereby enhancing patient outcomes. The financial
+ sector employs AI for risk management, fraud detection, and automated trading,
+ which increases operational efficiency and minimizes human error. In transportation,
+ AI is integral to the development of autonomous vehicles and smart traffic systems,
+ optimizing routes and reducing congestion. Furthermore, agriculture benefits
+ from AI applications through precision farming, which maximizes yield while
+ minimizing environmental impact.\\n\\n## Key Point 2: Ethical Considerations
+ and Challenges\\nAs AI technologies become more pervasive, ethical considerations
+ arise regarding their implementation and use. Concerns include data privacy,
+ algorithmic bias, and the displacement of jobs due to automation. Ensuring that
+ AI systems are transparent, fair, and accountable is crucial in addressing these
+ issues. Organizations must develop comprehensive guidelines and regulatory frameworks
+ to mitigate bias in AI algorithms and protect user data. Moreover, addressing
+ the social implications of AI, such as potential job displacement, is essential,
+ necessitating investment in workforce retraining and education to prepare for
+ an AI-driven economy.\\n\\n## Key Point 3: Future Directions and Developments\\nLooking
+ ahead, the future of AI promises continued advancements and integration into
+ everyday life. Emerging trends include the development of explainable AI (XAI),
+ enhancing interpretability and understanding of AI decision-making processes.
+ Advances in natural language processing (NLP) will facilitate better human-computer
+ interactions, allowing for more intuitive applications. Additionally, as AI
+ technology becomes increasingly sophisticated, its role in addressing global
+ challenges, such as climate change and healthcare disparities, is expected to
+ expand. Stakeholders must collaborate to ensure that these developments align
+ with ethical standards and societal needs, fostering a responsible AI future.\\n\\n##
+ Conclusion\\nArtificial Intelligence stands at the forefront of technological
+ innovation, with the potential to revolutionize industries and address complex
+ global challenges. However, it is imperative to navigate the ethical considerations
+ and challenges it poses. By fostering responsible AI development, we can harness
+ its transformative power while ensuring equitability and transparency for future
+ generations.\",\n \"refusal\": null\n },\n \"logprobs\": null,\n
+ \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
+ 725,\n \"completion_tokens\": 526,\n \"total_tokens\": 1251,\n \"prompt_tokens_details\":
+ {\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
+ {\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
+ 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"system_fingerprint\":
+ \"fp_0aa8d3e20b\"\n}\n"
+ headers:
+ CF-Cache-Status:
+ - DYNAMIC
+ CF-RAY:
+ - 8fcd98c269880133-GRU
+ Connection:
+ - keep-alive
+ Content-Encoding:
+ - gzip
+ Content-Type:
+ - application/json
+ Date:
+ - Sat, 04 Jan 2025 19:22:28 GMT
+ Server:
+ - cloudflare
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ access-control-expose-headers:
+ - X-Request-ID
+ alt-svc:
+ - h3=":443"; ma=86400
+ openai-organization:
+ - crewai-iuxna1
+ openai-processing-ms:
+ - '8620'
+ openai-version:
+ - '2020-10-01'
+ strict-transport-security:
+ - max-age=31536000; includeSubDomains; preload
+ x-ratelimit-limit-requests:
+ - '30000'
+ x-ratelimit-limit-tokens:
+ - '150000000'
+ x-ratelimit-remaining-requests:
+ - '29999'
+ x-ratelimit-remaining-tokens:
+ - '149998942'
+ x-ratelimit-reset-requests:
+ - 2ms
+ x-ratelimit-reset-tokens:
+ - 0s
+ x-request-id:
+ - req_de480c9e17954e77dece1b2fe013a0d0
+ http_version: HTTP/1.1
+ status_code: 200
+- request:
+ body: !!binary |
+ Cs4CCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkSpQIKEgoQY3Jld2FpLnRl
+ bGVtZXRyeRKOAgoQCwIBgw9XNdGpuGOOIANe2hIIriM3k2t+0NQqDFRhc2sgQ3JlYXRlZDABOcjF
+ ABuskxcYQfBlARuskxcYSi4KCGNyZXdfa2V5EiIKIDAwYjk0NmJlNDQzNzE0YjNhNDdjMjAxMDFl
+ YjAyZDY2SjEKB2NyZXdfaWQSJgokNzJkZTEwZTQtNDkwZC00NDYwLTk1NzMtMmU5ZmM5YTMwMWE1
+ Si4KCHRhc2tfa2V5EiIKIGI3MTNjODJmZWI5MmM5ZjVjNThiNDBhOTc1NTZiN2FjSjEKB3Rhc2tf
+ aWQSJgokYWYxYTk2MTgtOTI0YS00ZTc5LWI2ZWItNThkYTEzNjk1OWM1egIYAYUBAAEAAA==
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '337'
+ Content-Type:
+ - application/x-protobuf
+ User-Agent:
+ - OTel-OTLP-Exporter-Python/1.27.0
+ method: POST
+ uri: https://telemetry.crewai.com:4319/v1/traces
+ response:
+ body:
+ string: "\n\0"
+ headers:
+ Content-Length:
+ - '2'
+ Content-Type:
+ - application/x-protobuf
+ Date:
+ - Sat, 04 Jan 2025 19:22:32 GMT
+ status:
+ code: 200
+ message: OK
+- request:
+ body: '{"messages": [{"role": "system", "content": "You are Report Writer. You''re
+ an expert at writing structured reports.\nYour personal goal is: Create properly
+ formatted reports\nTo give my best complete final answer to the task use the
+ exact following format:\n\nThought: I now can give a great answer\nFinal Answer:
+ Your final answer must be the great and the most complete as possible, it must
+ be outcome described.\n\nI MUST use these formats, my job depends on it!"},
+ {"role": "user", "content": "\nCurrent Task: Write a report about AI with exactly
+ 3 key points.\n\nThis is the expect criteria for your final answer: A properly
+ formatted report\nyou MUST return the actual complete content as the final answer,
+ not a summary.\n\nThis is the context you''re working with:\n### Previous attempt
+ failed validation: Output must end with ''END REPORT'' no formatting, just the
+ word END REPORT\n\n\n### Previous result:\nREPORT: \n\n# Report on Artificial
+ Intelligence (AI)\n\n## Introduction\nArtificial Intelligence (AI) is a rapidly
+ evolving technology that simulates human intelligence processes by machines,
+ particularly computer systems. AI has a profound impact on various sectors,
+ enhancing efficiency, improving decision-making, and leading to groundbreaking
+ innovations. This report highlights three key points regarding the significance
+ and implications of AI technology.\n\n## Key Point 1: Transformative Potential
+ in Various Industries\nAI''s transformative potential is evident across multiple
+ industries, including healthcare, finance, transportation, and agriculture.
+ In healthcare, AI algorithms can analyze complex medical data, leading to improved
+ diagnostics, personalized medicine, and predictive analytics, thereby enhancing
+ patient outcomes. The financial sector employs AI for risk management, fraud
+ detection, and automated trading, which increases operational efficiency and
+ minimizes human error. In transportation, AI is integral to the development
+ of autonomous vehicles and smart traffic systems, optimizing routes and reducing
+ congestion. Furthermore, agriculture benefits from AI applications through precision
+ farming, which maximizes yield while minimizing environmental impact.\n\n##
+ Key Point 2: Ethical Considerations and Challenges\nAs AI technologies become
+ more pervasive, ethical considerations arise regarding their implementation
+ and use. Concerns include data privacy, algorithmic bias, and the displacement
+ of jobs due to automation. Ensuring that AI systems are transparent, fair, and
+ accountable is crucial in addressing these issues. Organizations must develop
+ comprehensive guidelines and regulatory frameworks to mitigate bias in AI algorithms
+ and protect user data. Moreover, addressing the social implications of AI, such
+ as potential job displacement, is essential, necessitating investment in workforce
+ retraining and education to prepare for an AI-driven economy.\n\n## Key Point
+ 3: Future Directions and Developments\nLooking ahead, the future of AI promises
+ continued advancements and integration into everyday life. Emerging trends include
+ the development of explainable AI (XAI), enhancing interpretability and understanding
+ of AI decision-making processes. Advances in natural language processing (NLP)
+ will facilitate better human-computer interactions, allowing for more intuitive
+ applications. Additionally, as AI technology becomes increasingly sophisticated,
+ its role in addressing global challenges, such as climate change and healthcare
+ disparities, is expected to expand. Stakeholders must collaborate to ensure
+ that these developments align with ethical standards and societal needs, fostering
+ a responsible AI future.\n\n## Conclusion\nArtificial Intelligence stands at
+ the forefront of technological innovation, with the potential to revolutionize
+ industries and address complex global challenges. However, it is imperative
+ to navigate the ethical considerations and challenges it poses. By fostering
+ responsible AI development, we can harness its transformative power while ensuring
+ equitability and transparency for future generations.\n\n\nTry again, making
+ sure to address the validation error.\n\nBegin! This is VERY important to you,
+ use the tools available and give your best Final Answer, your job depends on
+ it!\n\nThought:"}], "model": "gpt-4o-mini", "stop": ["\nObservation:"], "stream":
+ false}'
+ headers:
+ accept:
+ - application/json
+ accept-encoding:
+ - gzip, deflate
+ connection:
+ - keep-alive
+ content-length:
+ - '4369'
+ content-type:
+ - application/json
+ cookie:
+ - _cfuvid=SlnUP7AT9jJlQiN.Fm1c7MDyo78_hBRAz8PoabvHVSU-1736018539826-0.0.1.1-604800000;
+ __cf_bm=pumYGlf1gsbVoFNTM1vh9Okj41SgxP3y65T5YWWPU1U-1736018539-1.0.1.1-wmaotkWMviN4lKh6M3P04A8p61Ehm.rTehDpsJhxYhNBNU5.kznMCa3cNXePaEbsKkk4PU2QcWjHj2C7yDrjkw
+ host:
+ - api.openai.com
+ user-agent:
+ - OpenAI/Python 1.52.1
+ x-stainless-arch:
+ - arm64
+ x-stainless-async:
+ - 'false'
+ x-stainless-lang:
+ - python
+ x-stainless-os:
+ - MacOS
+ x-stainless-package-version:
+ - 1.52.1
+ x-stainless-raw-response:
+ - 'true'
+ x-stainless-retry-count:
+ - '0'
+ x-stainless-runtime:
+ - CPython
+ x-stainless-runtime-version:
+ - 3.11.7
+ method: POST
+ uri: https://api.openai.com/v1/chat/completions
+ response:
+ content: "{\n \"id\": \"chatcmpl-Am4176wzYnk3HmSTkkakM4yl6xVYS\",\n \"object\":
+ \"chat.completion\",\n \"created\": 1736018549,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
+ \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
+ \"assistant\",\n \"content\": \"I now can give a great answer \\nFinal
+ Answer: \\n\\n# Report on Artificial Intelligence (AI)\\n\\n## Introduction\\nArtificial
+ Intelligence (AI) is a revolutionary technology designed to simulate human intelligence
+ processes, enabling machines to perform tasks that typically require human cognition.
+ Its rapid development has brought forth significant changes across various sectors,
+ improving operational efficiencies, enhancing decision-making, and fostering
+ innovation. This report outlines three key points regarding the impact and implications
+ of AI technology.\\n\\n## Key Point 1: Transformative Potential in Various Industries\\nAI's
+ transformative potential is observable across numerous sectors including healthcare,
+ finance, transportation, and agriculture. In the healthcare sector, AI algorithms
+ are increasingly used to analyze vast amounts of medical data, which sharpens
+ diagnostics, facilitates personalized treatment plans, and enhances predictive
+ analytics, thus leading to better patient care. In finance, AI contributes to
+ risk assessment, fraud detection, and automated trading, heightening efficiency
+ and reducing the risk of human error. The transportation industry leverages
+ AI technologies for developments in autonomous vehicles and smart transportation
+ systems that optimize routes and alleviate traffic congestion. Furthermore,
+ agriculture benefits from AI by applying precision farming techniques that optimize
+ yield and mitigate environmental effects.\\n\\n## Key Point 2: Ethical Considerations
+ and Challenges\\nWith the increasing deployment of AI technologies, numerous
+ ethical considerations surface, particularly relating to privacy, algorithmic
+ fairness, and the displacement of jobs. Addressing issues such as data security,
+ bias in AI algorithms, and the societal impact of automation is paramount. Organizations
+ are encouraged to develop stringent guidelines and regulatory measures aimed
+ at minimizing bias and ensuring that AI systems uphold values of transparency
+ and accountability. Additionally, the implications of job displacement necessitate
+ strategies for workforce retraining and educational reforms to adequately prepare
+ the workforce for an economy increasingly shaped by AI technologies.\\n\\n##
+ Key Point 3: Future Directions and Developments\\nThe future of AI is poised
+ for remarkable advancements, with trends indicating a growing integration into
+ daily life and widespread applications. The emergence of explainable AI (XAI)
+ aims to enhance the transparency and interpretability of AI decision-making
+ processes, fostering trust and understanding among users. Improvements in natural
+ language processing (NLP) are likely to lead to more seamless and intuitive
+ human-computer interactions. Furthermore, AI's potential to address global challenges,
+ including climate change and disparities in healthcare access, is becoming increasingly
+ significant. Collaborative efforts among stakeholders will be vital to ensuring
+ that AI advancements are ethical and responsive to societal needs, paving the
+ way for a responsible and equitable AI landscape.\\n\\n## Conclusion\\nAI technology
+ is at the forefront of innovation, with the capacity to transform industries
+ and tackle pressing global issues. As we navigate through the complexities and
+ ethical challenges posed by AI, it is crucial to prioritize responsible development
+ and implementation. By harnessing AI's transformative capabilities with a focus
+ on equity and transparency, we can pave the way for a promising future that
+ benefits all.\\n\\nEND REPORT\",\n \"refusal\": null\n },\n \"logprobs\":
+ null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
+ 730,\n \"completion_tokens\": 571,\n \"total_tokens\": 1301,\n \"prompt_tokens_details\":
+ {\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
+ {\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
+ 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"system_fingerprint\":
+ \"fp_0aa8d3e20b\"\n}\n"
+ headers:
+ CF-Cache-Status:
+ - DYNAMIC
+ CF-RAY:
+ - 8fcd98f9fc060133-GRU
+ Connection:
+ - keep-alive
+ Content-Encoding:
+ - gzip
+ Content-Type:
+ - application/json
+ Date:
+ - Sat, 04 Jan 2025 19:22:36 GMT
+ Server:
+ - cloudflare
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ access-control-expose-headers:
+ - X-Request-ID
+ alt-svc:
+ - h3=":443"; ma=86400
+ openai-organization:
+ - crewai-iuxna1
+ openai-processing-ms:
+ - '7203'
+ openai-version:
+ - '2020-10-01'
+ strict-transport-security:
+ - max-age=31536000; includeSubDomains; preload
+ x-ratelimit-limit-requests:
+ - '30000'
+ x-ratelimit-limit-tokens:
+ - '150000000'
+ x-ratelimit-remaining-requests:
+ - '29999'
+ x-ratelimit-remaining-tokens:
+ - '149998937'
+ x-ratelimit-reset-requests:
+ - 2ms
+ x-ratelimit-reset-tokens:
+ - 0s
+ x-request-id:
+ - req_cab0502e7d8a8564e56d8f741cf451ec
+ http_version: HTTP/1.1
+ status_code: 200
+- request:
+ body: !!binary |
+ Cs4CCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkSpQIKEgoQY3Jld2FpLnRl
+ bGVtZXRyeRKOAgoQO/xpq2/yF233Vf8OitYSiBIIdyOEucIqtF8qDFRhc2sgQ3JlYXRlZDABOXDe
+ ZdqtkxcYQUDaZ9qtkxcYSi4KCGNyZXdfa2V5EiIKIDAwYjk0NmJlNDQzNzE0YjNhNDdjMjAxMDFl
+ YjAyZDY2SjEKB2NyZXdfaWQSJgokNzJkZTEwZTQtNDkwZC00NDYwLTk1NzMtMmU5ZmM5YTMwMWE1
+ Si4KCHRhc2tfa2V5EiIKIGI3MTNjODJmZWI5MmM5ZjVjNThiNDBhOTc1NTZiN2FjSjEKB3Rhc2tf
+ aWQSJgokYWYxYTk2MTgtOTI0YS00ZTc5LWI2ZWItNThkYTEzNjk1OWM1egIYAYUBAAEAAA==
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '337'
+ Content-Type:
+ - application/x-protobuf
+ User-Agent:
+ - OTel-OTLP-Exporter-Python/1.27.0
+ method: POST
+ uri: https://telemetry.crewai.com:4319/v1/traces
+ response:
+ body:
+ string: "\n\0"
+ headers:
+ Content-Length:
+ - '2'
+ Content-Type:
+ - application/x-protobuf
+ Date:
+ - Sat, 04 Jan 2025 19:22:37 GMT
+ status:
+ code: 200
+ message: OK
+- request:
+ body: '{"messages": [{"role": "system", "content": "You are Report Writer. You''re
+ an expert at writing structured reports.\nYour personal goal is: Create properly
+ formatted reports\nTo give my best complete final answer to the task use the
+ exact following format:\n\nThought: I now can give a great answer\nFinal Answer:
+ Your final answer must be the great and the most complete as possible, it must
+ be outcome described.\n\nI MUST use these formats, my job depends on it!"},
+ {"role": "user", "content": "\nCurrent Task: Write a report about AI with exactly
+ 3 key points.\n\nThis is the expect criteria for your final answer: A properly
+ formatted report\nyou MUST return the actual complete content as the final answer,
+ not a summary.\n\nThis is the context you''re working with:\n### Previous attempt
+ failed validation: Output must start with ''REPORT:'' no formatting, just the
+ word REPORT\n\n\n### Previous result:\n# Report on Artificial Intelligence (AI)\n\n##
+ Introduction\nArtificial Intelligence (AI) is a revolutionary technology designed
+ to simulate human intelligence processes, enabling machines to perform tasks
+ that typically require human cognition. Its rapid development has brought forth
+ significant changes across various sectors, improving operational efficiencies,
+ enhancing decision-making, and fostering innovation. This report outlines three
+ key points regarding the impact and implications of AI technology.\n\n## Key
+ Point 1: Transformative Potential in Various Industries\nAI''s transformative
+ potential is observable across numerous sectors including healthcare, finance,
+ transportation, and agriculture. In the healthcare sector, AI algorithms are
+ increasingly used to analyze vast amounts of medical data, which sharpens diagnostics,
+ facilitates personalized treatment plans, and enhances predictive analytics,
+ thus leading to better patient care. In finance, AI contributes to risk assessment,
+ fraud detection, and automated trading, heightening efficiency and reducing
+ the risk of human error. The transportation industry leverages AI technologies
+ for developments in autonomous vehicles and smart transportation systems that
+ optimize routes and alleviate traffic congestion. Furthermore, agriculture benefits
+ from AI by applying precision farming techniques that optimize yield and mitigate
+ environmental effects.\n\n## Key Point 2: Ethical Considerations and Challenges\nWith
+ the increasing deployment of AI technologies, numerous ethical considerations
+ surface, particularly relating to privacy, algorithmic fairness, and the displacement
+ of jobs. Addressing issues such as data security, bias in AI algorithms, and
+ the societal impact of automation is paramount. Organizations are encouraged
+ to develop stringent guidelines and regulatory measures aimed at minimizing
+ bias and ensuring that AI systems uphold values of transparency and accountability.
+ Additionally, the implications of job displacement necessitate strategies for
+ workforce retraining and educational reforms to adequately prepare the workforce
+ for an economy increasingly shaped by AI technologies.\n\n## Key Point 3: Future
+ Directions and Developments\nThe future of AI is poised for remarkable advancements,
+ with trends indicating a growing integration into daily life and widespread
+ applications. The emergence of explainable AI (XAI) aims to enhance the transparency
+ and interpretability of AI decision-making processes, fostering trust and understanding
+ among users. Improvements in natural language processing (NLP) are likely to
+ lead to more seamless and intuitive human-computer interactions. Furthermore,
+ AI''s potential to address global challenges, including climate change and disparities
+ in healthcare access, is becoming increasingly significant. Collaborative efforts
+ among stakeholders will be vital to ensuring that AI advancements are ethical
+ and responsive to societal needs, paving the way for a responsible and equitable
+ AI landscape.\n\n## Conclusion\nAI technology is at the forefront of innovation,
+ with the capacity to transform industries and tackle pressing global issues.
+ As we navigate through the complexities and ethical challenges posed by AI,
+ it is crucial to prioritize responsible development and implementation. By harnessing
+ AI''s transformative capabilities with a focus on equity and transparency, we
+ can pave the way for a promising future that benefits all.\n\nEND REPORT\n\n\nTry
+ again, making sure to address the validation error.\n\nBegin! This is VERY important
+ to you, use the tools available and give your best Final Answer, your job depends
+ on it!\n\nThought:"}], "model": "gpt-4o-mini", "stop": ["\nObservation:"], "stream":
+ false}'
+ headers:
+ accept:
+ - application/json
+ accept-encoding:
+ - gzip, deflate
+ connection:
+ - keep-alive
+ content-length:
+ - '4669'
+ content-type:
+ - application/json
+ cookie:
+ - _cfuvid=SlnUP7AT9jJlQiN.Fm1c7MDyo78_hBRAz8PoabvHVSU-1736018539826-0.0.1.1-604800000;
+ __cf_bm=pumYGlf1gsbVoFNTM1vh9Okj41SgxP3y65T5YWWPU1U-1736018539-1.0.1.1-wmaotkWMviN4lKh6M3P04A8p61Ehm.rTehDpsJhxYhNBNU5.kznMCa3cNXePaEbsKkk4PU2QcWjHj2C7yDrjkw
+ host:
+ - api.openai.com
+ user-agent:
+ - OpenAI/Python 1.52.1
+ x-stainless-arch:
+ - arm64
+ x-stainless-async:
+ - 'false'
+ x-stainless-lang:
+ - python
+ x-stainless-os:
+ - MacOS
+ x-stainless-package-version:
+ - 1.52.1
+ x-stainless-raw-response:
+ - 'true'
+ x-stainless-retry-count:
+ - '0'
+ x-stainless-runtime:
+ - CPython
+ x-stainless-runtime-version:
+ - 3.11.7
+ method: POST
+ uri: https://api.openai.com/v1/chat/completions
+ response:
+ content: "{\n \"id\": \"chatcmpl-Am41EaJaKZSumZe8ph2I32d6QNbTP\",\n \"object\":
+ \"chat.completion\",\n \"created\": 1736018556,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
+ \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
+ \"assistant\",\n \"content\": \"I now can give a great answer \\nFinal
+ Answer: \\n\\nREPORT: \\n\\n# Report on Artificial Intelligence (AI)\\n\\n##
+ Introduction\\nArtificial Intelligence (AI) is a revolutionary technology designed
+ to simulate human intelligence processes, enabling machines to perform tasks
+ that typically require human cognition. Its rapid development has brought forth
+ significant changes across various sectors, improving operational efficiencies,
+ enhancing decision-making, and fostering innovation. This report outlines three
+ key points regarding the impact and implications of AI technology.\\n\\n## Key
+ Point 1: Transformative Potential in Various Industries\\nAI's transformative
+ potential is observable across numerous sectors including healthcare, finance,
+ transportation, and agriculture. In the healthcare sector, AI algorithms are
+ increasingly used to analyze vast amounts of medical data, which sharpens diagnostics,
+ facilitates personalized treatment plans, and enhances predictive analytics,
+ thus leading to better patient care. In finance, AI contributes to risk assessment,
+ fraud detection, and automated trading, heightening efficiency and reducing
+ the risk of human error. The transportation industry leverages AI technologies
+ for developments in autonomous vehicles and smart transportation systems that
+ optimize routes and alleviate traffic congestion. Furthermore, agriculture benefits
+ from AI by applying precision farming techniques that optimize yield and mitigate
+ environmental effects.\\n\\n## Key Point 2: Ethical Considerations and Challenges\\nWith
+ the increasing deployment of AI technologies, numerous ethical considerations
+ surface, particularly relating to privacy, algorithmic fairness, and the displacement
+ of jobs. Addressing issues such as data security, bias in AI algorithms, and
+ the societal impact of automation is paramount. Organizations are encouraged
+ to develop stringent guidelines and regulatory measures aimed at minimizing
+ bias and ensuring that AI systems uphold values of transparency and accountability.
+ Additionally, the implications of job displacement necessitate strategies for
+ workforce retraining and educational reforms to adequately prepare the workforce
+ for an economy increasingly shaped by AI technologies.\\n\\n## Key Point 3:
+ Future Directions and Developments\\nThe future of AI is poised for remarkable
+ advancements, with trends indicating a growing integration into daily life and
+ widespread applications. The emergence of explainable AI (XAI) aims to enhance
+ the transparency and interpretability of AI decision-making processes, fostering
+ trust and understanding among users. Improvements in natural language processing
+ (NLP) are likely to lead to more seamless and intuitive human-computer interactions.
+ Furthermore, AI's potential to address global challenges, including climate
+ change and disparities in healthcare access, is becoming increasingly significant.
+ Collaborative efforts among stakeholders will be vital to ensuring that AI advancements
+ are ethical and responsive to societal needs, paving the way for a responsible
+ and equitable AI landscape.\\n\\n## Conclusion\\nAI technology is at the forefront
+ of innovation, with the capacity to transform industries and tackle pressing
+ global issues. As we navigate through the complexities and ethical challenges
+ posed by AI, it is crucial to prioritize responsible development and implementation.
+ By harnessing AI's transformative capabilities with a focus on equity and transparency,
+ we can pave the way for a promising future that benefits all.\\n\\nEND REPORT\",\n
+ \ \"refusal\": null\n },\n \"logprobs\": null,\n \"finish_reason\":
+ \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 774,\n \"completion_tokens\":
+ 574,\n \"total_tokens\": 1348,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
+ 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\": {\n
+ \ \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
+ 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"system_fingerprint\":
+ \"fp_0aa8d3e20b\"\n}\n"
+ headers:
+ CF-Cache-Status:
+ - DYNAMIC
+ CF-RAY:
+ - 8fcd9928eaa40133-GRU
+ Connection:
+ - keep-alive
+ Content-Encoding:
+ - gzip
+ Content-Type:
+ - application/json
+ Date:
+ - Sat, 04 Jan 2025 19:22:46 GMT
+ Server:
+ - cloudflare
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ access-control-expose-headers:
+ - X-Request-ID
+ alt-svc:
+ - h3=":443"; ma=86400
+ openai-organization:
+ - crewai-iuxna1
+ openai-processing-ms:
+ - '9767'
+ openai-version:
+ - '2020-10-01'
+ strict-transport-security:
+ - max-age=31536000; includeSubDomains; preload
+ x-ratelimit-limit-requests:
+ - '30000'
+ x-ratelimit-limit-tokens:
+ - '150000000'
+ x-ratelimit-remaining-requests:
+ - '29999'
+ x-ratelimit-remaining-tokens:
+ - '149998862'
+ x-ratelimit-reset-requests:
+ - 2ms
+ x-ratelimit-reset-tokens:
+ - 0s
+ x-request-id:
+ - req_d3d0e47180363d07d988cb5ab639597c
+ http_version: HTTP/1.1
+ status_code: 200
+version: 1
diff --git a/tests/crew_test.py b/tests/crew_test.py
index 8354f6584..3505cc701 100644
--- a/tests/crew_test.py
+++ b/tests/crew_test.py
@@ -3337,3 +3337,110 @@ def test_multimodal_agent_live_image_analysis():
assert isinstance(result.raw, str)
assert len(result.raw) > 100 # Expecting a detailed analysis
assert "error" not in result.raw.lower() # No error messages in response
+
+
[email protected](filter_headers=["authorization"])
+def test_crew_with_failing_task_guardrails():
+ """Test that crew properly handles failing guardrails and retries with validation feedback."""
+
+ def strict_format_guardrail(result: TaskOutput):
+ """Validates that the output follows a strict format:
+ - Must start with 'REPORT:'
+ - Must end with 'END REPORT'
+ """
+ content = result.raw.strip()
+
+ if not ('REPORT:' in content or '**REPORT:**' in content):
+ return (False, "Output must start with 'REPORT:' no formatting, just the word REPORT")
+
+ if not ('END REPORT' in content or '**END REPORT**' in content):
+ return (False, "Output must end with 'END REPORT' no formatting, just the word END REPORT")
+
+ return (True, content)
+
+ researcher = Agent(
+ role="Report Writer",
+ goal="Create properly formatted reports",
+ backstory="You're an expert at writing structured reports.",
+ )
+
+ task = Task(
+ description="""Write a report about AI with exactly 3 key points.""",
+ expected_output="A properly formatted report",
+ agent=researcher,
+ guardrail=strict_format_guardrail,
+ max_retries=3
+ )
+
+ crew = Crew(
+ agents=[researcher],
+ tasks=[task],
+ )
+
+ result = crew.kickoff()
+
+ # Verify the final output meets all format requirements
+ content = result.raw.strip()
+ assert content.startswith('REPORT:'), "Output should start with 'REPORT:'"
+ assert content.endswith('END REPORT'), "Output should end with 'END REPORT'"
+
+ # Verify task output
+ task_output = result.tasks_output[0]
+ assert isinstance(task_output, TaskOutput)
+ assert task_output.raw == result.raw
+
+
[email protected](filter_headers=["authorization"])
+def test_crew_guardrail_feedback_in_context():
+ """Test that guardrail feedback is properly appended to task context for retries."""
+
+ def format_guardrail(result: TaskOutput):
+ """Validates that the output contains a specific keyword."""
+ if "IMPORTANT" not in result.raw:
+ return (False, "Output must contain the keyword 'IMPORTANT'")
+ return (True, result.raw)
+
+ # Create execution contexts list to track contexts
+ execution_contexts = []
+
+ researcher = Agent(
+ role="Writer",
+ goal="Write content with specific keywords",
+ backstory="You're an expert at following specific writing requirements.",
+ allow_delegation=False
+ )
+
+ task = Task(
+ description="Write a short response.",
+ expected_output="A response containing the keyword 'IMPORTANT'",
+ agent=researcher,
+ guardrail=format_guardrail,
+ max_retries=2
+ )
+
+ crew = Crew(agents=[researcher], tasks=[task])
+
+ with patch.object(Agent, "execute_task") as mock_execute_task:
+ # Define side_effect to capture context and return different responses
+ def side_effect(task, context=None, tools=None):
+ execution_contexts.append(context if context else "")
+ if len(execution_contexts) == 1:
+ return "This is a test response"
+ return "This is an IMPORTANT test response"
+
+ mock_execute_task.side_effect = side_effect
+
+ result = crew.kickoff()
+
+ # Verify that we had multiple executions
+ assert len(execution_contexts) > 1, "Task should have been executed multiple times"
+
+ # Verify that the second execution included the guardrail feedback
+ assert "Output must contain the keyword 'IMPORTANT'" in execution_contexts[1], \
+ "Guardrail feedback should be included in retry context"
+
+ # Verify final output meets guardrail requirements
+ assert "IMPORTANT" in result.raw, "Final output should contain required keyword"
+
+ # Verify task retry count
+ assert task.retry_count == 1, "Task should have been retried once"