diff --git a/docs/concepts/llms.mdx b/docs/concepts/llms.mdx index 117face04..12061d1a6 100644 --- a/docs/concepts/llms.mdx +++ b/docs/concepts/llms.mdx @@ -27,157 +27,6 @@ Large Language Models (LLMs) are the core intelligence behind CrewAI agents. The -## Available Models and Their Capabilities - -Here's a detailed breakdown of supported models and their capabilities, you can compare performance at [lmarena.ai](https://lmarena.ai/?leaderboard) and [artificialanalysis.ai](https://artificialanalysis.ai/): - - - - | Model | Context Window | Best For | - |-------|---------------|-----------| - | GPT-4 | 8,192 tokens | High-accuracy tasks, complex reasoning | - | GPT-4 Turbo | 128,000 tokens | Long-form content, document analysis | - | GPT-4o & GPT-4o-mini | 128,000 tokens | Cost-effective large context processing | - | o3-mini | 200,000 tokens | Fast reasoning, complex reasoning | - - - 1 token ≈ 4 characters in English. For example, 8,192 tokens ≈ 32,768 characters or about 6,000 words. - - - - | Model | Context Window | Best For | - |-------|---------------|-----------| - | nvidia/mistral-nemo-minitron-8b-8k-instruct | 8,192 tokens | State-of-the-art small language model delivering superior accuracy for chatbot, virtual assistants, and content generation. | - | nvidia/nemotron-4-mini-hindi-4b-instruct| 4,096 tokens | A bilingual Hindi-English SLM for on-device inference, tailored specifically for Hindi Language. | - | "nvidia/llama-3.1-nemotron-70b-instruct | 128k tokens | Llama-3.1-Nemotron-70B-Instruct is a large language model customized by NVIDIA in order to improve the helpfulness of LLM generated responses. | - | nvidia/llama3-chatqa-1.5-8b | 128k tokens | Advanced LLM to generate high-quality, context-aware responses for chatbots and search engines. | - | nvidia/llama3-chatqa-1.5-70b | 128k tokens | Advanced LLM to generate high-quality, context-aware responses for chatbots and search engines. | - | nvidia/vila | 128k tokens | Multi-modal vision-language model that understands text/img/video and creates informative responses | - | nvidia/neva-22| 4,096 tokens | Multi-modal vision-language model that understands text/images and generates informative responses | - | nvidia/nemotron-mini-4b-instruct | 8,192 tokens | General-purpose tasks | - | nvidia/usdcode-llama3-70b-instruct | 128k tokens | State-of-the-art LLM that answers OpenUSD knowledge queries and generates USD-Python code. | - | nvidia/nemotron-4-340b-instruct | 4,096 tokens | Creates diverse synthetic data that mimics the characteristics of real-world data. | - | meta/codellama-70b | 100k tokens | LLM capable of generating code from natural language and vice versa. | - | meta/llama2-70b | 4,096 tokens | Cutting-edge large language AI model capable of generating text and code in response to prompts. | - | meta/llama3-8b-instruct | 8,192 tokens | Advanced state-of-the-art LLM with language understanding, superior reasoning, and text generation. | - | meta/llama3-70b-instruct | 8,192 tokens | Powers complex conversations with superior contextual understanding, reasoning and text generation. | - | meta/llama-3.1-8b-instruct | 128k tokens | Advanced state-of-the-art model with language understanding, superior reasoning, and text generation. | - | meta/llama-3.1-70b-instruct | 128k tokens | Powers complex conversations with superior contextual understanding, reasoning and text generation. | - | meta/llama-3.1-405b-instruct | 128k tokens | Advanced LLM for synthetic data generation, distillation, and inference for chatbots, coding, and domain-specific tasks. | - | meta/llama-3.2-1b-instruct | 128k tokens | Advanced state-of-the-art small language model with language understanding, superior reasoning, and text generation. | - | meta/llama-3.2-3b-instruct | 128k tokens | Advanced state-of-the-art small language model with language understanding, superior reasoning, and text generation. | - | meta/llama-3.2-11b-vision-instruct | 128k tokens | Advanced state-of-the-art small language model with language understanding, superior reasoning, and text generation. | - | meta/llama-3.2-90b-vision-instruct | 128k tokens | Advanced state-of-the-art small language model with language understanding, superior reasoning, and text generation. | - | meta/llama-3.1-70b-instruct | 128k tokens | Powers complex conversations with superior contextual understanding, reasoning and text generation. | - | google/gemma-7b | 8,192 tokens | Cutting-edge text generation model text understanding, transformation, and code generation. | - | google/gemma-2b | 8,192 tokens | Cutting-edge text generation model text understanding, transformation, and code generation. | - | google/codegemma-7b | 8,192 tokens | Cutting-edge model built on Google's Gemma-7B specialized for code generation and code completion. | - | google/codegemma-1.1-7b | 8,192 tokens | Advanced programming model for code generation, completion, reasoning, and instruction following. | - | google/recurrentgemma-2b | 8,192 tokens | Novel recurrent architecture based language model for faster inference when generating long sequences. | - | google/gemma-2-9b-it | 8,192 tokens | Cutting-edge text generation model text understanding, transformation, and code generation. | - | google/gemma-2-27b-it | 8,192 tokens | Cutting-edge text generation model text understanding, transformation, and code generation. | - | google/gemma-2-2b-it | 8,192 tokens | Cutting-edge text generation model text understanding, transformation, and code generation. | - | google/deplot | 512 tokens | One-shot visual language understanding model that translates images of plots into tables. | - | google/paligemma | 8,192 tokens | Vision language model adept at comprehending text and visual inputs to produce informative responses. | - | mistralai/mistral-7b-instruct-v0.2 | 32k tokens | This LLM follows instructions, completes requests, and generates creative text. | - | mistralai/mixtral-8x7b-instruct-v0.1 | 8,192 tokens | An MOE LLM that follows instructions, completes requests, and generates creative text. | - | mistralai/mistral-large | 4,096 tokens | Creates diverse synthetic data that mimics the characteristics of real-world data. | - | mistralai/mixtral-8x22b-instruct-v0.1 | 8,192 tokens | Creates diverse synthetic data that mimics the characteristics of real-world data. | - | mistralai/mistral-7b-instruct-v0.3 | 32k tokens | This LLM follows instructions, completes requests, and generates creative text. | - | nv-mistralai/mistral-nemo-12b-instruct | 128k tokens | Most advanced language model for reasoning, code, multilingual tasks; runs on a single GPU. | - | mistralai/mamba-codestral-7b-v0.1 | 256k tokens | Model for writing and interacting with code across a wide range of programming languages and tasks. | - | microsoft/phi-3-mini-128k-instruct | 128K tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | - | microsoft/phi-3-mini-4k-instruct | 4,096 tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | - | microsoft/phi-3-small-8k-instruct | 8,192 tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | - | microsoft/phi-3-small-128k-instruct | 128K tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | - | microsoft/phi-3-medium-4k-instruct | 4,096 tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | - | microsoft/phi-3-medium-128k-instruct | 128K tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | - | microsoft/phi-3.5-mini-instruct | 128K tokens | Lightweight multilingual LLM powering AI applications in latency bound, memory/compute constrained environments | - | microsoft/phi-3.5-moe-instruct | 128K tokens | Advanced LLM based on Mixture of Experts architecure to deliver compute efficient content generation | - | microsoft/kosmos-2 | 1,024 tokens | Groundbreaking multimodal model designed to understand and reason about visual elements in images. | - | microsoft/phi-3-vision-128k-instruct | 128k tokens | Cutting-edge open multimodal model exceling in high-quality reasoning from images. | - | microsoft/phi-3.5-vision-instruct | 128k tokens | Cutting-edge open multimodal model exceling in high-quality reasoning from images. | - | databricks/dbrx-instruct | 12k tokens | A general-purpose LLM with state-of-the-art performance in language understanding, coding, and RAG. | - | snowflake/arctic | 1,024 tokens | Delivers high efficiency inference for enterprise applications focused on SQL generation and coding. | - | aisingapore/sea-lion-7b-instruct | 4,096 tokens | LLM to represent and serve the linguistic and cultural diversity of Southeast Asia | - | ibm/granite-8b-code-instruct | 4,096 tokens | Software programming LLM for code generation, completion, explanation, and multi-turn conversion. | - | ibm/granite-34b-code-instruct | 8,192 tokens | Software programming LLM for code generation, completion, explanation, and multi-turn conversion. | - | ibm/granite-3.0-8b-instruct | 4,096 tokens | Advanced Small Language Model supporting RAG, summarization, classification, code, and agentic AI | - | ibm/granite-3.0-3b-a800m-instruct | 4,096 tokens | Highly efficient Mixture of Experts model for RAG, summarization, entity extraction, and classification | - | mediatek/breeze-7b-instruct | 4,096 tokens | Creates diverse synthetic data that mimics the characteristics of real-world data. | - | upstage/solar-10.7b-instruct | 4,096 tokens | Excels in NLP tasks, particularly in instruction-following, reasoning, and mathematics. | - | writer/palmyra-med-70b-32k | 32k tokens | Leading LLM for accurate, contextually relevant responses in the medical domain. | - | writer/palmyra-med-70b | 32k tokens | Leading LLM for accurate, contextually relevant responses in the medical domain. | - | writer/palmyra-fin-70b-32k | 32k tokens | Specialized LLM for financial analysis, reporting, and data processing | - | 01-ai/yi-large | 32k tokens | Powerful model trained on English and Chinese for diverse tasks including chatbot and creative writing. | - | deepseek-ai/deepseek-coder-6.7b-instruct | 2k tokens | Powerful coding model offering advanced capabilities in code generation, completion, and infilling | - | rakuten/rakutenai-7b-instruct | 1,024 tokens | Advanced state-of-the-art LLM with language understanding, superior reasoning, and text generation. | - | rakuten/rakutenai-7b-chat | 1,024 tokens | Advanced state-of-the-art LLM with language understanding, superior reasoning, and text generation. | - | baichuan-inc/baichuan2-13b-chat | 4,096 tokens | Support Chinese and English chat, coding, math, instruction following, solving quizzes | - - - NVIDIA's NIM support for models is expanding continuously! For the most up-to-date list of available models, please visit build.nvidia.com. - - - - | Model | Context Window | Best For | - |-------|---------------|-----------| - | gemini-2.0-flash-exp | 1M tokens | Higher quality at faster speed, multimodal model, good for most tasks | - | gemini-1.5-flash | 1M tokens | Balanced multimodal model, good for most tasks | - | gemini-1.5-flash-8B | 1M tokens | Fastest, most cost-efficient, good for high-frequency tasks | - | gemini-1.5-pro | 2M tokens | Best performing, wide variety of reasoning tasks including logical reasoning, coding, and creative collaboration | - - - Google's Gemini models are all multimodal, supporting audio, images, video and text, supporting context caching, json schema, function calling, etc. - - These models are available via API_KEY from - [The Gemini API](https://ai.google.dev/gemini-api/docs) and also from - [Google Cloud Vertex](https://cloud.google.com/vertex-ai/generative-ai/docs/migrate/migrate-google-ai) as part of the - [Model Garden](https://cloud.google.com/vertex-ai/generative-ai/docs/model-garden/explore-models). - - - - | Model | Context Window | Best For | - |-------|---------------|-----------| - | Llama 3.1 70B/8B | 131,072 tokens | High-performance, large context tasks | - | Llama 3.2 Series | 8,192 tokens | General-purpose tasks | - | Mixtral 8x7B | 32,768 tokens | Balanced performance and context | - - - Groq is known for its fast inference speeds, making it suitable for real-time applications. - - - - | Model | Context Window | Best For | - |-------|---------------|-----------| - | Llama 3.1 70B/8B | Up to 131,072 tokens | High-performance, large context tasks | - | Llama 3.1 405B | 8,192 tokens | High-performance and output quality | - | Llama 3.2 Series | 8,192 tokens | General-purpose tasks, multimodal | - | Llama 3.3 70B | Up to 131,072 tokens | High-performance and output quality| - | Qwen2 familly | 8,192 tokens | High-performance and output quality | - - - [SambaNova](https://cloud.sambanova.ai/) has several models with fast inference speed at full precision. - - - - | Provider | Context Window | Key Features | - |----------|---------------|--------------| - | Deepseek Chat | 64,000 tokens | Specialized in technical discussions | - | Deepseek R1 | 64,000 tokens | Affordable reasoning model | - | Claude 3 | Up to 200K tokens | Strong reasoning, code understanding | - | Gemma Series | 8,192 tokens | Efficient, smaller-scale tasks | - - - Provider selection should consider factors like: - - API availability in your region - - Pricing structure - - Required features (e.g., streaming, function calling) - - Performance requirements - - - - ## Setting Up Your LLM There are three ways to configure LLMs in CrewAI. Choose the method that best fits your workflow: @@ -206,102 +55,12 @@ There are three ways to configure LLMs in CrewAI. Choose the method that best fi ```yaml researcher: - # Agent Definition role: Research Specialist goal: Conduct comprehensive research and analysis backstory: A dedicated research professional with years of experience verbose: true - - # Model Selection (uncomment your choice) - - # OpenAI Models - Known for reliability and performance - llm: openai/gpt-4o-mini - # llm: openai/gpt-4 # More accurate but expensive - # llm: openai/gpt-4-turbo # Fast with large context - # llm: openai/gpt-4o # Optimized for longer texts - # llm: openai/o1-preview # Latest features - # llm: openai/o1-mini # Cost-effective - - # Azure Models - For enterprise deployments - # llm: azure/gpt-4o-mini - # llm: azure/gpt-4 - # llm: azure/gpt-35-turbo - - # Anthropic Models - Strong reasoning capabilities - # llm: anthropic/claude-3-opus-20240229-v1:0 - # llm: anthropic/claude-3-sonnet-20240229-v1:0 - # llm: anthropic/claude-3-haiku-20240307-v1:0 - # llm: anthropic/claude-2.1 - # llm: anthropic/claude-2.0 - - # Google Models - Strong reasoning, large cachable context window, multimodal - # llm: gemini/gemini-1.5-pro-latest - # llm: gemini/gemini-1.5-flash-latest - # llm: gemini/gemini-1.5-flash-8b-latest - - # AWS Bedrock Models - Enterprise-grade - # llm: bedrock/anthropic.claude-3-sonnet-20240229-v1:0 - # llm: bedrock/anthropic.claude-v2:1 - # llm: bedrock/amazon.titan-text-express-v1 - # llm: bedrock/meta.llama2-70b-chat-v1 - - # Amazon SageMaker Models - Enterprise-grade - # llm: sagemaker/ - - # Mistral Models - Open source alternative - # llm: mistral/mistral-large-latest - # llm: mistral/mistral-medium-latest - # llm: mistral/mistral-small-latest - - # Groq Models - Fast inference - # llm: groq/mixtral-8x7b-32768 - # llm: groq/llama-3.1-70b-versatile - # llm: groq/llama-3.2-90b-text-preview - # llm: groq/gemma2-9b-it - # llm: groq/gemma-7b-it - - # IBM watsonx.ai Models - Enterprise features - # llm: watsonx/ibm/granite-13b-chat-v2 - # llm: watsonx/meta-llama/llama-3-1-70b-instruct - # llm: watsonx/bigcode/starcoder2-15b - - # Ollama Models - Local deployment - # llm: ollama/llama3:70b - # llm: ollama/codellama - # llm: ollama/mistral - # llm: ollama/mixtral - # llm: ollama/phi - - # Fireworks AI Models - Specialized tasks - # llm: fireworks_ai/accounts/fireworks/models/llama-v3-70b-instruct - # llm: fireworks_ai/accounts/fireworks/models/mixtral-8x7b - # llm: fireworks_ai/accounts/fireworks/models/zephyr-7b-beta - - # Perplexity AI Models - Research focused - # llm: pplx/llama-3.1-sonar-large-128k-online - # llm: pplx/mistral-7b-instruct - # llm: pplx/codellama-34b-instruct - # llm: pplx/mixtral-8x7b-instruct - - # Hugging Face Models - Community models - # llm: huggingface/meta-llama/Meta-Llama-3.1-8B-Instruct - # llm: huggingface/mistralai/Mixtral-8x7B-Instruct-v0.1 - # llm: huggingface/tiiuae/falcon-180B-chat - # llm: huggingface/google/gemma-7b-it - - # Nvidia NIM Models - GPU-optimized - # llm: nvidia_nim/meta/llama3-70b-instruct - # llm: nvidia_nim/mistral/mixtral-8x7b - # llm: nvidia_nim/google/gemma-7b - - # SambaNova Models - Enterprise AI - # llm: sambanova/Meta-Llama-3.1-8B-Instruct - # llm: sambanova/BioMistral-7B - # llm: sambanova/Falcon-180B - - # Open Router Models - Affordable reasoning - # llm: openrouter/deepseek/deepseek-r1 - # llm: openrouter/deepseek/deepseek-chat + llm: openai/gpt-4o-mini # your model here + # (see provider configuration examples below for more) ``` @@ -349,6 +108,465 @@ There are three ways to configure LLMs in CrewAI. Choose the method that best fi +## Provider Configuration Examples + + +CrewAI supports a multitude of LLM providers, each offering unique features, authentication methods, and model capabilities. +In this section, you'll find detailed examples that help you select, configure, and optimize the LLM that best fits your project's needs. + + + + Set the following environment variables in your `.env` file: + + ```toml Code + # Required + OPENAI_API_KEY=sk-... + + # Optional + OPENAI_API_BASE= + OPENAI_ORGANIZATION= + ``` + + Example usage in your CrewAI project: + ```python Code + from crewai import LLM + + llm = LLM( + model="openai/gpt-4", # call model by provider/model_name + temperature=0.8, + max_tokens=150, + top_p=0.9, + frequency_penalty=0.1, + presence_penalty=0.1, + stop=["END"], + seed=42 + ) + ``` + + OpenAI is one of the leading providers of LLMs with a wide range of models and features. + + | Model | Context Window | Best For | + |---------------------|------------------|-----------------------------------------------| + | GPT-4 | 8,192 tokens | High-accuracy tasks, complex reasoning | + | GPT-4 Turbo | 128,000 tokens | Long-form content, document analysis | + | GPT-4o & GPT-4o-mini | 128,000 tokens | Cost-effective large context processing | + | o3-mini | 200,000 tokens | Fast reasoning, complex reasoning | + | o1-mini | 128,000 tokens | Fast reasoning, complex reasoning | + | o1-preview | 128,000 tokens | Fast reasoning, complex reasoning | + | o1 | 200,000 tokens | Fast reasoning, complex reasoning | + + + + ```toml Code + ANTHROPIC_API_KEY=sk-ant-... + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="anthropic/claude-3-sonnet-20240229-v1:0", + temperature=0.7 + ) + ``` + + + + Set the following environment variables in your `.env` file: + + ```toml Code + # Option 1: Gemini accessed with an API key. + # https://ai.google.dev/gemini-api/docs/api-key + GEMINI_API_KEY= + + # Option 2: Vertex AI IAM credentials for Gemini, Anthropic, and Model Garden. + # https://cloud.google.com/vertex-ai/generative-ai/docs/overview + ``` + + Get credentials from your Google Cloud Console and save it to a JSON file with the following code: + ```python Code + import json + + file_path = 'path/to/vertex_ai_service_account.json' + + # Load the JSON file + with open(file_path, 'r') as file: + vertex_credentials = json.load(file) + + # Convert the credentials to a JSON string + vertex_credentials_json = json.dumps(vertex_credentials) + ``` + + Example usage in your CrewAI project: + ```python Code + from crewai import LLM + + llm = LLM( + model="gemini/gemini-1.5-pro-latest", + temperature=0.7, + vertex_credentials=vertex_credentials_json + ) + ``` + Google offers a range of powerful models optimized for different use cases: + + | Model | Context Window | Best For | + |-----------------------|----------------|------------------------------------------------------------------| + | gemini-2.0-flash-exp | 1M tokens | Higher quality at faster speed, multimodal model, good for most tasks | + | gemini-1.5-flash | 1M tokens | Balanced multimodal model, good for most tasks | + | gemini-1.5-flash-8B | 1M tokens | Fastest, most cost-efficient, good for high-frequency tasks | + | gemini-1.5-pro | 2M tokens | Best performing, wide variety of reasoning tasks including logical reasoning, coding, and creative collaboration | + + + + ```toml Code + # Required + AZURE_API_KEY= + AZURE_API_BASE= + AZURE_API_VERSION= + + # Optional + AZURE_AD_TOKEN= + AZURE_API_TYPE= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="azure/gpt-4", + api_version="2023-05-15" + ) + ``` + + + + ```toml Code + AWS_ACCESS_KEY_ID= + AWS_SECRET_ACCESS_KEY= + AWS_DEFAULT_REGION= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="bedrock/anthropic.claude-3-sonnet-20240229-v1:0" + ) + ``` + + + + ```toml Code + AWS_ACCESS_KEY_ID= + AWS_SECRET_ACCESS_KEY= + AWS_DEFAULT_REGION= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="sagemaker/" + ) + ``` + + + + Set the following environment variables in your `.env` file: + ```toml Code + MISTRAL_API_KEY= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="mistral/mistral-large-latest", + temperature=0.7 + ) + ``` + + + + Set the following environment variables in your `.env` file: + ```toml Code + NVIDIA_API_KEY= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="nvidia_nim/meta/llama3-70b-instruct", + temperature=0.7 + ) + ``` + + Nvidia NIM provides a comprehensive suite of models for various use cases, from general-purpose tasks to specialized applications. + + | Model | Context Window | Best For | + |-------------------------------------------------------------------------|----------------|-------------------------------------------------------------------| + | nvidia/mistral-nemo-minitron-8b-8k-instruct | 8,192 tokens | State-of-the-art small language model delivering superior accuracy for chatbot, virtual assistants, and content generation. | + | nvidia/nemotron-4-mini-hindi-4b-instruct | 4,096 tokens | A bilingual Hindi-English SLM for on-device inference, tailored specifically for Hindi Language. | + | nvidia/llama-3.1-nemotron-70b-instruct | 128k tokens | Customized for enhanced helpfulness in responses | + | nvidia/llama3-chatqa-1.5-8b | 128k tokens | Advanced LLM to generate high-quality, context-aware responses for chatbots and search engines. | + | nvidia/llama3-chatqa-1.5-70b | 128k tokens | Advanced LLM to generate high-quality, context-aware responses for chatbots and search engines. | + | nvidia/vila | 128k tokens | Multi-modal vision-language model that understands text/img/video and creates informative responses | + | nvidia/neva-22 | 4,096 tokens | Multi-modal vision-language model that understands text/images and generates informative responses | + | nvidia/nemotron-mini-4b-instruct | 8,192 tokens | General-purpose tasks | + | nvidia/usdcode-llama3-70b-instruct | 128k tokens | State-of-the-art LLM that answers OpenUSD knowledge queries and generates USD-Python code. | + | nvidia/nemotron-4-340b-instruct | 4,096 tokens | Creates diverse synthetic data that mimics the characteristics of real-world data. | + | meta/codellama-70b | 100k tokens | LLM capable of generating code from natural language and vice versa. | + | meta/llama2-70b | 4,096 tokens | Cutting-edge large language AI model capable of generating text and code in response to prompts. | + | meta/llama3-8b-instruct | 8,192 tokens | Advanced state-of-the-art LLM with language understanding, superior reasoning, and text generation. | + | meta/llama3-70b-instruct | 8,192 tokens | Powers complex conversations with superior contextual understanding, reasoning and text generation. | + | meta/llama-3.1-8b-instruct | 128k tokens | Advanced state-of-the-art model with language understanding, superior reasoning, and text generation. | + | meta/llama-3.1-70b-instruct | 128k tokens | Powers complex conversations with superior contextual understanding, reasoning and text generation. | + | meta/llama-3.1-405b-instruct | 128k tokens | Advanced LLM for synthetic data generation, distillation, and inference for chatbots, coding, and domain-specific tasks. | + | meta/llama-3.2-1b-instruct | 128k tokens | Advanced state-of-the-art small language model with language understanding, superior reasoning, and text generation. | + | meta/llama-3.2-3b-instruct | 128k tokens | Advanced state-of-the-art small language model with language understanding, superior reasoning, and text generation. | + | meta/llama-3.2-11b-vision-instruct | 128k tokens | Advanced state-of-the-art small language model with language understanding, superior reasoning, and text generation. | + | meta/llama-3.2-90b-vision-instruct | 128k tokens | Advanced state-of-the-art small language model with language understanding, superior reasoning, and text generation. | + | google/gemma-7b | 8,192 tokens | Cutting-edge text generation model text understanding, transformation, and code generation. | + | google/gemma-2b | 8,192 tokens | Cutting-edge text generation model text understanding, transformation, and code generation. | + | google/codegemma-7b | 8,192 tokens | Cutting-edge model built on Google's Gemma-7B specialized for code generation and code completion. | + | google/codegemma-1.1-7b | 8,192 tokens | Advanced programming model for code generation, completion, reasoning, and instruction following. | + | google/recurrentgemma-2b | 8,192 tokens | Novel recurrent architecture based language model for faster inference when generating long sequences. | + | google/gemma-2-9b-it | 8,192 tokens | Cutting-edge text generation model text understanding, transformation, and code generation. | + | google/gemma-2-27b-it | 8,192 tokens | Cutting-edge text generation model text understanding, transformation, and code generation. | + | google/gemma-2-2b-it | 8,192 tokens | Cutting-edge text generation model text understanding, transformation, and code generation. | + | google/deplot | 512 tokens | One-shot visual language understanding model that translates images of plots into tables. | + | google/paligemma | 8,192 tokens | Vision language model adept at comprehending text and visual inputs to produce informative responses. | + | mistralai/mistral-7b-instruct-v0.2 | 32k tokens | This LLM follows instructions, completes requests, and generates creative text. | + | mistralai/mixtral-8x7b-instruct-v0.1 | 8,192 tokens | An MOE LLM that follows instructions, completes requests, and generates creative text. | + | mistralai/mistral-large | 4,096 tokens | Creates diverse synthetic data that mimics the characteristics of real-world data. | + | mistralai/mixtral-8x22b-instruct-v0.1 | 8,192 tokens | Creates diverse synthetic data that mimics the characteristics of real-world data. | + | mistralai/mistral-7b-instruct-v0.3 | 32k tokens | This LLM follows instructions, completes requests, and generates creative text. | + | nv-mistralai/mistral-nemo-12b-instruct | 128k tokens | Most advanced language model for reasoning, code, multilingual tasks; runs on a single GPU. | + | mistralai/mamba-codestral-7b-v0.1 | 256k tokens | Model for writing and interacting with code across a wide range of programming languages and tasks. | + | microsoft/phi-3-mini-128k-instruct | 128K tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | + | microsoft/phi-3-mini-4k-instruct | 4,096 tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | + | microsoft/phi-3-small-8k-instruct | 8,192 tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | + | microsoft/phi-3-small-128k-instruct | 128K tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | + | microsoft/phi-3-medium-4k-instruct | 4,096 tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | + | microsoft/phi-3-medium-128k-instruct | 128K tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | + | microsoft/phi-3.5-mini-instruct | 128K tokens | Lightweight multilingual LLM powering AI applications in latency bound, memory/compute constrained environments | + | microsoft/phi-3.5-moe-instruct | 128K tokens | Advanced LLM based on Mixture of Experts architecure to deliver compute efficient content generation | + | microsoft/kosmos-2 | 1,024 tokens | Groundbreaking multimodal model designed to understand and reason about visual elements in images. | + | microsoft/phi-3-vision-128k-instruct | 128k tokens | Cutting-edge open multimodal model exceling in high-quality reasoning from images. | + | microsoft/phi-3.5-vision-instruct | 128k tokens | Cutting-edge open multimodal model exceling in high-quality reasoning from images. | + | databricks/dbrx-instruct | 12k tokens | A general-purpose LLM with state-of-the-art performance in language understanding, coding, and RAG. | + | snowflake/arctic | 1,024 tokens | Delivers high efficiency inference for enterprise applications focused on SQL generation and coding. | + | aisingapore/sea-lion-7b-instruct | 4,096 tokens | LLM to represent and serve the linguistic and cultural diversity of Southeast Asia | + | ibm/granite-8b-code-instruct | 4,096 tokens | Software programming LLM for code generation, completion, explanation, and multi-turn conversion. | + | ibm/granite-34b-code-instruct | 8,192 tokens | Software programming LLM for code generation, completion, explanation, and multi-turn conversion. | + | ibm/granite-3.0-8b-instruct | 4,096 tokens | Advanced Small Language Model supporting RAG, summarization, classification, code, and agentic AI | + | ibm/granite-3.0-3b-a800m-instruct | 4,096 tokens | Highly efficient Mixture of Experts model for RAG, summarization, entity extraction, and classification | + | mediatek/breeze-7b-instruct | 4,096 tokens | Creates diverse synthetic data that mimics the characteristics of real-world data. | + | upstage/solar-10.7b-instruct | 4,096 tokens | Excels in NLP tasks, particularly in instruction-following, reasoning, and mathematics. | + | writer/palmyra-med-70b-32k | 32k tokens | Leading LLM for accurate, contextually relevant responses in the medical domain. | + | writer/palmyra-med-70b | 32k tokens | Leading LLM for accurate, contextually relevant responses in the medical domain. | + | writer/palmyra-fin-70b-32k | 32k tokens | Specialized LLM for financial analysis, reporting, and data processing | + | 01-ai/yi-large | 32k tokens | Powerful model trained on English and Chinese for diverse tasks including chatbot and creative writing. | + | deepseek-ai/deepseek-coder-6.7b-instruct | 2k tokens | Powerful coding model offering advanced capabilities in code generation, completion, and infilling | + | rakuten/rakutenai-7b-instruct | 1,024 tokens | Advanced state-of-the-art LLM with language understanding, superior reasoning, and text generation. | + | rakuten/rakutenai-7b-chat | 1,024 tokens | Advanced state-of-the-art LLM with language understanding, superior reasoning, and text generation. | + | baichuan-inc/baichuan2-13b-chat | 4,096 tokens | Support Chinese and English chat, coding, math, instruction following, solving quizzes | + + + + Set the following environment variables in your `.env` file: + + ```toml Code + GROQ_API_KEY= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="groq/llama-3.2-90b-text-preview", + temperature=0.7 + ) + ``` + | Model | Context Window | Best For | + |-------------------|------------------|--------------------------------------------| + | Llama 3.1 70B/8B | 131,072 tokens | High-performance, large context tasks | + | Llama 3.2 Series | 8,192 tokens | General-purpose tasks | + | Mixtral 8x7B | 32,768 tokens | Balanced performance and context | + + + + Set the following environment variables in your `.env` file: + ```toml Code + # Required + WATSONX_URL= + WATSONX_APIKEY= + WATSONX_PROJECT_ID= + + # Optional + WATSONX_TOKEN= + WATSONX_DEPLOYMENT_SPACE_ID= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="watsonx/meta-llama/llama-3-1-70b-instruct", + base_url="https://api.watsonx.ai/v1" + ) + ``` + + + + 1. Install Ollama: [ollama.ai](https://ollama.ai/) + 2. Run a model: `ollama run llama2` + 3. Configure: + + ```python Code + llm = LLM( + model="ollama/llama3:70b", + base_url="http://localhost:11434" + ) + ``` + + + + Set the following environment variables in your `.env` file: + ```toml Code + FIREWORKS_API_KEY= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="fireworks_ai/accounts/fireworks/models/llama-v3-70b-instruct", + temperature=0.7 + ) + ``` + + + + Set the following environment variables in your `.env` file: + ```toml Code + PERPLEXITY_API_KEY= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="llama-3.1-sonar-large-128k-online", + base_url="https://api.perplexity.ai/" + ) + ``` + + + + Set the following environment variables in your `.env` file: + ```toml Code + HUGGINGFACE_API_KEY= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="huggingface/meta-llama/Meta-Llama-3.1-8B-Instruct", + base_url="your_api_endpoint" + ) + ``` + + + + Set the following environment variables in your `.env` file: + + ```toml Code + SAMBANOVA_API_KEY= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="sambanova/Meta-Llama-3.1-8B-Instruct", + temperature=0.7 + ) + ``` + | Model | Context Window | Best For | + |--------------------|------------------------|----------------------------------------------| + | Llama 3.1 70B/8B | Up to 131,072 tokens | High-performance, large context tasks | + | Llama 3.1 405B | 8,192 tokens | High-performance and output quality | + | Llama 3.2 Series | 8,192 tokens | General-purpose, multimodal tasks | + | Llama 3.3 70B | Up to 131,072 tokens | High-performance and output quality | + | Qwen2 familly | 8,192 tokens | High-performance and output quality | + + + + Set the following environment variables in your `.env` file: + ```toml Code + # Required + CEREBRAS_API_KEY= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="cerebras/llama3.1-70b", + temperature=0.7, + max_tokens=8192 + ) + ``` + + + Cerebras features: + - Fast inference speeds + - Competitive pricing + - Good balance of speed and quality + - Support for long context windows + + + + + Set the following environment variables in your `.env` file: + ```toml Code + OPENROUTER_API_KEY= + ``` + + Example usage in your CrewAI project: + ```python Code + llm = LLM( + model="openrouter/deepseek/deepseek-r1", + base_url="https://openrouter.ai/api/v1", + api_key=OPENROUTER_API_KEY + ) + ``` + + + Open Router models: + - openrouter/deepseek/deepseek-r1 + - openrouter/deepseek/deepseek-chat + + + + +## Structured LLM Calls + +CrewAI supports structured responses from LLM calls by allowing you to define a `response_format` using a Pydantic model. This enables the framework to automatically parse and validate the output, making it easier to integrate the response into your application without manual post-processing. + +For example, you can define a Pydantic model to represent the expected response structure and pass it as the `response_format` when instantiating the LLM. The model will then be used to convert the LLM output into a structured Python object. + +```python Code +from crewai import LLM + +class Dog(BaseModel): + name: str + age: int + breed: str + + +llm = LLM(model="gpt-4o", response_format=Dog) + +response = llm.call( + "Analyze the following messages and return the name, age, and breed. " + "Meet Kona! She is 3 years old and is a black german shepherd." +) +print(response) + +# Output: +# Dog(name='Kona', age=3, breed='black german shepherd') +``` + ## Advanced Features and Optimization Learn how to get the most out of your LLM configuration: @@ -417,339 +635,6 @@ Learn how to get the most out of your LLM configuration: -## Provider Configuration Examples - - - - ```python Code - # Required - OPENAI_API_KEY=sk-... - - # Optional - OPENAI_API_BASE= - OPENAI_ORGANIZATION= - ``` - - Example usage: - ```python Code - from crewai import LLM - - llm = LLM( - model="gpt-4", - temperature=0.8, - max_tokens=150, - top_p=0.9, - frequency_penalty=0.1, - presence_penalty=0.1, - stop=["END"], - seed=42 - ) - ``` - - - - ```python Code - ANTHROPIC_API_KEY=sk-ant-... - ``` - - Example usage: - ```python Code - llm = LLM( - model="anthropic/claude-3-sonnet-20240229-v1:0", - temperature=0.7 - ) - ``` - - - - ```python Code - # Option 1: Gemini accessed with an API key. - # https://ai.google.dev/gemini-api/docs/api-key - GEMINI_API_KEY= - - # Option 2: Vertex AI IAM credentials for Gemini, Anthropic, and Model Garden. - # https://cloud.google.com/vertex-ai/generative-ai/docs/overview - ``` - - Get credentials: - ```python Code - import json - - file_path = 'path/to/vertex_ai_service_account.json' - - # Load the JSON file - with open(file_path, 'r') as file: - vertex_credentials = json.load(file) - - # Convert the credentials to a JSON string - vertex_credentials_json = json.dumps(vertex_credentials) - ``` - - Example usage: - ```python Code - from crewai import LLM - - llm = LLM( - model="gemini/gemini-1.5-pro-latest", - temperature=0.7, - vertex_credentials=vertex_credentials_json - ) - ``` - - - - ```python Code - # Required - AZURE_API_KEY= - AZURE_API_BASE= - AZURE_API_VERSION= - - # Optional - AZURE_AD_TOKEN= - AZURE_API_TYPE= - ``` - - Example usage: - ```python Code - llm = LLM( - model="azure/gpt-4", - api_version="2023-05-15" - ) - ``` - - - - ```python Code - AWS_ACCESS_KEY_ID= - AWS_SECRET_ACCESS_KEY= - AWS_DEFAULT_REGION= - ``` - - Example usage: - ```python Code - llm = LLM( - model="bedrock/anthropic.claude-3-sonnet-20240229-v1:0" - ) - ``` - - - - ```python Code - AWS_ACCESS_KEY_ID= - AWS_SECRET_ACCESS_KEY= - AWS_DEFAULT_REGION= - ``` - - Example usage: - ```python Code - llm = LLM( - model="sagemaker/" - ) - ``` - - - - ```python Code - MISTRAL_API_KEY= - ``` - - Example usage: - ```python Code - llm = LLM( - model="mistral/mistral-large-latest", - temperature=0.7 - ) - ``` - - - - ```python Code - NVIDIA_API_KEY= - ``` - - Example usage: - ```python Code - llm = LLM( - model="nvidia_nim/meta/llama3-70b-instruct", - temperature=0.7 - ) - ``` - - - - ```python Code - GROQ_API_KEY= - ``` - - Example usage: - ```python Code - llm = LLM( - model="groq/llama-3.2-90b-text-preview", - temperature=0.7 - ) - ``` - - - - ```python Code - # Required - WATSONX_URL= - WATSONX_APIKEY= - WATSONX_PROJECT_ID= - - # Optional - WATSONX_TOKEN= - WATSONX_DEPLOYMENT_SPACE_ID= - ``` - - Example usage: - ```python Code - llm = LLM( - model="watsonx/meta-llama/llama-3-1-70b-instruct", - base_url="https://api.watsonx.ai/v1" - ) - ``` - - - - 1. Install Ollama: [ollama.ai](https://ollama.ai/) - 2. Run a model: `ollama run llama2` - 3. Configure: - - ```python Code - llm = LLM( - model="ollama/llama3:70b", - base_url="http://localhost:11434" - ) - ``` - - - - ```python Code - FIREWORKS_API_KEY= - ``` - - Example usage: - ```python Code - llm = LLM( - model="fireworks_ai/accounts/fireworks/models/llama-v3-70b-instruct", - temperature=0.7 - ) - ``` - - - - ```python Code - PERPLEXITY_API_KEY= - ``` - - Example usage: - ```python Code - llm = LLM( - model="llama-3.1-sonar-large-128k-online", - base_url="https://api.perplexity.ai/" - ) - ``` - - - - ```python Code - HUGGINGFACE_API_KEY= - ``` - - Example usage: - ```python Code - llm = LLM( - model="huggingface/meta-llama/Meta-Llama-3.1-8B-Instruct", - base_url="your_api_endpoint" - ) - ``` - - - - ```python Code - SAMBANOVA_API_KEY= - ``` - - Example usage: - ```python Code - llm = LLM( - model="sambanova/Meta-Llama-3.1-8B-Instruct", - temperature=0.7 - ) - ``` - - - - ```python Code - # Required - CEREBRAS_API_KEY= - ``` - - Example usage: - ```python Code - llm = LLM( - model="cerebras/llama3.1-70b", - temperature=0.7, - max_tokens=8192 - ) - ``` - - - Cerebras features: - - Fast inference speeds - - Competitive pricing - - Good balance of speed and quality - - Support for long context windows - - - - - ```python Code - OPENROUTER_API_KEY= - ``` - - Example usage: - ```python Code - llm = LLM( - model="openrouter/deepseek/deepseek-r1", - base_url="https://openrouter.ai/api/v1", - api_key=OPENROUTER_API_KEY - ) - ``` - - - Open Router models: - - openrouter/deepseek/deepseek-r1 - - openrouter/deepseek/deepseek-chat - - - - -## Structured LLM Calls - -CrewAI supports structured responses from LLM calls by allowing you to define a `response_format` using a Pydantic model. This enables the framework to automatically parse and validate the output, making it easier to integrate the response into your application without manual post-processing. - -For example, you can define a Pydantic model to represent the expected response structure and pass it as the `response_format` when instantiating the LLM. The model will then be used to convert the LLM output into a structured Python object. - -```python Code -from crewai import LLM - -class Dog(BaseModel): - name: str - age: int - breed: str - - -llm = LLM(model="gpt-4o", response_format=Dog) - -response = llm.call( - "Analyze the following messages and return the name, age, and breed. " - "Meet Kona! She is 3 years old and is a black german shepherd." -) -print(response) -``` - ## Common Issues and Solutions diff --git a/src/crewai/agent.py b/src/crewai/agent.py index 4c1e3c393..f07408133 100644 --- a/src/crewai/agent.py +++ b/src/crewai/agent.py @@ -19,25 +19,17 @@ from crewai.tools.agent_tools.agent_tools import AgentTools from crewai.utilities import Converter, Prompts from crewai.utilities.constants import TRAINED_AGENTS_DATA_FILE, TRAINING_DATA_FILE from crewai.utilities.converter import generate_model_description +from crewai.utilities.events.agent_events import ( + AgentExecutionCompletedEvent, + AgentExecutionErrorEvent, + AgentExecutionStartedEvent, +) +from crewai.utilities.events.crewai_event_bus import crewai_event_bus from crewai.utilities.llm_utils import create_llm from crewai.utilities.token_counter_callback import TokenCalcHandler from crewai.utilities.training_handler import CrewTrainingHandler -agentops = None -try: - import agentops # type: ignore # Name "agentops" is already defined - from agentops import track_agent # type: ignore -except ImportError: - - def track_agent(): - def noop(f): - return f - - return noop - - -@track_agent() class Agent(BaseAgent): """Represents an agent in a system. @@ -240,6 +232,15 @@ class Agent(BaseAgent): task_prompt = self._use_trained_data(task_prompt=task_prompt) try: + crewai_event_bus.emit( + self, + event=AgentExecutionStartedEvent( + agent=self, + tools=self.tools, + task_prompt=task_prompt, + task=task, + ), + ) result = self.agent_executor.invoke( { "input": task_prompt, @@ -251,9 +252,25 @@ class Agent(BaseAgent): except Exception as e: if e.__class__.__module__.startswith("litellm"): # Do not retry on litellm errors + crewai_event_bus.emit( + self, + event=AgentExecutionErrorEvent( + agent=self, + task=task, + error=str(e), + ), + ) raise e self._times_executed += 1 if self._times_executed > self.max_retry_limit: + crewai_event_bus.emit( + self, + event=AgentExecutionErrorEvent( + agent=self, + task=task, + error=str(e), + ), + ) raise e result = self.execute_task(task, context, tools) @@ -266,7 +283,10 @@ class Agent(BaseAgent): for tool_result in self.tools_results: # type: ignore # Item "None" of "list[Any] | None" has no attribute "__iter__" (not iterable) if tool_result.get("result_as_answer", False): result = tool_result["result"] - + crewai_event_bus.emit( + self, + event=AgentExecutionCompletedEvent(agent=self, task=task, output=result), + ) return result def create_agent_executor( diff --git a/src/crewai/agents/agent_builder/base_agent.py b/src/crewai/agents/agent_builder/base_agent.py index e602e42a9..64110c2ae 100644 --- a/src/crewai/agents/agent_builder/base_agent.py +++ b/src/crewai/agents/agent_builder/base_agent.py @@ -20,8 +20,7 @@ from crewai.agents.cache.cache_handler import CacheHandler from crewai.agents.tools_handler import ToolsHandler from crewai.knowledge.knowledge import Knowledge from crewai.knowledge.source.base_knowledge_source import BaseKnowledgeSource -from crewai.tools import BaseTool -from crewai.tools.base_tool import Tool +from crewai.tools.base_tool import BaseTool, Tool from crewai.utilities import I18N, Logger, RPMController from crewai.utilities.config import process_config from crewai.utilities.converter import Converter @@ -112,7 +111,7 @@ class BaseAgent(ABC, BaseModel): default=False, description="Enable agent to delegate and ask questions among each other.", ) - tools: Optional[List[Any]] = Field( + tools: Optional[List[BaseTool]] = Field( default_factory=list, description="Tools at agents' disposal" ) max_iter: int = Field( diff --git a/src/crewai/agents/crew_agent_executor.py b/src/crewai/agents/crew_agent_executor.py index ed89008fd..6d34fea4e 100644 --- a/src/crewai/agents/crew_agent_executor.py +++ b/src/crewai/agents/crew_agent_executor.py @@ -18,6 +18,12 @@ from crewai.tools.base_tool import BaseTool from crewai.tools.tool_usage import ToolUsage, ToolUsageErrorException from crewai.utilities import I18N, Printer from crewai.utilities.constants import MAX_LLM_RETRY, TRAINING_DATA_FILE +from crewai.utilities.events import ( + ToolUsageErrorEvent, + ToolUsageStartedEvent, + crewai_event_bus, +) +from crewai.utilities.events.tool_usage_events import ToolUsageStartedEvent from crewai.utilities.exceptions.context_window_exceeding_exception import ( LLMContextLengthExceededException, ) @@ -107,11 +113,11 @@ class CrewAgentExecutor(CrewAgentExecutorMixin): ) raise except Exception as e: + self._handle_unknown_error(e) if e.__class__.__module__.startswith("litellm"): # Do not retry on litellm errors raise e else: - self._handle_unknown_error(e) raise e if self.ask_for_human_input: @@ -349,40 +355,68 @@ class CrewAgentExecutor(CrewAgentExecutorMixin): ) def _execute_tool_and_check_finality(self, agent_action: AgentAction) -> ToolResult: - tool_usage = ToolUsage( - tools_handler=self.tools_handler, - tools=self.tools, - original_tools=self.original_tools, - tools_description=self.tools_description, - tools_names=self.tools_names, - function_calling_llm=self.function_calling_llm, - task=self.task, # type: ignore[arg-type] - agent=self.agent, - action=agent_action, - ) - tool_calling = tool_usage.parse_tool_calling(agent_action.text) - - if isinstance(tool_calling, ToolUsageErrorException): - tool_result = tool_calling.message - return ToolResult(result=tool_result, result_as_answer=False) - else: - if tool_calling.tool_name.casefold().strip() in [ - name.casefold().strip() for name in self.tool_name_to_tool_map - ] or tool_calling.tool_name.casefold().replace("_", " ") in [ - name.casefold().strip() for name in self.tool_name_to_tool_map - ]: - tool_result = tool_usage.use(tool_calling, agent_action.text) - tool = self.tool_name_to_tool_map.get(tool_calling.tool_name) - if tool: - return ToolResult( - result=tool_result, result_as_answer=tool.result_as_answer - ) - else: - tool_result = self._i18n.errors("wrong_tool_name").format( - tool=tool_calling.tool_name, - tools=", ".join([tool.name.casefold() for tool in self.tools]), + try: + if self.agent: + crewai_event_bus.emit( + self, + event=ToolUsageStartedEvent( + agent_key=self.agent.key, + agent_role=self.agent.role, + tool_name=agent_action.tool, + tool_args=agent_action.tool_input, + tool_class=agent_action.tool, + ), ) - return ToolResult(result=tool_result, result_as_answer=False) + tool_usage = ToolUsage( + tools_handler=self.tools_handler, + tools=self.tools, + original_tools=self.original_tools, + tools_description=self.tools_description, + tools_names=self.tools_names, + function_calling_llm=self.function_calling_llm, + task=self.task, # type: ignore[arg-type] + agent=self.agent, + action=agent_action, + ) + tool_calling = tool_usage.parse_tool_calling(agent_action.text) + + if isinstance(tool_calling, ToolUsageErrorException): + tool_result = tool_calling.message + return ToolResult(result=tool_result, result_as_answer=False) + else: + if tool_calling.tool_name.casefold().strip() in [ + name.casefold().strip() for name in self.tool_name_to_tool_map + ] or tool_calling.tool_name.casefold().replace("_", " ") in [ + name.casefold().strip() for name in self.tool_name_to_tool_map + ]: + tool_result = tool_usage.use(tool_calling, agent_action.text) + tool = self.tool_name_to_tool_map.get(tool_calling.tool_name) + if tool: + return ToolResult( + result=tool_result, result_as_answer=tool.result_as_answer + ) + else: + tool_result = self._i18n.errors("wrong_tool_name").format( + tool=tool_calling.tool_name, + tools=", ".join([tool.name.casefold() for tool in self.tools]), + ) + return ToolResult(result=tool_result, result_as_answer=False) + + except Exception as e: + # TODO: drop + if self.agent: + crewai_event_bus.emit( + self, + event=ToolUsageErrorEvent( # validation error + agent_key=self.agent.key, + agent_role=self.agent.role, + tool_name=agent_action.tool, + tool_args=agent_action.tool_input, + tool_class=agent_action.tool, + error=str(e), + ), + ) + raise e def _summarize_messages(self) -> None: messages_groups = [] diff --git a/src/crewai/crew.py b/src/crewai/crew.py index d331599b5..31678ae88 100644 --- a/src/crewai/crew.py +++ b/src/crewai/crew.py @@ -38,11 +38,24 @@ from crewai.tasks.task_output import TaskOutput from crewai.telemetry import Telemetry from crewai.tools.agent_tools.agent_tools import AgentTools from crewai.tools.base_tool import Tool +from crewai.traces.unified_trace_controller import init_crew_main_trace from crewai.types.usage_metrics import UsageMetrics from crewai.utilities import I18N, FileHandler, Logger, RPMController from crewai.utilities.constants import TRAINING_DATA_FILE from crewai.utilities.evaluators.crew_evaluator_handler import CrewEvaluator from crewai.utilities.evaluators.task_evaluator import TaskEvaluator +from crewai.utilities.events.crew_events import ( + CrewKickoffCompletedEvent, + CrewKickoffFailedEvent, + CrewKickoffStartedEvent, + CrewTestCompletedEvent, + CrewTestFailedEvent, + CrewTestStartedEvent, + CrewTrainCompletedEvent, + CrewTrainFailedEvent, + CrewTrainStartedEvent, +) +from crewai.utilities.events.crewai_event_bus import crewai_event_bus from crewai.utilities.formatter import ( aggregate_raw_outputs_from_task_outputs, aggregate_raw_outputs_from_tasks, @@ -52,12 +65,6 @@ from crewai.utilities.planning_handler import CrewPlanner from crewai.utilities.task_output_storage_handler import TaskOutputStorageHandler from crewai.utilities.training_handler import CrewTrainingHandler -try: - import agentops # type: ignore -except ImportError: - agentops = None - - warnings.filterwarnings("ignore", category=SyntaxWarning, module="pysbd") @@ -521,10 +528,19 @@ class Crew(BaseModel): self, n_iterations: int, filename: str, inputs: Optional[Dict[str, Any]] = {} ) -> None: """Trains the crew for a given number of iterations.""" - train_crew = self.copy() - train_crew._setup_for_training(filename) - try: + crewai_event_bus.emit( + self, + CrewTrainStartedEvent( + crew_name=self.name or "crew", + n_iterations=n_iterations, + filename=filename, + inputs=inputs, + ), + ) + train_crew = self.copy() + train_crew._setup_for_training(filename) + for n_iteration in range(n_iterations): train_crew._train_iteration = n_iteration train_crew.kickoff(inputs=inputs) @@ -539,70 +555,94 @@ class Crew(BaseModel): CrewTrainingHandler(filename).save_trained_data( agent_id=str(agent.role), trained_data=result.model_dump() ) + + crewai_event_bus.emit( + self, + CrewTrainCompletedEvent( + crew_name=self.name or "crew", + n_iterations=n_iterations, + filename=filename, + ), + ) except Exception as e: + crewai_event_bus.emit( + self, + CrewTrainFailedEvent(error=str(e), crew_name=self.name or "crew"), + ) self._logger.log("error", f"Training failed: {e}", color="red") CrewTrainingHandler(TRAINING_DATA_FILE).clear() CrewTrainingHandler(filename).clear() raise + @init_crew_main_trace def kickoff( self, inputs: Optional[Dict[str, Any]] = None, ) -> CrewOutput: - for before_callback in self.before_kickoff_callbacks: - if inputs is None: - inputs = {} - inputs = before_callback(inputs) + try: + for before_callback in self.before_kickoff_callbacks: + if inputs is None: + inputs = {} + inputs = before_callback(inputs) - """Starts the crew to work on its assigned tasks.""" - self._execution_span = self._telemetry.crew_execution_span(self, inputs) - self._task_output_handler.reset() - self._logging_color = "bold_purple" - - if inputs is not None: - self._inputs = inputs - self._interpolate_inputs(inputs) - self._set_tasks_callbacks() - - i18n = I18N(prompt_file=self.prompt_file) - - for agent in self.agents: - agent.i18n = i18n - # type: ignore[attr-defined] # Argument 1 to "_interpolate_inputs" of "Crew" has incompatible type "dict[str, Any] | None"; expected "dict[str, Any]" - agent.crew = self # type: ignore[attr-defined] - # TODO: Create an AgentFunctionCalling protocol for future refactoring - if not agent.function_calling_llm: # type: ignore # "BaseAgent" has no attribute "function_calling_llm" - agent.function_calling_llm = self.function_calling_llm # type: ignore # "BaseAgent" has no attribute "function_calling_llm" - - if not agent.step_callback: # type: ignore # "BaseAgent" has no attribute "step_callback" - agent.step_callback = self.step_callback # type: ignore # "BaseAgent" has no attribute "step_callback" - - agent.create_agent_executor() - - if self.planning: - self._handle_crew_planning() - - metrics: List[UsageMetrics] = [] - - if self.process == Process.sequential: - result = self._run_sequential_process() - elif self.process == Process.hierarchical: - result = self._run_hierarchical_process() - else: - raise NotImplementedError( - f"The process '{self.process}' is not implemented yet." + crewai_event_bus.emit( + self, + CrewKickoffStartedEvent(crew_name=self.name or "crew", inputs=inputs), ) - for after_callback in self.after_kickoff_callbacks: - result = after_callback(result) + # Starts the crew to work on its assigned tasks. + self._task_output_handler.reset() + self._logging_color = "bold_purple" - metrics += [agent._token_process.get_summary() for agent in self.agents] + if inputs is not None: + self._inputs = inputs + self._interpolate_inputs(inputs) + self._set_tasks_callbacks() - self.usage_metrics = UsageMetrics() - for metric in metrics: - self.usage_metrics.add_usage_metrics(metric) + i18n = I18N(prompt_file=self.prompt_file) - return result + for agent in self.agents: + agent.i18n = i18n + # type: ignore[attr-defined] # Argument 1 to "_interpolate_inputs" of "Crew" has incompatible type "dict[str, Any] | None"; expected "dict[str, Any]" + agent.crew = self # type: ignore[attr-defined] + # TODO: Create an AgentFunctionCalling protocol for future refactoring + if not agent.function_calling_llm: # type: ignore # "BaseAgent" has no attribute "function_calling_llm" + agent.function_calling_llm = self.function_calling_llm # type: ignore # "BaseAgent" has no attribute "function_calling_llm" + + if not agent.step_callback: # type: ignore # "BaseAgent" has no attribute "step_callback" + agent.step_callback = self.step_callback # type: ignore # "BaseAgent" has no attribute "step_callback" + + agent.create_agent_executor() + + if self.planning: + self._handle_crew_planning() + + metrics: List[UsageMetrics] = [] + + if self.process == Process.sequential: + result = self._run_sequential_process() + elif self.process == Process.hierarchical: + result = self._run_hierarchical_process() + else: + raise NotImplementedError( + f"The process '{self.process}' is not implemented yet." + ) + + for after_callback in self.after_kickoff_callbacks: + result = after_callback(result) + + metrics += [agent._token_process.get_summary() for agent in self.agents] + + self.usage_metrics = UsageMetrics() + for metric in metrics: + self.usage_metrics.add_usage_metrics(metric) + return result + except Exception as e: + crewai_event_bus.emit( + self, + CrewKickoffFailedEvent(error=str(e), crew_name=self.name or "crew"), + ) + raise def kickoff_for_each(self, inputs: List[Dict[str, Any]]) -> List[CrewOutput]: """Executes the Crew's workflow for each input in the list and aggregates results.""" @@ -950,7 +990,12 @@ class Crew(BaseModel): final_string_output = final_task_output.raw self._finish_execution(final_string_output) token_usage = self.calculate_usage_metrics() - + crewai_event_bus.emit( + self, + CrewKickoffCompletedEvent( + crew_name=self.name or "crew", output=final_task_output + ), + ) return CrewOutput( raw=final_task_output.raw, pydantic=final_task_output.pydantic, @@ -1136,13 +1181,6 @@ class Crew(BaseModel): def _finish_execution(self, final_string_output: str) -> None: if self.max_rpm: self._rpm_controller.stop_rpm_counter() - if agentops: - agentops.end_session( - end_state="Success", - end_state_reason="Finished Execution", - is_auto_end=True, - ) - self._telemetry.end_crew(self, final_string_output) def calculate_usage_metrics(self) -> UsageMetrics: """Calculates and returns the usage metrics.""" @@ -1164,26 +1202,41 @@ class Crew(BaseModel): inputs: Optional[Dict[str, Any]] = None, ) -> None: """Test and evaluate the Crew with the given inputs for n iterations concurrently using concurrent.futures.""" - test_crew = self.copy() + try: + eval_llm = create_llm(eval_llm) + if not eval_llm: + raise ValueError("Failed to create LLM instance.") - eval_llm = create_llm(eval_llm) + crewai_event_bus.emit( + self, + CrewTestStartedEvent( + crew_name=self.name or "crew", + n_iterations=n_iterations, + eval_llm=eval_llm, + inputs=inputs, + ), + ) + test_crew = self.copy() + evaluator = CrewEvaluator(test_crew, eval_llm) # type: ignore[arg-type] - if not eval_llm: - raise ValueError("Failed to create LLM instance.") + for i in range(1, n_iterations + 1): + evaluator.set_iteration(i) + test_crew.kickoff(inputs=inputs) - self._test_execution_span = test_crew._telemetry.test_execution_span( - test_crew, - n_iterations, - inputs, - eval_llm.model, # type: ignore[arg-type] - ) # type: ignore[arg-type] - evaluator = CrewEvaluator(test_crew, eval_llm) # type: ignore[arg-type] + evaluator.print_crew_evaluation_result() - for i in range(1, n_iterations + 1): - evaluator.set_iteration(i) - test_crew.kickoff(inputs=inputs) - - evaluator.print_crew_evaluation_result() + crewai_event_bus.emit( + self, + CrewTestCompletedEvent( + crew_name=self.name or "crew", + ), + ) + except Exception as e: + crewai_event_bus.emit( + self, + CrewTestFailedEvent(error=str(e), crew_name=self.name or "crew"), + ) + raise def __repr__(self): return f"Crew(id={self.id}, process={self.process}, number_of_agents={len(self.agents)}, number_of_tasks={len(self.tasks)})" diff --git a/src/crewai/flow/flow.py b/src/crewai/flow/flow.py index f1242a2bf..2babbe57c 100644 --- a/src/crewai/flow/flow.py +++ b/src/crewai/flow/flow.py @@ -17,19 +17,25 @@ from typing import ( ) from uuid import uuid4 -from blinker import Signal from pydantic import BaseModel, Field, ValidationError -from crewai.flow.flow_events import ( - FlowFinishedEvent, - FlowStartedEvent, - MethodExecutionFinishedEvent, - MethodExecutionStartedEvent, -) from crewai.flow.flow_visualizer import plot_flow from crewai.flow.persistence.base import FlowPersistence from crewai.flow.utils import get_possible_return_constants -from crewai.telemetry import Telemetry +from crewai.traces.unified_trace_controller import ( + init_flow_main_trace, + trace_flow_step, +) +from crewai.utilities.events.crewai_event_bus import crewai_event_bus +from crewai.utilities.events.flow_events import ( + FlowCreatedEvent, + FlowFinishedEvent, + FlowPlotEvent, + FlowStartedEvent, + MethodExecutionFailedEvent, + MethodExecutionFinishedEvent, + MethodExecutionStartedEvent, +) from crewai.utilities.printer import Printer logger = logging.getLogger(__name__) @@ -427,7 +433,6 @@ class Flow(Generic[T], metaclass=FlowMeta): Type parameter T must be either Dict[str, Any] or a subclass of BaseModel.""" - _telemetry = Telemetry() _printer = Printer() _start_methods: List[str] = [] @@ -435,7 +440,6 @@ class Flow(Generic[T], metaclass=FlowMeta): _routers: Set[str] = set() _router_paths: Dict[str, List[str]] = {} initial_state: Union[Type[T], T, None] = None - event_emitter = Signal("event_emitter") def __class_getitem__(cls: Type["Flow"], item: Type[T]) -> Type["Flow"]: class _FlowGeneric(cls): # type: ignore @@ -469,7 +473,13 @@ class Flow(Generic[T], metaclass=FlowMeta): if kwargs: self._initialize_state(kwargs) - self._telemetry.flow_creation_span(self.__class__.__name__) + crewai_event_bus.emit( + self, + FlowCreatedEvent( + type="flow_created", + flow_name=self.__class__.__name__, + ), + ) # Register all flow-related methods for method_name in dir(self): @@ -738,9 +748,9 @@ class Flow(Generic[T], metaclass=FlowMeta): self._initialize_state(filtered_inputs) # Start flow execution - self.event_emitter.send( + crewai_event_bus.emit( self, - event=FlowStartedEvent( + FlowStartedEvent( type="flow_started", flow_name=self.__class__.__name__, inputs=inputs, @@ -753,16 +763,16 @@ class Flow(Generic[T], metaclass=FlowMeta): if inputs is not None and "id" not in inputs: self._initialize_state(inputs) - return asyncio.run(self.kickoff_async()) + async def run_flow(): + return await self.kickoff_async() + return asyncio.run(run_flow()) + + @init_flow_main_trace async def kickoff_async(self, inputs: Optional[Dict[str, Any]] = None) -> Any: if not self._start_methods: raise ValueError("No start method defined") - self._telemetry.flow_execution_span( - self.__class__.__name__, list(self._methods.keys()) - ) - tasks = [ self._execute_start_method(start_method) for start_method in self._start_methods @@ -771,9 +781,9 @@ class Flow(Generic[T], metaclass=FlowMeta): final_output = self._method_outputs[-1] if self._method_outputs else None - self.event_emitter.send( + crewai_event_bus.emit( self, - event=FlowFinishedEvent( + FlowFinishedEvent( type="flow_finished", flow_name=self.__class__.__name__, result=final_output, @@ -804,43 +814,59 @@ class Flow(Generic[T], metaclass=FlowMeta): ) await self._execute_listeners(start_method_name, result) + @trace_flow_step async def _execute_method( self, method_name: str, method: Callable, *args: Any, **kwargs: Any ) -> Any: - dumped_params = {f"_{i}": arg for i, arg in enumerate(args)} | (kwargs or {}) - self.event_emitter.send( - self, - event=MethodExecutionStartedEvent( - type="method_execution_started", - method_name=method_name, - flow_name=self.__class__.__name__, - params=dumped_params, - state=self._copy_state(), - ), - ) + try: + dumped_params = {f"_{i}": arg for i, arg in enumerate(args)} | ( + kwargs or {} + ) + crewai_event_bus.emit( + self, + MethodExecutionStartedEvent( + type="method_execution_started", + method_name=method_name, + flow_name=self.__class__.__name__, + params=dumped_params, + state=self._copy_state(), + ), + ) - result = ( - await method(*args, **kwargs) - if asyncio.iscoroutinefunction(method) - else method(*args, **kwargs) - ) - self._method_outputs.append(result) - self._method_execution_counts[method_name] = ( - self._method_execution_counts.get(method_name, 0) + 1 - ) + result = ( + await method(*args, **kwargs) + if asyncio.iscoroutinefunction(method) + else method(*args, **kwargs) + ) - self.event_emitter.send( - self, - event=MethodExecutionFinishedEvent( - type="method_execution_finished", - method_name=method_name, - flow_name=self.__class__.__name__, - state=self._copy_state(), - result=result, - ), - ) + self._method_outputs.append(result) + self._method_execution_counts[method_name] = ( + self._method_execution_counts.get(method_name, 0) + 1 + ) - return result + crewai_event_bus.emit( + self, + MethodExecutionFinishedEvent( + type="method_execution_finished", + method_name=method_name, + flow_name=self.__class__.__name__, + state=self._copy_state(), + result=result, + ), + ) + + return result + except Exception as e: + crewai_event_bus.emit( + self, + MethodExecutionFailedEvent( + type="method_execution_failed", + method_name=method_name, + flow_name=self.__class__.__name__, + error=e, + ), + ) + raise e async def _execute_listeners(self, trigger_method: str, result: Any) -> None: """ @@ -978,6 +1004,7 @@ class Flow(Generic[T], metaclass=FlowMeta): """ try: method = self._methods[listener_name] + sig = inspect.signature(method) params = list(sig.parameters.values()) method_params = [p for p in params if p.name != "self"] @@ -1027,7 +1054,11 @@ class Flow(Generic[T], metaclass=FlowMeta): logger.warning(message) def plot(self, filename: str = "crewai_flow") -> None: - self._telemetry.flow_plotting_span( - self.__class__.__name__, list(self._methods.keys()) + crewai_event_bus.emit( + self, + FlowPlotEvent( + type="flow_plot", + flow_name=self.__class__.__name__, + ), ) plot_flow(self, filename) diff --git a/src/crewai/flow/flow_events.py b/src/crewai/flow/flow_events.py deleted file mode 100644 index c8f9e9694..000000000 --- a/src/crewai/flow/flow_events.py +++ /dev/null @@ -1,39 +0,0 @@ -from dataclasses import dataclass, field -from datetime import datetime -from typing import Any, Dict, Optional, Union - -from pydantic import BaseModel - - -@dataclass -class Event: - type: str - flow_name: str - timestamp: datetime = field(init=False) - - def __post_init__(self): - self.timestamp = datetime.now() - - -@dataclass -class FlowStartedEvent(Event): - inputs: Optional[Dict[str, Any]] = None - - -@dataclass -class MethodExecutionStartedEvent(Event): - method_name: str - state: Union[Dict[str, Any], BaseModel] - params: Optional[Dict[str, Any]] = None - - -@dataclass -class MethodExecutionFinishedEvent(Event): - method_name: str - state: Union[Dict[str, Any], BaseModel] - result: Any = None - - -@dataclass -class FlowFinishedEvent(Event): - result: Optional[Any] = None diff --git a/src/crewai/flow/persistence/decorators.py b/src/crewai/flow/persistence/decorators.py index ebf3778b7..7b3bd447c 100644 --- a/src/crewai/flow/persistence/decorators.py +++ b/src/crewai/flow/persistence/decorators.py @@ -58,7 +58,7 @@ class PersistenceDecorator: _printer = Printer() # Class-level printer instance @classmethod - def persist_state(cls, flow_instance: Any, method_name: str, persistence_instance: FlowPersistence) -> None: + def persist_state(cls, flow_instance: Any, method_name: str, persistence_instance: FlowPersistence, verbose: bool = False) -> None: """Persist flow state with proper error handling and logging. This method handles the persistence of flow state data, including proper @@ -68,6 +68,7 @@ class PersistenceDecorator: flow_instance: The flow instance whose state to persist method_name: Name of the method that triggered persistence persistence_instance: The persistence backend to use + verbose: Whether to log persistence operations Raises: ValueError: If flow has no state or state lacks an ID @@ -88,9 +89,10 @@ class PersistenceDecorator: if not flow_uuid: raise ValueError("Flow state must have an 'id' field for persistence") - # Log state saving with consistent message - cls._printer.print(LOG_MESSAGES["save_state"].format(flow_uuid), color="cyan") - logger.info(LOG_MESSAGES["save_state"].format(flow_uuid)) + # Log state saving only if verbose is True + if verbose: + cls._printer.print(LOG_MESSAGES["save_state"].format(flow_uuid), color="cyan") + logger.info(LOG_MESSAGES["save_state"].format(flow_uuid)) try: persistence_instance.save_state( @@ -115,7 +117,7 @@ class PersistenceDecorator: raise ValueError(error_msg) from e -def persist(persistence: Optional[FlowPersistence] = None): +def persist(persistence: Optional[FlowPersistence] = None, verbose: bool = False): """Decorator to persist flow state. This decorator can be applied at either the class level or method level. @@ -126,6 +128,7 @@ def persist(persistence: Optional[FlowPersistence] = None): Args: persistence: Optional FlowPersistence implementation to use. If not provided, uses SQLiteFlowPersistence. + verbose: Whether to log persistence operations. Defaults to False. Returns: A decorator that can be applied to either a class or method @@ -135,13 +138,12 @@ def persist(persistence: Optional[FlowPersistence] = None): RuntimeError: If state persistence fails Example: - @persist # Class-level persistence with default SQLite + @persist(verbose=True) # Class-level persistence with logging class MyFlow(Flow[MyState]): @start() def begin(self): pass """ - def decorator(target: Union[Type, Callable[..., T]]) -> Union[Type, Callable[..., T]]: """Decorator that handles both class and method decoration.""" actual_persistence = persistence or SQLiteFlowPersistence() @@ -179,7 +181,7 @@ def persist(persistence: Optional[FlowPersistence] = None): @functools.wraps(original_method) async def method_wrapper(self: Any, *args: Any, **kwargs: Any) -> Any: result = await original_method(self, *args, **kwargs) - PersistenceDecorator.persist_state(self, method_name, actual_persistence) + PersistenceDecorator.persist_state(self, method_name, actual_persistence, verbose) return result return method_wrapper @@ -199,7 +201,7 @@ def persist(persistence: Optional[FlowPersistence] = None): @functools.wraps(original_method) def method_wrapper(self: Any, *args: Any, **kwargs: Any) -> Any: result = original_method(self, *args, **kwargs) - PersistenceDecorator.persist_state(self, method_name, actual_persistence) + PersistenceDecorator.persist_state(self, method_name, actual_persistence, verbose) return result return method_wrapper @@ -228,7 +230,7 @@ def persist(persistence: Optional[FlowPersistence] = None): result = await method_coro else: result = method_coro - PersistenceDecorator.persist_state(flow_instance, method.__name__, actual_persistence) + PersistenceDecorator.persist_state(flow_instance, method.__name__, actual_persistence, verbose) return result for attr in ["__is_start_method__", "__trigger_methods__", "__condition_type__", "__is_router__"]: @@ -240,7 +242,7 @@ def persist(persistence: Optional[FlowPersistence] = None): @functools.wraps(method) def method_sync_wrapper(flow_instance: Any, *args: Any, **kwargs: Any) -> T: result = method(flow_instance, *args, **kwargs) - PersistenceDecorator.persist_state(flow_instance, method.__name__, actual_persistence) + PersistenceDecorator.persist_state(flow_instance, method.__name__, actual_persistence, verbose) return result for attr in ["__is_start_method__", "__trigger_methods__", "__condition_type__", "__is_router__"]: diff --git a/src/crewai/flow/state_utils.py b/src/crewai/flow/state_utils.py index 40bc81162..eaf0f21ce 100644 --- a/src/crewai/flow/state_utils.py +++ b/src/crewai/flow/state_utils.py @@ -1,12 +1,18 @@ +import json from datetime import date, datetime -from typing import Any +from typing import Any, Dict, List, Union from pydantic import BaseModel from crewai.flow import Flow +SerializablePrimitive = Union[str, int, float, bool, None] +Serializable = Union[ + SerializablePrimitive, List["Serializable"], Dict[str, "Serializable"] +] -def export_state(flow: Flow) -> dict[str, Any]: + +def export_state(flow: Flow) -> dict[str, Serializable]: """Exports the Flow's internal state as JSON-compatible data structures. Performs a one-way transformation of a Flow's state into basic Python types @@ -20,10 +26,27 @@ def export_state(flow: Flow) -> dict[str, Any]: dict[str, Any]: The transformed state using JSON-compatible Python types. """ - return _to_serializable(flow._state) + result = to_serializable(flow._state) + assert isinstance(result, dict) + return result -def _to_serializable(obj: Any, max_depth: int = 5, _current_depth: int = 0) -> Any: +def to_serializable( + obj: Any, max_depth: int = 5, _current_depth: int = 0 +) -> Serializable: + """Converts a Python object into a JSON-compatible representation. + + Supports primitives, datetime objects, collections, dictionaries, and + Pydantic models. Recursion depth is limited to prevent infinite nesting. + Non-convertible objects default to their string representations. + + Args: + obj (Any): Object to transform. + max_depth (int, optional): Maximum recursion depth. Defaults to 5. + + Returns: + Serializable: A JSON-compatible structure. + """ if _current_depth >= max_depth: return repr(obj) @@ -32,16 +55,16 @@ def _to_serializable(obj: Any, max_depth: int = 5, _current_depth: int = 0) -> A elif isinstance(obj, (date, datetime)): return obj.isoformat() elif isinstance(obj, (list, tuple, set)): - return [_to_serializable(item, max_depth, _current_depth + 1) for item in obj] + return [to_serializable(item, max_depth, _current_depth + 1) for item in obj] elif isinstance(obj, dict): return { - _to_serializable_key(key): _to_serializable( + _to_serializable_key(key): to_serializable( value, max_depth, _current_depth + 1 ) for key, value in obj.items() } elif isinstance(obj, BaseModel): - return _to_serializable(obj.model_dump(), max_depth, _current_depth + 1) + return to_serializable(obj.model_dump(), max_depth, _current_depth + 1) else: return repr(obj) @@ -50,3 +73,19 @@ def _to_serializable_key(key: Any) -> str: if isinstance(key, (str, int)): return str(key) return f"key_{id(key)}_{repr(key)}" + + +def to_string(obj: Any) -> str | None: + """Serializes an object into a JSON string. + + Args: + obj (Any): Object to serialize. + + Returns: + str | None: A JSON-formatted string or `None` if empty. + """ + serializable = to_serializable(obj) + if serializable is None: + return None + else: + return json.dumps(serializable) diff --git a/src/crewai/knowledge/storage/knowledge_storage.py b/src/crewai/knowledge/storage/knowledge_storage.py index 9e6ab8041..72240e2b6 100644 --- a/src/crewai/knowledge/storage/knowledge_storage.py +++ b/src/crewai/knowledge/storage/knowledge_storage.py @@ -76,7 +76,7 @@ class KnowledgeStorage(BaseKnowledgeStorage): "context": fetched["documents"][0][i], # type: ignore "score": fetched["distances"][0][i], # type: ignore } - if result["score"] >= score_threshold: # type: ignore + if result["score"] >= score_threshold: results.append(result) return results else: diff --git a/src/crewai/llm.py b/src/crewai/llm.py index e9376a16e..08f31f0fb 100644 --- a/src/crewai/llm.py +++ b/src/crewai/llm.py @@ -1,3 +1,4 @@ +import inspect import json import logging import os @@ -5,11 +6,23 @@ import sys import threading import warnings from contextlib import contextmanager -from typing import Any, Dict, List, Literal, Optional, Type, Union, cast +from typing import ( + Any, + Dict, + List, + Literal, + Optional, + Tuple, + Type, + Union, + cast, +) from dotenv import load_dotenv from pydantic import BaseModel +from crewai.utilities.events.tool_usage_events import ToolExecutionErrorEvent + with warnings.catch_warnings(): warnings.simplefilter("ignore", UserWarning) import litellm @@ -18,9 +31,12 @@ with warnings.catch_warnings(): from litellm.utils import supports_response_schema +from crewai.traces.unified_trace_controller import trace_llm_call +from crewai.utilities.events import crewai_event_bus from crewai.utilities.exceptions.context_window_exceeding_exception import ( LLMContextLengthExceededException, ) +from crewai.utilities.protocols import AgentExecutorProtocol load_dotenv() @@ -164,6 +180,7 @@ class LLM: self.context_window_size = 0 self.reasoning_effort = reasoning_effort self.additional_params = kwargs + self._message_history: List[Dict[str, str]] = [] self.is_anthropic = self._is_anthropic_model(model) litellm.drop_params = True @@ -179,6 +196,12 @@ class LLM: self.set_callbacks(callbacks) self.set_env_callbacks() + @trace_llm_call + def _call_llm(self, params: Dict[str, Any]) -> Any: + with suppress_warnings(): + response = litellm.completion(**params) + return response + def _is_anthropic_model(self, model: str) -> bool: """Determine if the model is from Anthropic provider. @@ -288,7 +311,7 @@ class LLM: params = {k: v for k, v in params.items() if v is not None} # --- 2) Make the completion call - response = litellm.completion(**params) + response = self._call_llm(params) response_message = cast(Choices, cast(ModelResponse, response).choices)[ 0 ].message @@ -315,7 +338,7 @@ class LLM: # --- 5) Handle the tool call tool_call = tool_calls[0] function_name = tool_call.function.name - + print("function_name", function_name) if function_name in available_functions: try: function_args = json.loads(tool_call.function.arguments) @@ -333,6 +356,15 @@ class LLM: logging.error( f"Error executing function '{function_name}': {e}" ) + crewai_event_bus.emit( + self, + event=ToolExecutionErrorEvent( + tool_name=function_name, + tool_args=function_args, + tool_class=fn, + error=str(e), + ), + ) return text_response else: @@ -499,3 +531,95 @@ class LLM: litellm.success_callback = success_callbacks litellm.failure_callback = failure_callbacks + + def _get_execution_context(self) -> Tuple[Optional[Any], Optional[Any]]: + """Get the agent and task from the execution context. + + Returns: + tuple: (agent, task) from any AgentExecutor context, or (None, None) if not found + """ + frame = inspect.currentframe() + caller_frame = frame.f_back if frame else None + agent = None + task = None + + # Add a maximum depth to prevent infinite loops + max_depth = 100 # Reasonable limit for call stack depth + current_depth = 0 + + while caller_frame and current_depth < max_depth: + if "self" in caller_frame.f_locals: + caller_self = caller_frame.f_locals["self"] + if isinstance(caller_self, AgentExecutorProtocol): + agent = caller_self.agent + task = caller_self.task + break + caller_frame = caller_frame.f_back + current_depth += 1 + + return agent, task + + def _get_new_messages(self, messages: List[Dict[str, str]]) -> List[Dict[str, str]]: + """Get only the new messages that haven't been processed before.""" + if not hasattr(self, "_message_history"): + self._message_history = [] + + new_messages = [] + for message in messages: + message_key = (message["role"], message["content"]) + if message_key not in [ + (m["role"], m["content"]) for m in self._message_history + ]: + new_messages.append(message) + self._message_history.append(message) + return new_messages + + def _get_new_tool_results(self, agent) -> List[Dict]: + """Get only the new tool results that haven't been processed before.""" + if not agent or not agent.tools_results: + return [] + + if not hasattr(self, "_tool_results_history"): + self._tool_results_history: List[Dict] = [] + + new_tool_results = [] + + for result in agent.tools_results: + # Process tool arguments to extract actual values + processed_args = {} + if isinstance(result["tool_args"], dict): + for key, value in result["tool_args"].items(): + if isinstance(value, dict) and "type" in value: + # Skip metadata and just store the actual value + continue + processed_args[key] = value + + # Create a clean result with processed arguments + clean_result = { + "tool_name": result["tool_name"], + "tool_args": processed_args, + "result": result["result"], + "content": result.get("content", ""), + "start_time": result.get("start_time", ""), + } + + # Check if this exact tool execution exists in history + is_duplicate = False + for history_result in self._tool_results_history: + if ( + clean_result["tool_name"] == history_result["tool_name"] + and str(clean_result["tool_args"]) + == str(history_result["tool_args"]) + and str(clean_result["result"]) == str(history_result["result"]) + and clean_result["content"] == history_result.get("content", "") + and clean_result["start_time"] + == history_result.get("start_time", "") + ): + is_duplicate = True + break + + if not is_duplicate: + new_tool_results.append(clean_result) + self._tool_results_history.append(clean_result) + + return new_tool_results diff --git a/src/crewai/task.py b/src/crewai/task.py index 4088c3fb0..b9e341e33 100644 --- a/src/crewai/task.py +++ b/src/crewai/task.py @@ -21,7 +21,6 @@ from typing import ( Union, ) -from opentelemetry.trace import Span from pydantic import ( UUID4, BaseModel, @@ -36,10 +35,15 @@ from crewai.agents.agent_builder.base_agent import BaseAgent from crewai.tasks.guardrail_result import GuardrailResult from crewai.tasks.output_format import OutputFormat from crewai.tasks.task_output import TaskOutput -from crewai.telemetry.telemetry import Telemetry 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.events import ( + TaskCompletedEvent, + TaskFailedEvent, + TaskStartedEvent, +) +from crewai.utilities.events.crewai_event_bus import crewai_event_bus from crewai.utilities.i18n import I18N from crewai.utilities.printer import Printer @@ -183,8 +187,6 @@ class Task(BaseModel): ) return v - _telemetry: Telemetry = PrivateAttr(default_factory=Telemetry) - _execution_span: Optional[Span] = PrivateAttr(default=None) _original_description: Optional[str] = PrivateAttr(default=None) _original_expected_output: Optional[str] = PrivateAttr(default=None) _original_output_file: Optional[str] = PrivateAttr(default=None) @@ -348,100 +350,102 @@ class Task(BaseModel): tools: Optional[List[Any]], ) -> TaskOutput: """Run the core execution logic of the task.""" - agent = agent or self.agent - self.agent = agent - if not agent: - raise Exception( - f"The task '{self.description}' has no agent assigned, therefore it can't be executed directly and should be executed in a Crew using a specific process that support that, like hierarchical." + try: + agent = agent or self.agent + self.agent = agent + if not agent: + raise Exception( + f"The task '{self.description}' has no agent assigned, therefore it can't be executed directly and should be executed in a Crew using a specific process that support that, like hierarchical." + ) + + self.start_time = datetime.datetime.now() + + self.prompt_context = context + tools = tools or self.tools or [] + + self.processed_by_agents.add(agent.role) + crewai_event_bus.emit(self, TaskStartedEvent(context=context)) + result = agent.execute_task( + task=self, + context=context, + tools=tools, ) - self.start_time = datetime.datetime.now() - self._execution_span = self._telemetry.task_started(crew=agent.crew, task=self) + pydantic_output, json_output = self._export_output(result) + task_output = TaskOutput( + name=self.name, + description=self.description, + expected_output=self.expected_output, + raw=result, + pydantic=pydantic_output, + json_dict=json_output, + agent=agent.role, + output_format=self._get_output_format(), + ) - self.prompt_context = context - tools = tools or self.tools or [] + if self.guardrail: + guardrail_result = GuardrailResult.from_tuple( + self.guardrail(task_output) + ) + if not guardrail_result.success: + if self.retry_count >= self.max_retries: + raise Exception( + f"Task failed guardrail validation after {self.max_retries} retries. " + f"Last error: {guardrail_result.error}" + ) - self.processed_by_agents.add(agent.role) + self.retry_count += 1 + context = self.i18n.errors("validation_error").format( + 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) - result = agent.execute_task( - task=self, - context=context, - tools=tools, - ) - - pydantic_output, json_output = self._export_output(result) - task_output = TaskOutput( - name=self.name, - description=self.description, - expected_output=self.expected_output, - raw=result, - pydantic=pydantic_output, - json_dict=json_output, - agent=agent.role, - output_format=self._get_output_format(), - ) - - if self.guardrail: - guardrail_result = GuardrailResult.from_tuple(self.guardrail(task_output)) - if not guardrail_result.success: - if self.retry_count >= self.max_retries: + if guardrail_result.result is None: raise Exception( - f"Task failed guardrail validation after {self.max_retries} retries. " - f"Last error: {guardrail_result.error}" + "Task guardrail returned None as result. This is not allowed." ) - self.retry_count += 1 - context = self.i18n.errors("validation_error").format( - guardrail_result_error=guardrail_result.error, - task_output=task_output.raw, + if isinstance(guardrail_result.result, str): + task_output.raw = guardrail_result.result + pydantic_output, json_output = self._export_output( + guardrail_result.result + ) + task_output.pydantic = pydantic_output + task_output.json_dict = json_output + elif isinstance(guardrail_result.result, TaskOutput): + task_output = guardrail_result.result + + self.output = task_output + self.end_time = datetime.datetime.now() + + if self.callback: + self.callback(self.output) + + crew = self.agent.crew # type: ignore[union-attr] + if crew and crew.task_callback and crew.task_callback != self.callback: + crew.task_callback(self.output) + + if self.output_file: + content = ( + json_output + if json_output + else pydantic_output.model_dump_json() + if pydantic_output + else result ) - 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: - raise Exception( - "Task guardrail returned None as result. This is not allowed." - ) - - if isinstance(guardrail_result.result, str): - task_output.raw = guardrail_result.result - pydantic_output, json_output = self._export_output( - guardrail_result.result - ) - task_output.pydantic = pydantic_output - task_output.json_dict = json_output - elif isinstance(guardrail_result.result, TaskOutput): - task_output = guardrail_result.result - - self.output = task_output - self.end_time = datetime.datetime.now() - - if self.callback: - self.callback(self.output) - - crew = self.agent.crew # type: ignore[union-attr] - if crew and crew.task_callback and crew.task_callback != self.callback: - crew.task_callback(self.output) - - if self._execution_span: - self._telemetry.task_ended(self._execution_span, self, agent.crew) - self._execution_span = None - - if self.output_file: - content = ( - json_output - if json_output - else pydantic_output.model_dump_json() - if pydantic_output - else result - ) - self._save_file(content) - - return task_output + self._save_file(content) + crewai_event_bus.emit(self, TaskCompletedEvent(output=task_output)) + return task_output + except Exception as e: + self.end_time = datetime.datetime.now() + crewai_event_bus.emit(self, TaskFailedEvent(error=str(e))) + raise e # Re-raise the exception after emitting the event def prompt(self) -> str: """Prompt the task. @@ -716,10 +720,9 @@ class Task(BaseModel): file.write(str(result)) except (OSError, IOError) as e: raise RuntimeError( - "\n".join([ - f"Failed to save output file: {e}", - FILEWRITER_RECOMMENDATION - ]) + "\n".join( + [f"Failed to save output file: {e}", FILEWRITER_RECOMMENDATION] + ) ) return None diff --git a/src/crewai/tools/tool_usage.py b/src/crewai/tools/tool_usage.py index 218410ef7..5c9333557 100644 --- a/src/crewai/tools/tool_usage.py +++ b/src/crewai/tools/tool_usage.py @@ -2,6 +2,7 @@ import ast import datetime import json import time +from datetime import UTC from difflib import SequenceMatcher from json import JSONDecodeError from textwrap import dedent @@ -10,20 +11,21 @@ from typing import Any, Dict, List, Optional, Union import json5 from json_repair import repair_json -import crewai.utilities.events as events from crewai.agents.tools_handler import ToolsHandler from crewai.task import Task from crewai.telemetry import Telemetry from crewai.tools import BaseTool from crewai.tools.structured_tool import CrewStructuredTool from crewai.tools.tool_calling import InstructorToolCalling, ToolCalling -from crewai.tools.tool_usage_events import ToolUsageError, ToolUsageFinished from crewai.utilities import I18N, Converter, ConverterError, Printer +from crewai.utilities.events.crewai_event_bus import crewai_event_bus +from crewai.utilities.events.tool_usage_events import ( + ToolSelectionErrorEvent, + ToolUsageErrorEvent, + ToolUsageFinishedEvent, + ToolValidateInputErrorEvent, +) -try: - import agentops # type: ignore -except ImportError: - agentops = None OPENAI_BIGGER_MODELS = [ "gpt-4", "gpt-4o", @@ -116,7 +118,10 @@ class ToolUsage: self._printer.print(content=f"\n\n{error}\n", color="red") return error - if isinstance(tool, CrewStructuredTool) and tool.name == self._i18n.tools("add_image")["name"]: # type: ignore + if ( + isinstance(tool, CrewStructuredTool) + and tool.name == self._i18n.tools("add_image")["name"] # type: ignore + ): try: result = self._use(tool_string=tool_string, tool=tool, calling=calling) return result @@ -136,7 +141,6 @@ class ToolUsage: tool: Any, calling: Union[ToolCalling, InstructorToolCalling], ) -> str: # TODO: Fix this return type - tool_event = agentops.ToolEvent(name=calling.tool_name) if agentops else None # type: ignore if self._check_tool_repeated_usage(calling=calling): # type: ignore # _check_tool_repeated_usage of "ToolUsage" does not return a value (it only ever returns None) try: result = self._i18n.errors("task_repeated_usage").format( @@ -154,6 +158,7 @@ class ToolUsage: self.task.increment_tools_errors() started_at = time.time() + started_at_trace = datetime.datetime.now(UTC) from_cache = False result = None # type: ignore # Incompatible types in assignment (expression has type "None", variable has type "str") @@ -181,7 +186,9 @@ class ToolUsage: if calling.arguments: try: - acceptable_args = tool.args_schema.model_json_schema()["properties"].keys() # type: ignore + acceptable_args = tool.args_schema.model_json_schema()[ + "properties" + ].keys() # type: ignore arguments = { k: v for k, v in calling.arguments.items() @@ -202,7 +209,7 @@ class ToolUsage: error=e, tool=tool.name, tool_inputs=tool.description ) error = ToolUsageErrorException( - f'\n{error_message}.\nMoving on then. {self._i18n.slice("format").format(tool_names=self.tools_names)}' + f"\n{error_message}.\nMoving on then. {self._i18n.slice('format').format(tool_names=self.tools_names)}" ).message self.task.increment_tools_errors() if self.agent.verbose: @@ -212,10 +219,6 @@ class ToolUsage: return error # type: ignore # No return value expected self.task.increment_tools_errors() - if agentops: - agentops.record( - agentops.ErrorEvent(exception=e, trigger_event=tool_event) - ) return self.use(calling=calling, tool_string=tool_string) # type: ignore # No return value expected if self.tools_handler: @@ -231,9 +234,6 @@ class ToolUsage: self.tools_handler.on_tool_use( calling=calling, output=result, should_cache=should_cache ) - - if agentops: - agentops.record(tool_event) self._telemetry.tool_usage( llm=self.function_calling_llm, tool_name=tool.name, @@ -244,6 +244,7 @@ class ToolUsage: "result": result, "tool_name": tool.name, "tool_args": calling.arguments, + "start_time": started_at_trace, } self.on_tool_use_finished( @@ -308,14 +309,33 @@ class ToolUsage: ): return tool self.task.increment_tools_errors() + tool_selection_data = { + "agent_key": self.agent.key, + "agent_role": self.agent.role, + "tool_name": tool_name, + "tool_args": {}, + "tool_class": self.tools_description, + } if tool_name and tool_name != "": - raise Exception( - f"Action '{tool_name}' don't exist, these are the only available Actions:\n{self.tools_description}" + error = f"Action '{tool_name}' don't exist, these are the only available Actions:\n{self.tools_description}" + crewai_event_bus.emit( + self, + ToolSelectionErrorEvent( + **tool_selection_data, + error=error, + ), ) + raise Exception(error) else: - raise Exception( - f"I forgot the Action name, these are the only available Actions: {self.tools_description}" + error = f"I forgot the Action name, these are the only available Actions: {self.tools_description}" + crewai_event_bus.emit( + self, + ToolSelectionErrorEvent( + **tool_selection_data, + error=error, + ), ) + raise Exception(error) def _render(self) -> str: """Render the tool name and description in plain text.""" @@ -368,7 +388,7 @@ class ToolUsage: raise else: return ToolUsageErrorException( - f'{self._i18n.errors("tool_arguments_error")}' + f"{self._i18n.errors('tool_arguments_error')}" ) if not isinstance(arguments, dict): @@ -376,7 +396,7 @@ class ToolUsage: raise else: return ToolUsageErrorException( - f'{self._i18n.errors("tool_arguments_error")}' + f"{self._i18n.errors('tool_arguments_error')}" ) return ToolCalling( @@ -404,7 +424,7 @@ class ToolUsage: if self.agent.verbose: self._printer.print(content=f"\n\n{e}\n", color="red") return ToolUsageErrorException( # type: ignore # Incompatible return value type (got "ToolUsageErrorException", expected "ToolCalling | InstructorToolCalling") - f'{self._i18n.errors("tool_usage_error").format(error=e)}\nMoving on then. {self._i18n.slice("format").format(tool_names=self.tools_names)}' + f"{self._i18n.errors('tool_usage_error').format(error=e)}\nMoving on then. {self._i18n.slice('format').format(tool_names=self.tools_names)}" ) return self._tool_calling(tool_string) @@ -451,18 +471,33 @@ class ToolUsage: if isinstance(arguments, dict): return arguments except Exception as e: - self._printer.print(content=f"Failed to repair JSON: {e}", color="red") + error = f"Failed to repair JSON: {e}" + self._printer.print(content=error, color="red") - # If all parsing attempts fail, raise an error - raise Exception( + error_message = ( "Tool input must be a valid dictionary in JSON or Python literal format" ) + self._emit_validate_input_error(error_message) + # If all parsing attempts fail, raise an error + raise Exception(error_message) + + def _emit_validate_input_error(self, final_error: str): + tool_selection_data = { + "agent_key": self.agent.key, + "agent_role": self.agent.role, + "tool_name": self.action.tool, + "tool_args": str(self.action.tool_input), + "tool_class": self.__class__.__name__, + } + + crewai_event_bus.emit( + self, + ToolValidateInputErrorEvent(**tool_selection_data, error=final_error), + ) def on_tool_error(self, tool: Any, tool_calling: ToolCalling, e: Exception) -> None: event_data = self._prepare_event_data(tool, tool_calling) - events.emit( - source=self, event=ToolUsageError(**{**event_data, "error": str(e)}) - ) + crewai_event_bus.emit(self, ToolUsageErrorEvent(**{**event_data, "error": e})) def on_tool_use_finished( self, tool: Any, tool_calling: ToolCalling, from_cache: bool, started_at: float @@ -476,7 +511,7 @@ class ToolUsage: "from_cache": from_cache, } ) - events.emit(source=self, event=ToolUsageFinished(**event_data)) + crewai_event_bus.emit(self, ToolUsageFinishedEvent(**event_data)) def _prepare_event_data(self, tool: Any, tool_calling: ToolCalling) -> dict: return { diff --git a/src/crewai/tools/tool_usage_events.py b/src/crewai/tools/tool_usage_events.py deleted file mode 100644 index 3c1d16113..000000000 --- a/src/crewai/tools/tool_usage_events.py +++ /dev/null @@ -1,24 +0,0 @@ -from datetime import datetime -from typing import Any, Dict - -from pydantic import BaseModel - - -class ToolUsageEvent(BaseModel): - agent_key: str - agent_role: str - tool_name: str - tool_args: Dict[str, Any] - tool_class: str - run_attempts: int | None = None - delegations: int | None = None - - -class ToolUsageFinished(ToolUsageEvent): - started_at: datetime - finished_at: datetime - from_cache: bool = False - - -class ToolUsageError(ToolUsageEvent): - error: str diff --git a/src/crewai/traces/__init__.py b/src/crewai/traces/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/crewai/traces/context.py b/src/crewai/traces/context.py new file mode 100644 index 000000000..dd1cf144e --- /dev/null +++ b/src/crewai/traces/context.py @@ -0,0 +1,39 @@ +from contextlib import contextmanager +from contextvars import ContextVar +from typing import Generator + + +class TraceContext: + """Maintains the current trace context throughout the execution stack. + + This class provides a context manager for tracking trace execution across + async and sync code paths using ContextVars. + """ + + _context: ContextVar = ContextVar("trace_context", default=None) + + @classmethod + def get_current(cls): + """Get the current trace context. + + Returns: + Optional[UnifiedTraceController]: The current trace controller or None if not set. + """ + return cls._context.get() + + @classmethod + @contextmanager + def set_current(cls, trace): + """Set the current trace context within a context manager. + + Args: + trace: The trace controller to set as current. + + Yields: + UnifiedTraceController: The current trace controller. + """ + token = cls._context.set(trace) + try: + yield trace + finally: + cls._context.reset(token) diff --git a/src/crewai/traces/enums.py b/src/crewai/traces/enums.py new file mode 100644 index 000000000..392f46ea4 --- /dev/null +++ b/src/crewai/traces/enums.py @@ -0,0 +1,19 @@ +from enum import Enum + + +class TraceType(Enum): + LLM_CALL = "llm_call" + TOOL_CALL = "tool_call" + FLOW_STEP = "flow_step" + START_CALL = "start_call" + + +class RunType(Enum): + KICKOFF = "kickoff" + TRAIN = "train" + TEST = "test" + + +class CrewType(Enum): + CREW = "crew" + FLOW = "flow" diff --git a/src/crewai/traces/models.py b/src/crewai/traces/models.py new file mode 100644 index 000000000..254da957e --- /dev/null +++ b/src/crewai/traces/models.py @@ -0,0 +1,89 @@ +from datetime import datetime +from typing import Any, Dict, List, Optional + +from pydantic import BaseModel, Field + + +class ToolCall(BaseModel): + """Model representing a tool call during execution""" + + name: str + arguments: Dict[str, Any] + output: str + start_time: datetime + end_time: Optional[datetime] = None + latency_ms: Optional[int] = None + error: Optional[str] = None + + +class LLMRequest(BaseModel): + """Model representing the LLM request details""" + + model: str + messages: List[Dict[str, str]] + temperature: Optional[float] = None + max_tokens: Optional[int] = None + stop_sequences: Optional[List[str]] = None + additional_params: Dict[str, Any] = Field(default_factory=dict) + + +class LLMResponse(BaseModel): + """Model representing the LLM response details""" + + content: str + finish_reason: Optional[str] = None + + +class FlowStepIO(BaseModel): + """Model representing flow step input/output details""" + + function_name: str + inputs: Dict[str, Any] = Field(default_factory=dict) + outputs: Any + metadata: Dict[str, Any] = Field(default_factory=dict) + + +class CrewTrace(BaseModel): + """Model for tracking detailed information about LLM interactions and Flow steps""" + + deployment_instance_id: Optional[str] = Field( + description="ID of the deployment instance" + ) + trace_id: str = Field(description="Unique identifier for this trace") + run_id: str = Field(description="Identifier for the execution run") + agent_role: Optional[str] = Field(description="Role of the agent") + task_id: Optional[str] = Field(description="ID of the current task being executed") + task_name: Optional[str] = Field(description="Name of the current task") + task_description: Optional[str] = Field( + description="Description of the current task" + ) + trace_type: str = Field(description="Type of the trace") + crew_type: str = Field(description="Type of the crew") + run_type: str = Field(description="Type of the run") + + # Timing information + start_time: Optional[datetime] = None + end_time: Optional[datetime] = None + latency_ms: Optional[int] = None + + # Request/Response for LLM calls + request: Optional[LLMRequest] = None + response: Optional[LLMResponse] = None + + # Input/Output for Flow steps + flow_step: Optional[FlowStepIO] = None + + # Tool usage + tool_calls: List[ToolCall] = Field(default_factory=list) + + # Metrics + tokens_used: Optional[int] = None + prompt_tokens: Optional[int] = None + completion_tokens: Optional[int] = None + cost: Optional[float] = None + + # Additional metadata + status: str = "running" # running, completed, error + error: Optional[str] = None + metadata: Dict[str, Any] = Field(default_factory=dict) + tags: List[str] = Field(default_factory=list) diff --git a/src/crewai/traces/unified_trace_controller.py b/src/crewai/traces/unified_trace_controller.py new file mode 100644 index 000000000..986a0a174 --- /dev/null +++ b/src/crewai/traces/unified_trace_controller.py @@ -0,0 +1,543 @@ +import inspect +import os +from datetime import UTC, datetime +from functools import wraps +from typing import Any, Awaitable, Callable, Dict, List, Optional +from uuid import uuid4 + +from crewai.traces.context import TraceContext +from crewai.traces.enums import CrewType, RunType, TraceType +from crewai.traces.models import ( + CrewTrace, + FlowStepIO, + LLMRequest, + LLMResponse, + ToolCall, +) + + +class UnifiedTraceController: + """Controls and manages trace execution and recording. + + This class handles the lifecycle of traces including creation, execution tracking, + and recording of results for various types of operations (LLM calls, tool calls, flow steps). + """ + + _task_traces: Dict[str, List["UnifiedTraceController"]] = {} + + def __init__( + self, + trace_type: TraceType, + run_type: RunType, + crew_type: CrewType, + run_id: str, + deployment_instance_id: str = os.environ.get( + "CREWAI_DEPLOYMENT_INSTANCE_ID", "" + ), + parent_trace_id: Optional[str] = None, + agent_role: Optional[str] = "unknown", + task_name: Optional[str] = None, + task_description: Optional[str] = None, + task_id: Optional[str] = None, + flow_step: Dict[str, Any] = {}, + tool_calls: List[ToolCall] = [], + **context: Any, + ) -> None: + """Initialize a new trace controller. + + Args: + trace_type: Type of trace being recorded. + run_type: Type of run being executed. + crew_type: Type of crew executing the trace. + run_id: Unique identifier for the run. + deployment_instance_id: Optional deployment instance identifier. + parent_trace_id: Optional parent trace identifier for nested traces. + agent_role: Role of the agent executing the trace. + task_name: Optional name of the task being executed. + task_description: Optional description of the task. + task_id: Optional unique identifier for the task. + flow_step: Optional flow step information. + tool_calls: Optional list of tool calls made during execution. + **context: Additional context parameters. + """ + self.trace_id = str(uuid4()) + self.run_id = run_id + self.parent_trace_id = parent_trace_id + self.trace_type = trace_type + self.run_type = run_type + self.crew_type = crew_type + self.context = context + self.agent_role = agent_role + self.task_name = task_name + self.task_description = task_description + self.task_id = task_id + self.deployment_instance_id = deployment_instance_id + self.children: List[Dict[str, Any]] = [] + self.start_time: Optional[datetime] = None + self.end_time: Optional[datetime] = None + self.error: Optional[str] = None + self.tool_calls = tool_calls + self.flow_step = flow_step + self.status: str = "running" + + # Add trace to task's trace collection if task_id is present + if task_id: + self._add_to_task_traces() + + def _add_to_task_traces(self) -> None: + """Add this trace to the task's trace collection.""" + if not hasattr(UnifiedTraceController, "_task_traces"): + UnifiedTraceController._task_traces = {} + + if self.task_id is None: + return + + if self.task_id not in UnifiedTraceController._task_traces: + UnifiedTraceController._task_traces[self.task_id] = [] + + UnifiedTraceController._task_traces[self.task_id].append(self) + + @classmethod + def get_task_traces(cls, task_id: str) -> List["UnifiedTraceController"]: + """Get all traces for a specific task. + + Args: + task_id: The ID of the task to get traces for + + Returns: + List of traces associated with the task + """ + return cls._task_traces.get(task_id, []) + + @classmethod + def clear_task_traces(cls, task_id: str) -> None: + """Clear traces for a specific task. + + Args: + task_id: The ID of the task to clear traces for + """ + if hasattr(cls, "_task_traces") and task_id in cls._task_traces: + del cls._task_traces[task_id] + + def _get_current_trace(self) -> "UnifiedTraceController": + return TraceContext.get_current() + + def start_trace(self) -> "UnifiedTraceController": + """Start the trace execution. + + Returns: + UnifiedTraceController: Self for method chaining. + """ + self.start_time = datetime.now(UTC) + return self + + def end_trace(self, result: Any = None, error: Optional[str] = None) -> None: + """End the trace execution and record results. + + Args: + result: Optional result from the trace execution. + error: Optional error message if the trace failed. + """ + self.end_time = datetime.now(UTC) + self.status = "error" if error else "completed" + self.error = error + self._record_trace(result) + + def add_child_trace(self, child_trace: Dict[str, Any]) -> None: + """Add a child trace to this trace's execution history. + + Args: + child_trace: The child trace information to add. + """ + self.children.append(child_trace) + + def to_crew_trace(self) -> CrewTrace: + """Convert to CrewTrace format for storage. + + Returns: + CrewTrace: The trace data in CrewTrace format. + """ + latency_ms = None + + if self.tool_calls and hasattr(self.tool_calls[0], "start_time"): + self.start_time = self.tool_calls[0].start_time + + if self.start_time and self.end_time: + latency_ms = int((self.end_time - self.start_time).total_seconds() * 1000) + + request = None + response = None + flow_step_obj = None + + if self.trace_type in [TraceType.LLM_CALL, TraceType.TOOL_CALL]: + request = LLMRequest( + model=self.context.get("model", "unknown"), + messages=self.context.get("messages", []), + temperature=self.context.get("temperature"), + max_tokens=self.context.get("max_tokens"), + stop_sequences=self.context.get("stop_sequences"), + ) + if "response" in self.context: + response = LLMResponse( + content=self.context["response"].get("content", ""), + finish_reason=self.context["response"].get("finish_reason"), + ) + + elif self.trace_type == TraceType.FLOW_STEP: + flow_step_obj = FlowStepIO( + function_name=self.flow_step.get("function_name", "unknown"), + inputs=self.flow_step.get("inputs", {}), + outputs={"result": self.context.get("response")}, + metadata=self.flow_step.get("metadata", {}), + ) + + return CrewTrace( + deployment_instance_id=self.deployment_instance_id, + trace_id=self.trace_id, + task_id=self.task_id, + run_id=self.run_id, + agent_role=self.agent_role, + task_name=self.task_name, + task_description=self.task_description, + trace_type=self.trace_type.value, + crew_type=self.crew_type.value, + run_type=self.run_type.value, + start_time=self.start_time, + end_time=self.end_time, + latency_ms=latency_ms, + request=request, + response=response, + flow_step=flow_step_obj, + tool_calls=self.tool_calls, + tokens_used=self.context.get("tokens_used"), + prompt_tokens=self.context.get("prompt_tokens"), + completion_tokens=self.context.get("completion_tokens"), + status=self.status, + error=self.error, + ) + + def _record_trace(self, result: Any = None) -> None: + """Record the trace. + + This method is called when a trace is completed. It ensures the trace + is properly recorded and associated with its task if applicable. + + Args: + result: Optional result to include in the trace + """ + if result: + self.context["response"] = result + + # Add to task traces if this trace belongs to a task + if self.task_id: + self._add_to_task_traces() + + +def should_trace() -> bool: + """Check if tracing is enabled via environment variable.""" + return os.getenv("CREWAI_ENABLE_TRACING", "false").lower() == "true" + + +# Crew main trace +def init_crew_main_trace(func: Callable[..., Any]) -> Callable[..., Any]: + """Decorator to initialize and track the main crew execution trace. + + This decorator sets up the trace context for the main crew execution, + handling both synchronous and asynchronous crew operations. + + Args: + func: The crew function to be traced. + + Returns: + Wrapped function that creates and manages the main crew trace context. + """ + + @wraps(func) + def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any: + if not should_trace(): + return func(self, *args, **kwargs) + + trace = build_crew_main_trace(self) + with TraceContext.set_current(trace): + try: + return func(self, *args, **kwargs) + except Exception as e: + trace.end_trace(error=str(e)) + raise + + return wrapper + + +def build_crew_main_trace(self: Any) -> "UnifiedTraceController": + """Build the main trace controller for a crew execution. + + This function creates a trace controller configured for the main crew execution, + handling different run types (kickoff, test, train) and maintaining context. + + Args: + self: The crew instance. + + Returns: + UnifiedTraceController: The configured trace controller for the crew. + """ + run_type = RunType.KICKOFF + if hasattr(self, "_test") and self._test: + run_type = RunType.TEST + elif hasattr(self, "_train") and self._train: + run_type = RunType.TRAIN + + current_trace = TraceContext.get_current() + + trace = UnifiedTraceController( + trace_type=TraceType.LLM_CALL, + run_type=run_type, + crew_type=current_trace.crew_type if current_trace else CrewType.CREW, + run_id=current_trace.run_id if current_trace else str(self.id), + parent_trace_id=current_trace.trace_id if current_trace else None, + ) + return trace + + +# Flow main trace +def init_flow_main_trace( + func: Callable[..., Awaitable[Any]], +) -> Callable[..., Awaitable[Any]]: + """Decorator to initialize and track the main flow execution trace. + + Args: + func: The async flow function to be traced. + + Returns: + Wrapped async function that creates and manages the main flow trace context. + """ + + @wraps(func) + async def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any: + if not should_trace(): + return await func(self, *args, **kwargs) + + trace = build_flow_main_trace(self, *args, **kwargs) + with TraceContext.set_current(trace): + try: + return await func(self, *args, **kwargs) + except Exception: + raise + + return wrapper + + +def build_flow_main_trace( + self: Any, *args: Any, **kwargs: Any +) -> "UnifiedTraceController": + """Build the main trace controller for a flow execution. + + Args: + self: The flow instance. + *args: Variable positional arguments. + **kwargs: Variable keyword arguments. + + Returns: + UnifiedTraceController: The configured trace controller for the flow. + """ + current_trace = TraceContext.get_current() + trace = UnifiedTraceController( + trace_type=TraceType.FLOW_STEP, + run_id=current_trace.run_id if current_trace else str(self.flow_id), + parent_trace_id=current_trace.trace_id if current_trace else None, + crew_type=CrewType.FLOW, + run_type=RunType.KICKOFF, + context={ + "crew_name": self.__class__.__name__, + "inputs": kwargs.get("inputs", {}), + "agents": [], + "tasks": [], + }, + ) + return trace + + +# Flow step trace +def trace_flow_step( + func: Callable[..., Awaitable[Any]], +) -> Callable[..., Awaitable[Any]]: + """Decorator to trace individual flow step executions. + + Args: + func: The async flow step function to be traced. + + Returns: + Wrapped async function that creates and manages the flow step trace context. + """ + + @wraps(func) + async def wrapper( + self: Any, + method_name: str, + method: Callable[..., Any], + *args: Any, + **kwargs: Any, + ) -> Any: + if not should_trace(): + return await func(self, method_name, method, *args, **kwargs) + + trace = build_flow_step_trace(self, method_name, method, *args, **kwargs) + with TraceContext.set_current(trace): + trace.start_trace() + try: + result = await func(self, method_name, method, *args, **kwargs) + trace.end_trace(result=result) + return result + except Exception as e: + trace.end_trace(error=str(e)) + raise + + return wrapper + + +def build_flow_step_trace( + self: Any, method_name: str, method: Callable[..., Any], *args: Any, **kwargs: Any +) -> "UnifiedTraceController": + """Build a trace controller for an individual flow step. + + Args: + self: The flow instance. + method_name: Name of the method being executed. + method: The actual method being executed. + *args: Variable positional arguments. + **kwargs: Variable keyword arguments. + + Returns: + UnifiedTraceController: The configured trace controller for the flow step. + """ + current_trace = TraceContext.get_current() + + # Get method signature + sig = inspect.signature(method) + params = list(sig.parameters.values()) + + # Create inputs dictionary mapping parameter names to values + method_params = [p for p in params if p.name != "self"] + inputs: Dict[str, Any] = {} + + # Map positional args to their parameter names + for i, param in enumerate(method_params): + if i < len(args): + inputs[param.name] = args[i] + + # Add keyword arguments + inputs.update(kwargs) + + trace = UnifiedTraceController( + trace_type=TraceType.FLOW_STEP, + run_type=current_trace.run_type if current_trace else RunType.KICKOFF, + crew_type=current_trace.crew_type if current_trace else CrewType.FLOW, + run_id=current_trace.run_id if current_trace else str(self.flow_id), + parent_trace_id=current_trace.trace_id if current_trace else None, + flow_step={ + "function_name": method_name, + "inputs": inputs, + "metadata": { + "crew_name": self.__class__.__name__, + }, + }, + ) + return trace + + +# LLM trace +def trace_llm_call(func: Callable[..., Any]) -> Callable[..., Any]: + """Decorator to trace LLM calls. + + Args: + func: The function to trace. + + Returns: + Wrapped function that creates and manages the LLM call trace context. + """ + + @wraps(func) + def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any: + if not should_trace(): + return func(self, *args, **kwargs) + + trace = build_llm_trace(self, *args, **kwargs) + with TraceContext.set_current(trace): + trace.start_trace() + try: + response = func(self, *args, **kwargs) + # Extract relevant data from response + trace_response = { + "content": response["choices"][0]["message"]["content"], + "finish_reason": response["choices"][0].get("finish_reason"), + } + + # Add usage metrics to context + if "usage" in response: + trace.context["tokens_used"] = response["usage"].get( + "total_tokens", 0 + ) + trace.context["prompt_tokens"] = response["usage"].get( + "prompt_tokens", 0 + ) + trace.context["completion_tokens"] = response["usage"].get( + "completion_tokens", 0 + ) + + trace.end_trace(trace_response) + return response + except Exception as e: + trace.end_trace(error=str(e)) + raise + + return wrapper + + +def build_llm_trace( + self: Any, params: Dict[str, Any], *args: Any, **kwargs: Any +) -> Any: + """Build a trace controller for an LLM call. + + Args: + self: The LLM instance. + params: The parameters for the LLM call. + *args: Variable positional arguments. + **kwargs: Variable keyword arguments. + + Returns: + UnifiedTraceController: The configured trace controller for the LLM call. + """ + current_trace = TraceContext.get_current() + agent, task = self._get_execution_context() + + # Get new messages and tool results + new_messages = self._get_new_messages(params.get("messages", [])) + new_tool_results = self._get_new_tool_results(agent) + + # Create trace context + trace = UnifiedTraceController( + trace_type=TraceType.TOOL_CALL if new_tool_results else TraceType.LLM_CALL, + crew_type=current_trace.crew_type if current_trace else CrewType.CREW, + run_type=current_trace.run_type if current_trace else RunType.KICKOFF, + run_id=current_trace.run_id if current_trace else str(uuid4()), + parent_trace_id=current_trace.trace_id if current_trace else None, + agent_role=agent.role if agent else "unknown", + task_id=str(task.id) if task else None, + task_name=task.name if task else None, + task_description=task.description if task else None, + model=self.model, + messages=new_messages, + temperature=self.temperature, + max_tokens=self.max_tokens, + stop_sequences=self.stop, + tool_calls=[ + ToolCall( + name=result["tool_name"], + arguments=result["tool_args"], + output=str(result["result"]), + start_time=result.get("start_time", ""), + end_time=datetime.now(UTC), + ) + for result in new_tool_results + ], + ) + return trace diff --git a/src/crewai/utilities/constants.py b/src/crewai/utilities/constants.py index 096bb7c8c..9ff10f1d4 100644 --- a/src/crewai/utilities/constants.py +++ b/src/crewai/utilities/constants.py @@ -4,3 +4,4 @@ DEFAULT_SCORE_THRESHOLD = 0.35 KNOWLEDGE_DIRECTORY = "knowledge" MAX_LLM_RETRY = 3 MAX_FILE_NAME_LENGTH = 255 +EMITTER_COLOR = "bold_blue" diff --git a/src/crewai/utilities/evaluators/task_evaluator.py b/src/crewai/utilities/evaluators/task_evaluator.py index 294629274..2e9907bd7 100644 --- a/src/crewai/utilities/evaluators/task_evaluator.py +++ b/src/crewai/utilities/evaluators/task_evaluator.py @@ -3,19 +3,9 @@ from typing import List from pydantic import BaseModel, Field from crewai.utilities import Converter +from crewai.utilities.events import TaskEvaluationEvent, crewai_event_bus from crewai.utilities.pydantic_schema_parser import PydanticSchemaParser -agentops = None -try: - from agentops import track_agent # type: ignore -except ImportError: - - def track_agent(name): - def noop(f): - return f - - return noop - class Entity(BaseModel): name: str = Field(description="The name of the entity.") @@ -48,12 +38,15 @@ class TrainingTaskEvaluation(BaseModel): ) -@track_agent(name="Task Evaluator") class TaskEvaluator: def __init__(self, original_agent): self.llm = original_agent.llm + self.original_agent = original_agent def evaluate(self, task, output) -> TaskEvaluation: + crewai_event_bus.emit( + self, TaskEvaluationEvent(evaluation_type="task_evaluation") + ) evaluation_query = ( f"Assess the quality of the task completed based on the description, expected output, and actual results.\n\n" f"Task Description:\n{task.description}\n\n" @@ -90,6 +83,9 @@ class TaskEvaluator: - training_data (dict): The training data to be evaluated. - agent_id (str): The ID of the agent. """ + crewai_event_bus.emit( + self, TaskEvaluationEvent(evaluation_type="training_data_evaluation") + ) output_training_data = training_data[agent_id] final_aggregated_data = "" diff --git a/src/crewai/utilities/events.py b/src/crewai/utilities/events.py deleted file mode 100644 index 11175e0d2..000000000 --- a/src/crewai/utilities/events.py +++ /dev/null @@ -1,44 +0,0 @@ -from functools import wraps -from typing import Any, Callable, Dict, Generic, List, Type, TypeVar - -from pydantic import BaseModel - -T = TypeVar("T") -EVT = TypeVar("EVT", bound=BaseModel) - - -class Emitter(Generic[T, EVT]): - _listeners: Dict[Type[EVT], List[Callable]] = {} - - def on(self, event_type: Type[EVT]): - def decorator(func: Callable): - @wraps(func) - def wrapper(*args, **kwargs): - return func(*args, **kwargs) - - self._listeners.setdefault(event_type, []).append(wrapper) - return wrapper - - return decorator - - def emit(self, source: T, event: EVT) -> None: - event_type = type(event) - for func in self._listeners.get(event_type, []): - func(source, event) - - -default_emitter = Emitter[Any, BaseModel]() - - -def emit(source: Any, event: BaseModel, raise_on_error: bool = False) -> None: - try: - default_emitter.emit(source, event) - except Exception as e: - if raise_on_error: - raise e - else: - print(f"Error emitting event: {e}") - - -def on(event_type: Type[BaseModel]) -> Callable: - return default_emitter.on(event_type) diff --git a/src/crewai/utilities/events/__init__.py b/src/crewai/utilities/events/__init__.py new file mode 100644 index 000000000..7f3442360 --- /dev/null +++ b/src/crewai/utilities/events/__init__.py @@ -0,0 +1,40 @@ +from .crew_events import ( + CrewKickoffStartedEvent, + CrewKickoffCompletedEvent, + CrewKickoffFailedEvent, + CrewTrainStartedEvent, + CrewTrainCompletedEvent, + CrewTrainFailedEvent, + CrewTestStartedEvent, + CrewTestCompletedEvent, + CrewTestFailedEvent, +) +from .agent_events import ( + AgentExecutionStartedEvent, + AgentExecutionCompletedEvent, + AgentExecutionErrorEvent, +) +from .task_events import TaskStartedEvent, TaskCompletedEvent, TaskFailedEvent, TaskEvaluationEvent +from .flow_events import ( + FlowCreatedEvent, + FlowStartedEvent, + FlowFinishedEvent, + FlowPlotEvent, + MethodExecutionStartedEvent, + MethodExecutionFinishedEvent, + MethodExecutionFailedEvent, +) +from .crewai_event_bus import CrewAIEventsBus, crewai_event_bus +from .tool_usage_events import ( + ToolUsageFinishedEvent, + ToolUsageErrorEvent, + ToolUsageStartedEvent, + ToolExecutionErrorEvent, + ToolSelectionErrorEvent, + ToolUsageEvent, + ToolValidateInputErrorEvent, +) + +# events +from .event_listener import EventListener +from .third_party.agentops_listener import agentops_listener diff --git a/src/crewai/utilities/events/agent_events.py b/src/crewai/utilities/events/agent_events.py new file mode 100644 index 000000000..ed0480957 --- /dev/null +++ b/src/crewai/utilities/events/agent_events.py @@ -0,0 +1,40 @@ +from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence, Union + +from crewai.agents.agent_builder.base_agent import BaseAgent +from crewai.tools.base_tool import BaseTool +from crewai.tools.structured_tool import CrewStructuredTool + +from .base_events import CrewEvent + +if TYPE_CHECKING: + from crewai.agents.agent_builder.base_agent import BaseAgent + + +class AgentExecutionStartedEvent(CrewEvent): + """Event emitted when an agent starts executing a task""" + + agent: BaseAgent + task: Any + tools: Optional[Sequence[Union[BaseTool, CrewStructuredTool]]] + task_prompt: str + type: str = "agent_execution_started" + + model_config = {"arbitrary_types_allowed": True} + + +class AgentExecutionCompletedEvent(CrewEvent): + """Event emitted when an agent completes executing a task""" + + agent: BaseAgent + task: Any + output: str + type: str = "agent_execution_completed" + + +class AgentExecutionErrorEvent(CrewEvent): + """Event emitted when an agent encounters an error during execution""" + + agent: BaseAgent + task: Any + error: str + type: str = "agent_execution_error" diff --git a/src/crewai/utilities/events/base_event_listener.py b/src/crewai/utilities/events/base_event_listener.py new file mode 100644 index 000000000..37763dcc1 --- /dev/null +++ b/src/crewai/utilities/events/base_event_listener.py @@ -0,0 +1,14 @@ +from abc import ABC, abstractmethod +from logging import Logger + +from crewai.utilities.events.crewai_event_bus import CrewAIEventsBus, crewai_event_bus + + +class BaseEventListener(ABC): + def __init__(self): + super().__init__() + self.setup_listeners(crewai_event_bus) + + @abstractmethod + def setup_listeners(self, crewai_event_bus: CrewAIEventsBus): + pass diff --git a/src/crewai/utilities/events/base_events.py b/src/crewai/utilities/events/base_events.py new file mode 100644 index 000000000..b29ae6fb6 --- /dev/null +++ b/src/crewai/utilities/events/base_events.py @@ -0,0 +1,10 @@ +from datetime import datetime + +from pydantic import BaseModel, Field + + +class CrewEvent(BaseModel): + """Base class for all crew events""" + + timestamp: datetime = Field(default_factory=datetime.now) + type: str diff --git a/src/crewai/utilities/events/crew_events.py b/src/crewai/utilities/events/crew_events.py new file mode 100644 index 000000000..13dfd8e34 --- /dev/null +++ b/src/crewai/utilities/events/crew_events.py @@ -0,0 +1,81 @@ +from typing import Any, Dict, Optional, Union + +from pydantic import InstanceOf + +from crewai.utilities.events.base_events import CrewEvent + + +class CrewKickoffStartedEvent(CrewEvent): + """Event emitted when a crew starts execution""" + + crew_name: Optional[str] + inputs: Optional[Dict[str, Any]] + type: str = "crew_kickoff_started" + + +class CrewKickoffCompletedEvent(CrewEvent): + """Event emitted when a crew completes execution""" + + crew_name: Optional[str] + output: Any + type: str = "crew_kickoff_completed" + + +class CrewKickoffFailedEvent(CrewEvent): + """Event emitted when a crew fails to complete execution""" + + error: str + crew_name: Optional[str] + type: str = "crew_kickoff_failed" + + +class CrewTrainStartedEvent(CrewEvent): + """Event emitted when a crew starts training""" + + crew_name: Optional[str] + n_iterations: int + filename: str + inputs: Optional[Dict[str, Any]] + type: str = "crew_train_started" + + +class CrewTrainCompletedEvent(CrewEvent): + """Event emitted when a crew completes training""" + + crew_name: Optional[str] + n_iterations: int + filename: str + type: str = "crew_train_completed" + + +class CrewTrainFailedEvent(CrewEvent): + """Event emitted when a crew fails to complete training""" + + error: str + crew_name: Optional[str] + type: str = "crew_train_failed" + + +class CrewTestStartedEvent(CrewEvent): + """Event emitted when a crew starts testing""" + + crew_name: Optional[str] + n_iterations: int + eval_llm: Optional[Union[str, Any]] + inputs: Optional[Dict[str, Any]] + type: str = "crew_test_started" + + +class CrewTestCompletedEvent(CrewEvent): + """Event emitted when a crew completes testing""" + + crew_name: Optional[str] + type: str = "crew_test_completed" + + +class CrewTestFailedEvent(CrewEvent): + """Event emitted when a crew fails to complete testing""" + + error: str + crew_name: Optional[str] + type: str = "crew_test_failed" diff --git a/src/crewai/utilities/events/crewai_event_bus.py b/src/crewai/utilities/events/crewai_event_bus.py new file mode 100644 index 000000000..c0cf50908 --- /dev/null +++ b/src/crewai/utilities/events/crewai_event_bus.py @@ -0,0 +1,113 @@ +import threading +from contextlib import contextmanager +from typing import Any, Callable, Dict, List, Type, TypeVar, cast + +from blinker import Signal + +from crewai.utilities.events.base_events import CrewEvent +from crewai.utilities.events.event_types import EventTypes + +EventT = TypeVar("EventT", bound=CrewEvent) + + +class CrewAIEventsBus: + """ + A singleton event bus that uses blinker signals for event handling. + Allows both internal (Flow/Crew) and external event handling. + """ + + _instance = None + _lock = threading.Lock() + + def __new__(cls): + if cls._instance is None: + with cls._lock: + if cls._instance is None: # prevent race condition + cls._instance = super(CrewAIEventsBus, cls).__new__(cls) + cls._instance._initialize() + return cls._instance + + def _initialize(self) -> None: + """Initialize the event bus internal state""" + self._signal = Signal("crewai_event_bus") + self._handlers: Dict[Type[CrewEvent], List[Callable]] = {} + + def on( + self, event_type: Type[EventT] + ) -> Callable[[Callable[[Any, EventT], None]], Callable[[Any, EventT], None]]: + """ + Decorator to register an event handler for a specific event type. + + Usage: + @crewai_event_bus.on(AgentExecutionCompletedEvent) + def on_agent_execution_completed( + source: Any, event: AgentExecutionCompletedEvent + ): + print(f"👍 Agent '{event.agent}' completed task") + print(f" Output: {event.output}") + """ + + def decorator( + handler: Callable[[Any, EventT], None], + ) -> Callable[[Any, EventT], None]: + if event_type not in self._handlers: + self._handlers[event_type] = [] + self._handlers[event_type].append( + cast(Callable[[Any, EventT], None], handler) + ) + return handler + + return decorator + + def emit(self, source: Any, event: CrewEvent) -> None: + """ + Emit an event to all registered handlers + + Args: + source: The object emitting the event + event: The event instance to emit + """ + event_type = type(event) + if event_type in self._handlers: + for handler in self._handlers[event_type]: + handler(source, event) + self._signal.send(source, event=event) + + def clear_handlers(self) -> None: + """Clear all registered event handlers - useful for testing""" + self._handlers.clear() + + def register_handler( + self, event_type: Type[EventTypes], handler: Callable[[Any, EventTypes], None] + ) -> None: + """Register an event handler for a specific event type""" + if event_type not in self._handlers: + self._handlers[event_type] = [] + self._handlers[event_type].append( + cast(Callable[[Any, EventTypes], None], handler) + ) + + @contextmanager + def scoped_handlers(self): + """ + Context manager for temporary event handling scope. + Useful for testing or temporary event handling. + + Usage: + with crewai_event_bus.scoped_handlers(): + @crewai_event_bus.on(CrewKickoffStarted) + def temp_handler(source, event): + print("Temporary handler") + # Do stuff... + # Handlers are cleared after the context + """ + previous_handlers = self._handlers.copy() + self._handlers.clear() + try: + yield + finally: + self._handlers = previous_handlers + + +# Global instance +crewai_event_bus = CrewAIEventsBus() diff --git a/src/crewai/utilities/events/event_listener.py b/src/crewai/utilities/events/event_listener.py new file mode 100644 index 000000000..0dcefcd3d --- /dev/null +++ b/src/crewai/utilities/events/event_listener.py @@ -0,0 +1,257 @@ +from pydantic import PrivateAttr + +from crewai.telemetry.telemetry import Telemetry +from crewai.utilities import Logger +from crewai.utilities.constants import EMITTER_COLOR +from crewai.utilities.events.base_event_listener import BaseEventListener + +from .agent_events import AgentExecutionCompletedEvent, AgentExecutionStartedEvent +from .crew_events import ( + CrewKickoffCompletedEvent, + CrewKickoffFailedEvent, + CrewKickoffStartedEvent, + CrewTestCompletedEvent, + CrewTestFailedEvent, + CrewTestStartedEvent, + CrewTrainCompletedEvent, + CrewTrainFailedEvent, + CrewTrainStartedEvent, +) +from .flow_events import ( + FlowCreatedEvent, + FlowFinishedEvent, + FlowStartedEvent, + MethodExecutionFailedEvent, + MethodExecutionFinishedEvent, + MethodExecutionStartedEvent, +) +from .task_events import TaskCompletedEvent, TaskFailedEvent, TaskStartedEvent +from .tool_usage_events import ( + ToolUsageErrorEvent, + ToolUsageFinishedEvent, + ToolUsageStartedEvent, +) + + +class EventListener(BaseEventListener): + _instance = None + _telemetry: Telemetry = PrivateAttr(default_factory=lambda: Telemetry()) + logger = Logger(verbose=True, default_color=EMITTER_COLOR) + + def __new__(cls): + if cls._instance is None: + cls._instance = super().__new__(cls) + cls._instance._initialized = False + return cls._instance + + def __init__(self): + if not hasattr(self, "_initialized") or not self._initialized: + super().__init__() + self._telemetry = Telemetry() + self._telemetry.set_tracer() + self._initialized = True + + # ----------- CREW EVENTS ----------- + + def setup_listeners(self, crewai_event_bus): + @crewai_event_bus.on(CrewKickoffStartedEvent) + def on_crew_started(source, event: CrewKickoffStartedEvent): + self.logger.log( + f"🚀 Crew '{event.crew_name}' started", + event.timestamp, + ) + self._telemetry.crew_execution_span(source, event.inputs) + + @crewai_event_bus.on(CrewKickoffCompletedEvent) + def on_crew_completed(source, event: CrewKickoffCompletedEvent): + final_string_output = event.output.raw + self._telemetry.end_crew(source, final_string_output) + self.logger.log( + f"✅ Crew '{event.crew_name}' completed", + event.timestamp, + ) + + @crewai_event_bus.on(CrewKickoffFailedEvent) + def on_crew_failed(source, event: CrewKickoffFailedEvent): + self.logger.log( + f"❌ Crew '{event.crew_name}' failed", + event.timestamp, + ) + + @crewai_event_bus.on(CrewTestStartedEvent) + def on_crew_test_started(source, event: CrewTestStartedEvent): + cloned_crew = source.copy() + cloned_crew._telemetry.test_execution_span( + cloned_crew, + event.n_iterations, + event.inputs, + event.eval_llm, + ) + self.logger.log( + f"🚀 Crew '{event.crew_name}' started test", + event.timestamp, + ) + + @crewai_event_bus.on(CrewTestCompletedEvent) + def on_crew_test_completed(source, event: CrewTestCompletedEvent): + self.logger.log( + f"✅ Crew '{event.crew_name}' completed test", + event.timestamp, + ) + + @crewai_event_bus.on(CrewTestFailedEvent) + def on_crew_test_failed(source, event: CrewTestFailedEvent): + self.logger.log( + f"❌ Crew '{event.crew_name}' failed test", + event.timestamp, + ) + + @crewai_event_bus.on(CrewTrainStartedEvent) + def on_crew_train_started(source, event: CrewTrainStartedEvent): + self.logger.log( + f"📋 Crew '{event.crew_name}' started train", + event.timestamp, + ) + + @crewai_event_bus.on(CrewTrainCompletedEvent) + def on_crew_train_completed(source, event: CrewTrainCompletedEvent): + self.logger.log( + f"✅ Crew '{event.crew_name}' completed train", + event.timestamp, + ) + + @crewai_event_bus.on(CrewTrainFailedEvent) + def on_crew_train_failed(source, event: CrewTrainFailedEvent): + self.logger.log( + f"❌ Crew '{event.crew_name}' failed train", + event.timestamp, + ) + + # ----------- TASK EVENTS ----------- + + @crewai_event_bus.on(TaskStartedEvent) + def on_task_started(source, event: TaskStartedEvent): + source._execution_span = self._telemetry.task_started( + crew=source.agent.crew, task=source + ) + self.logger.log( + f"📋 Task started: {source.description}", + event.timestamp, + ) + + @crewai_event_bus.on(TaskCompletedEvent) + def on_task_completed(source, event: TaskCompletedEvent): + if source._execution_span: + self._telemetry.task_ended( + source._execution_span, source, source.agent.crew + ) + self.logger.log( + f"✅ Task completed: {source.description}", + event.timestamp, + ) + source._execution_span = None + + @crewai_event_bus.on(TaskFailedEvent) + def on_task_failed(source, event: TaskFailedEvent): + if source._execution_span: + if source.agent and source.agent.crew: + self._telemetry.task_ended( + source._execution_span, source, source.agent.crew + ) + source._execution_span = None + self.logger.log( + f"❌ Task failed: {source.description}", + event.timestamp, + ) + + # ----------- AGENT EVENTS ----------- + + @crewai_event_bus.on(AgentExecutionStartedEvent) + def on_agent_execution_started(source, event: AgentExecutionStartedEvent): + self.logger.log( + f"🤖 Agent '{event.agent.role}' started task", + event.timestamp, + ) + + @crewai_event_bus.on(AgentExecutionCompletedEvent) + def on_agent_execution_completed(source, event: AgentExecutionCompletedEvent): + self.logger.log( + f"✅ Agent '{event.agent.role}' completed task", + event.timestamp, + ) + + # ----------- FLOW EVENTS ----------- + + @crewai_event_bus.on(FlowCreatedEvent) + def on_flow_created(source, event: FlowCreatedEvent): + self._telemetry.flow_creation_span(self.__class__.__name__) + self.logger.log( + f"🌊 Flow Created: '{event.flow_name}'", + event.timestamp, + ) + + @crewai_event_bus.on(FlowStartedEvent) + def on_flow_started(source, event: FlowStartedEvent): + self._telemetry.flow_execution_span( + source.__class__.__name__, list(source._methods.keys()) + ) + self.logger.log( + f"🤖 Flow Started: '{event.flow_name}'", + event.timestamp, + ) + + @crewai_event_bus.on(FlowFinishedEvent) + def on_flow_finished(source, event: FlowFinishedEvent): + self.logger.log( + f"👍 Flow Finished: '{event.flow_name}'", + event.timestamp, + ) + + @crewai_event_bus.on(MethodExecutionStartedEvent) + def on_method_execution_started(source, event: MethodExecutionStartedEvent): + self.logger.log( + f"🤖 Flow Method Started: '{event.method_name}'", + event.timestamp, + ) + + @crewai_event_bus.on(MethodExecutionFailedEvent) + def on_method_execution_failed(source, event: MethodExecutionFailedEvent): + self.logger.log( + f"❌ Flow Method Failed: '{event.method_name}'", + event.timestamp, + ) + + @crewai_event_bus.on(MethodExecutionFinishedEvent) + def on_method_execution_finished(source, event: MethodExecutionFinishedEvent): + self.logger.log( + f"👍 Flow Method Finished: '{event.method_name}'", + event.timestamp, + ) + + # ----------- TOOL USAGE EVENTS ----------- + + @crewai_event_bus.on(ToolUsageStartedEvent) + def on_tool_usage_started(source, event: ToolUsageStartedEvent): + self.logger.log( + f"🤖 Tool Usage Started: '{event.tool_name}'", + event.timestamp, + ) + + @crewai_event_bus.on(ToolUsageFinishedEvent) + def on_tool_usage_finished(source, event: ToolUsageFinishedEvent): + self.logger.log( + f"✅ Tool Usage Finished: '{event.tool_name}'", + event.timestamp, + # + ) + + @crewai_event_bus.on(ToolUsageErrorEvent) + def on_tool_usage_error(source, event: ToolUsageErrorEvent): + self.logger.log( + f"❌ Tool Usage Error: '{event.tool_name}'", + event.timestamp, + # + ) + + +event_listener = EventListener() diff --git a/src/crewai/utilities/events/event_types.py b/src/crewai/utilities/events/event_types.py new file mode 100644 index 000000000..81caf17f4 --- /dev/null +++ b/src/crewai/utilities/events/event_types.py @@ -0,0 +1,61 @@ +from typing import Union + +from .agent_events import ( + AgentExecutionCompletedEvent, + AgentExecutionErrorEvent, + AgentExecutionStartedEvent, +) +from .crew_events import ( + CrewKickoffCompletedEvent, + CrewKickoffFailedEvent, + CrewKickoffStartedEvent, + CrewTestCompletedEvent, + CrewTestFailedEvent, + CrewTestStartedEvent, + CrewTrainCompletedEvent, + CrewTrainFailedEvent, + CrewTrainStartedEvent, +) +from .flow_events import ( + FlowFinishedEvent, + FlowStartedEvent, + MethodExecutionFailedEvent, + MethodExecutionFinishedEvent, + MethodExecutionStartedEvent, +) +from .task_events import ( + TaskCompletedEvent, + TaskFailedEvent, + TaskStartedEvent, +) +from .tool_usage_events import ( + ToolUsageErrorEvent, + ToolUsageFinishedEvent, + ToolUsageStartedEvent, +) + +EventTypes = Union[ + CrewKickoffStartedEvent, + CrewKickoffCompletedEvent, + CrewKickoffFailedEvent, + CrewTestStartedEvent, + CrewTestCompletedEvent, + CrewTestFailedEvent, + CrewTrainStartedEvent, + CrewTrainCompletedEvent, + CrewTrainFailedEvent, + AgentExecutionStartedEvent, + AgentExecutionCompletedEvent, + TaskStartedEvent, + TaskCompletedEvent, + TaskFailedEvent, + FlowStartedEvent, + FlowFinishedEvent, + MethodExecutionStartedEvent, + MethodExecutionFinishedEvent, + MethodExecutionFailedEvent, + AgentExecutionErrorEvent, + ToolUsageFinishedEvent, + ToolUsageErrorEvent, + ToolUsageStartedEvent, +] diff --git a/src/crewai/utilities/events/flow_events.py b/src/crewai/utilities/events/flow_events.py new file mode 100644 index 000000000..435d64214 --- /dev/null +++ b/src/crewai/utilities/events/flow_events.py @@ -0,0 +1,71 @@ +from typing import Any, Dict, Optional, Union + +from pydantic import BaseModel + +from .base_events import CrewEvent + + +class FlowEvent(CrewEvent): + """Base class for all flow events""" + + type: str + flow_name: str + + +class FlowStartedEvent(FlowEvent): + """Event emitted when a flow starts execution""" + + flow_name: str + inputs: Optional[Dict[str, Any]] = None + type: str = "flow_started" + + +class FlowCreatedEvent(FlowEvent): + """Event emitted when a flow is created""" + + flow_name: str + type: str = "flow_created" + + +class MethodExecutionStartedEvent(FlowEvent): + """Event emitted when a flow method starts execution""" + + flow_name: str + method_name: str + state: Union[Dict[str, Any], BaseModel] + params: Optional[Dict[str, Any]] = None + type: str = "method_execution_started" + + +class MethodExecutionFinishedEvent(FlowEvent): + """Event emitted when a flow method completes execution""" + + flow_name: str + method_name: str + result: Any = None + state: Union[Dict[str, Any], BaseModel] + type: str = "method_execution_finished" + + +class MethodExecutionFailedEvent(FlowEvent): + """Event emitted when a flow method fails execution""" + + flow_name: str + method_name: str + error: Any + type: str = "method_execution_failed" + + +class FlowFinishedEvent(FlowEvent): + """Event emitted when a flow completes execution""" + + flow_name: str + result: Optional[Any] = None + type: str = "flow_finished" + + +class FlowPlotEvent(FlowEvent): + """Event emitted when a flow plot is created""" + + flow_name: str + type: str = "flow_plot" diff --git a/src/crewai/utilities/events/task_events.py b/src/crewai/utilities/events/task_events.py new file mode 100644 index 000000000..f69e77d6a --- /dev/null +++ b/src/crewai/utilities/events/task_events.py @@ -0,0 +1,32 @@ +from typing import Any, Optional + +from crewai.tasks.task_output import TaskOutput +from crewai.utilities.events.base_events import CrewEvent + + +class TaskStartedEvent(CrewEvent): + """Event emitted when a task starts""" + + type: str = "task_started" + context: Optional[str] + + +class TaskCompletedEvent(CrewEvent): + """Event emitted when a task completes""" + + output: TaskOutput + type: str = "task_completed" + + +class TaskFailedEvent(CrewEvent): + """Event emitted when a task fails""" + + error: str + type: str = "task_failed" + + +class TaskEvaluationEvent(CrewEvent): + """Event emitted when a task evaluation is completed""" + + type: str = "task_evaluation" + evaluation_type: str diff --git a/src/crewai/utilities/events/third_party/__init__.py b/src/crewai/utilities/events/third_party/__init__.py new file mode 100644 index 000000000..e9de52477 --- /dev/null +++ b/src/crewai/utilities/events/third_party/__init__.py @@ -0,0 +1 @@ +from .agentops_listener import agentops_listener diff --git a/src/crewai/utilities/events/third_party/agentops_listener.py b/src/crewai/utilities/events/third_party/agentops_listener.py new file mode 100644 index 000000000..294a820ee --- /dev/null +++ b/src/crewai/utilities/events/third_party/agentops_listener.py @@ -0,0 +1,67 @@ +from typing import Optional + +from crewai.utilities.events import ( + CrewKickoffCompletedEvent, + ToolUsageErrorEvent, + ToolUsageStartedEvent, +) +from crewai.utilities.events.base_event_listener import BaseEventListener +from crewai.utilities.events.crew_events import CrewKickoffStartedEvent +from crewai.utilities.events.task_events import TaskEvaluationEvent + +try: + import agentops + + AGENTOPS_INSTALLED = True +except ImportError: + AGENTOPS_INSTALLED = False + + +class AgentOpsListener(BaseEventListener): + tool_event: Optional["agentops.ToolEvent"] = None + session: Optional["agentops.Session"] = None + + def __init__(self): + super().__init__() + + def setup_listeners(self, crewai_event_bus): + if not AGENTOPS_INSTALLED: + return + + @crewai_event_bus.on(CrewKickoffStartedEvent) + def on_crew_kickoff_started(source, event: CrewKickoffStartedEvent): + self.session = agentops.init() + for agent in source.agents: + if self.session: + self.session.create_agent( + name=agent.role, + agent_id=str(agent.id), + ) + + @crewai_event_bus.on(CrewKickoffCompletedEvent) + def on_crew_kickoff_completed(source, event: CrewKickoffCompletedEvent): + if self.session: + self.session.end_session( + end_state="Success", + end_state_reason="Finished Execution", + ) + + @crewai_event_bus.on(ToolUsageStartedEvent) + def on_tool_usage_started(source, event: ToolUsageStartedEvent): + self.tool_event = agentops.ToolEvent(name=event.tool_name) + if self.session: + self.session.record(self.tool_event) + + @crewai_event_bus.on(ToolUsageErrorEvent) + def on_tool_usage_error(source, event: ToolUsageErrorEvent): + agentops.ErrorEvent(exception=event.error, trigger_event=self.tool_event) + + @crewai_event_bus.on(TaskEvaluationEvent) + def on_task_evaluation(source, event: TaskEvaluationEvent): + if self.session: + self.session.create_agent( + name="Task Evaluator", agent_id=str(source.original_agent.id) + ) + + +agentops_listener = AgentOpsListener() diff --git a/src/crewai/utilities/events/tool_usage_events.py b/src/crewai/utilities/events/tool_usage_events.py new file mode 100644 index 000000000..aa375dcd7 --- /dev/null +++ b/src/crewai/utilities/events/tool_usage_events.py @@ -0,0 +1,64 @@ +from datetime import datetime +from typing import Any, Callable, Dict + +from .base_events import CrewEvent + + +class ToolUsageEvent(CrewEvent): + """Base event for tool usage tracking""" + + agent_key: str + agent_role: str + tool_name: str + tool_args: Dict[str, Any] | str + tool_class: str + run_attempts: int | None = None + delegations: int | None = None + + model_config = {"arbitrary_types_allowed": True} + + +class ToolUsageStartedEvent(ToolUsageEvent): + """Event emitted when a tool execution is started""" + + type: str = "tool_usage_started" + + +class ToolUsageFinishedEvent(ToolUsageEvent): + """Event emitted when a tool execution is completed""" + + started_at: datetime + finished_at: datetime + from_cache: bool = False + type: str = "tool_usage_finished" + + +class ToolUsageErrorEvent(ToolUsageEvent): + """Event emitted when a tool execution encounters an error""" + + error: Any + type: str = "tool_usage_error" + + +class ToolValidateInputErrorEvent(ToolUsageEvent): + """Event emitted when a tool input validation encounters an error""" + + error: Any + type: str = "tool_validate_input_error" + + +class ToolSelectionErrorEvent(ToolUsageEvent): + """Event emitted when a tool selection encounters an error""" + + error: Any + type: str = "tool_selection_error" + + +class ToolExecutionErrorEvent(CrewEvent): + """Event emitted when a tool execution encounters an error""" + + error: Any + type: str = "tool_execution_error" + tool_name: str + tool_args: Dict[str, Any] + tool_class: Callable diff --git a/src/crewai/utilities/logger.py b/src/crewai/utilities/logger.py index 9b883f617..2f69e7abc 100644 --- a/src/crewai/utilities/logger.py +++ b/src/crewai/utilities/logger.py @@ -8,8 +8,11 @@ from crewai.utilities.printer import Printer class Logger(BaseModel): verbose: bool = Field(default=False) _printer: Printer = PrivateAttr(default_factory=Printer) + default_color: str = Field(default="bold_yellow") - def log(self, level, message, color="bold_yellow"): + def log(self, level, message, color=None): + if color is None: + color = self.default_color if self.verbose: timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") self._printer.print( diff --git a/src/crewai/utilities/protocols.py b/src/crewai/utilities/protocols.py new file mode 100644 index 000000000..83ebf58e9 --- /dev/null +++ b/src/crewai/utilities/protocols.py @@ -0,0 +1,12 @@ +from typing import Any, Protocol, runtime_checkable + + +@runtime_checkable +class AgentExecutorProtocol(Protocol): + """Protocol defining the expected interface for an agent executor.""" + + @property + def agent(self) -> Any: ... + + @property + def task(self) -> Any: ... diff --git a/tests/agent_test.py b/tests/agent_test.py index e67a7454a..3547398e5 100644 --- a/tests/agent_test.py +++ b/tests/agent_test.py @@ -1,6 +1,7 @@ """Test Agent creation and execution basic functionality.""" import os +from datetime import UTC, datetime, timezone from unittest import mock from unittest.mock import patch @@ -16,9 +17,9 @@ from crewai.llm import LLM from crewai.tools import tool from crewai.tools.tool_calling import InstructorToolCalling from crewai.tools.tool_usage import ToolUsage -from crewai.tools.tool_usage_events import ToolUsageFinished from crewai.utilities import RPMController -from crewai.utilities.events import Emitter +from crewai.utilities.events import crewai_event_bus +from crewai.utilities.events.tool_usage_events import ToolUsageFinishedEvent def test_agent_llm_creation_with_env_vars(): @@ -154,15 +155,19 @@ def test_agent_execution_with_tools(): agent=agent, expected_output="The result of the multiplication.", ) - with patch.object(Emitter, "emit") as emit: - output = agent.execute_task(task) - assert output == "The result of the multiplication is 12." - assert emit.call_count == 1 - args, _ = emit.call_args - assert isinstance(args[1], ToolUsageFinished) - assert not args[1].from_cache - assert args[1].tool_name == "multiplier" - assert args[1].tool_args == {"first_number": 3, "second_number": 4} + received_events = [] + + @crewai_event_bus.on(ToolUsageFinishedEvent) + def handle_tool_end(source, event): + received_events.append(event) + + output = agent.execute_task(task) + assert output == "The result of the multiplication is 12." + + assert len(received_events) == 1 + assert isinstance(received_events[0], ToolUsageFinishedEvent) + assert received_events[0].tool_name == "multiplier" + assert received_events[0].tool_args == {"first_number": 3, "second_number": 4} @pytest.mark.vcr(filter_headers=["authorization"]) @@ -249,10 +254,14 @@ def test_cache_hitting(): "multiplier-{'first_number': 3, 'second_number': 3}": 9, "multiplier-{'first_number': 12, 'second_number': 3}": 36, } + received_events = [] + + @crewai_event_bus.on(ToolUsageFinishedEvent) + def handle_tool_end(source, event): + received_events.append(event) with ( patch.object(CacheHandler, "read") as read, - patch.object(Emitter, "emit") as emit, ): read.return_value = "0" task = Task( @@ -265,10 +274,9 @@ def test_cache_hitting(): read.assert_called_with( tool="multiplier", input={"first_number": 2, "second_number": 6} ) - assert emit.call_count == 1 - args, _ = emit.call_args - assert isinstance(args[1], ToolUsageFinished) - assert args[1].from_cache + assert len(received_events) == 1 + assert isinstance(received_events[0], ToolUsageFinishedEvent) + assert received_events[0].from_cache @pytest.mark.vcr(filter_headers=["authorization"]) @@ -908,6 +916,8 @@ def test_tool_result_as_answer_is_the_final_answer_for_the_agent(): @pytest.mark.vcr(filter_headers=["authorization"]) def test_tool_usage_information_is_appended_to_agent(): + from datetime import UTC, datetime + from crewai.tools import BaseTool class MyCustomTool(BaseTool): @@ -917,30 +927,36 @@ def test_tool_usage_information_is_appended_to_agent(): def _run(self) -> str: return "Howdy!" - agent1 = Agent( - role="Friendly Neighbor", - goal="Make everyone feel welcome", - backstory="You are the friendly neighbor", - tools=[MyCustomTool(result_as_answer=True)], - ) + fixed_datetime = datetime(2025, 2, 10, 12, 0, 0, tzinfo=UTC) + with patch("datetime.datetime") as mock_datetime: + mock_datetime.now.return_value = fixed_datetime + mock_datetime.side_effect = lambda *args, **kw: datetime(*args, **kw) - greeting = Task( - description="Say an appropriate greeting.", - expected_output="The greeting.", - agent=agent1, - ) - tasks = [greeting] - crew = Crew(agents=[agent1], tasks=tasks) + agent1 = Agent( + role="Friendly Neighbor", + goal="Make everyone feel welcome", + backstory="You are the friendly neighbor", + tools=[MyCustomTool(result_as_answer=True)], + ) - crew.kickoff() - assert agent1.tools_results == [ - { - "result": "Howdy!", - "tool_name": "Decide Greetings", - "tool_args": {}, - "result_as_answer": True, - } - ] + greeting = Task( + description="Say an appropriate greeting.", + expected_output="The greeting.", + agent=agent1, + ) + tasks = [greeting] + crew = Crew(agents=[agent1], tasks=tasks) + + crew.kickoff() + assert agent1.tools_results == [ + { + "result": "Howdy!", + "tool_name": "Decide Greetings", + "tool_args": {}, + "result_as_answer": True, + "start_time": fixed_datetime, + } + ] def test_agent_definition_based_on_dict(): diff --git a/tests/cassettes/test_tool_execution_error_event.yaml b/tests/cassettes/test_tool_execution_error_event.yaml new file mode 100644 index 000000000..61583726a --- /dev/null +++ b/tests/cassettes/test_tool_execution_error_event.yaml @@ -0,0 +1,112 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Use the failing tool"}], "model": + "gpt-4o-mini", "stop": [], "tools": [{"type": "function", "function": {"name": + "failing_tool", "description": "This tool always fails.", "parameters": {"type": + "object", "properties": {"param": {"type": "string", "description": "A test + parameter"}}, "required": ["param"]}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '353' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B2P4zoJZuES7Aom8ugEq1modz5Vsl\",\n \"object\": + \"chat.completion\",\n \"created\": 1739912761,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n + \ \"id\": \"call_F6fJxISpMKUBIGV6dd2vjRNG\",\n \"type\": + \"function\",\n \"function\": {\n \"name\": \"failing_tool\",\n + \ \"arguments\": \"{\\\"param\\\":\\\"test\\\"}\"\n }\n + \ }\n ],\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"tool_calls\"\n }\n ],\n \"usage\": {\n + \ \"prompt_tokens\": 51,\n \"completion_tokens\": 15,\n \"total_tokens\": + 66,\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 \"service_tier\": \"default\",\n \"system_fingerprint\": + \"fp_00428b782a\"\n}\n" + headers: + CF-RAY: + - 9140fa827f38eb1e-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 18 Feb 2025 21:06:02 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=xbuu3IQpCMh.43ZrqL1TRMECOc6QldgHV0hzOX1GrWI-1739912762-1.0.1.1-t7iyq5xMioPrwfeaHLvPT9rwRPp7Q9A9uIm69icH9dPxRD4xMA3cWqb1aXj1_e2IyAEQQWFe1UWjlmJ22aHh3Q; + path=/; expires=Tue, 18-Feb-25 21:36:02 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=x9l.Rhja8_wXDN.j8qcEU1PvvEqAwZp4Fd3s_aj4qwM-1739912762161-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 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '861' + 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: + - '149999978' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_8666ec3aa6677cb346ba00993556051d + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/crew_test.py b/tests/crew_test.py index 398be37de..6cd0370ae 100644 --- a/tests/crew_test.py +++ b/tests/crew_test.py @@ -6,7 +6,6 @@ from concurrent.futures import Future from unittest import mock from unittest.mock import MagicMock, patch -import instructor import pydantic_core import pytest @@ -18,13 +17,21 @@ from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSourc from crewai.llm import LLM from crewai.memory.contextual.contextual_memory import ContextualMemory from crewai.process import Process -from crewai.project import crew from crewai.task import Task from crewai.tasks.conditional_task import ConditionalTask from crewai.tasks.output_format import OutputFormat from crewai.tasks.task_output import TaskOutput from crewai.types.usage_metrics import UsageMetrics from crewai.utilities import Logger +from crewai.utilities.events import ( + CrewTrainCompletedEvent, + CrewTrainStartedEvent, + crewai_event_bus, +) +from crewai.utilities.events.crew_events import ( + CrewTestCompletedEvent, + CrewTestStartedEvent, +) from crewai.utilities.rpm_controller import RPMController from crewai.utilities.task_output_storage_handler import TaskOutputStorageHandler @@ -844,8 +851,21 @@ def test_crew_verbose_output(capsys): crew.verbose = False crew._logger = Logger(verbose=False) crew.kickoff() + expected_listener_logs = [ + "[🚀 CREW 'CREW' STARTED]", + "[📋 TASK STARTED: RESEARCH AI ADVANCEMENTS.]", + "[🤖 AGENT 'RESEARCHER' STARTED TASK]", + "[✅ AGENT 'RESEARCHER' COMPLETED TASK]", + "[✅ TASK COMPLETED: RESEARCH AI ADVANCEMENTS.]", + "[📋 TASK STARTED: WRITE ABOUT AI IN HEALTHCARE.]", + "[🤖 AGENT 'SENIOR WRITER' STARTED TASK]", + "[✅ AGENT 'SENIOR WRITER' COMPLETED TASK]", + "[✅ TASK COMPLETED: WRITE ABOUT AI IN HEALTHCARE.]", + "[✅ CREW 'CREW' COMPLETED]", + ] captured = capsys.readouterr() - assert captured.out == "" + for log in expected_listener_logs: + assert log in captured.out @pytest.mark.vcr(filter_headers=["authorization"]) @@ -1283,9 +1303,9 @@ def test_kickoff_for_each_invalid_input(): crew = Crew(agents=[agent], tasks=[task]) - with pytest.raises(TypeError): + with pytest.raises(pydantic_core._pydantic_core.ValidationError): # Pass a string instead of a list - crew.kickoff_for_each("invalid input") + crew.kickoff_for_each(["invalid input"]) def test_kickoff_for_each_error_handling(): @@ -2569,6 +2589,16 @@ def test_crew_train_success( # Create a mock for the copied crew copy_mock.return_value = crew + received_events = [] + + @crewai_event_bus.on(CrewTrainStartedEvent) + def on_crew_train_started(source, event: CrewTrainStartedEvent): + received_events.append(event) + + @crewai_event_bus.on(CrewTrainCompletedEvent) + def on_crew_train_completed(source, event: CrewTrainCompletedEvent): + received_events.append(event) + crew.train( n_iterations=2, inputs={"topic": "AI"}, filename="trained_agents_data.pkl" ) @@ -2614,6 +2644,10 @@ def test_crew_train_success( ] ) + assert len(received_events) == 2 + assert isinstance(received_events[0], CrewTrainStartedEvent) + assert isinstance(received_events[1], CrewTrainCompletedEvent) + def test_crew_train_error(): task = Task( @@ -3342,7 +3376,18 @@ def test_crew_testing_function(kickoff_mock, copy_mock, crew_evaluator): copy_mock.return_value = crew n_iterations = 2 - llm_instance = LLM('gpt-4o-mini') + llm_instance = LLM("gpt-4o-mini") + + received_events = [] + + @crewai_event_bus.on(CrewTestStartedEvent) + def on_crew_test_started(source, event: CrewTestStartedEvent): + received_events.append(event) + + @crewai_event_bus.on(CrewTestCompletedEvent) + def on_crew_test_completed(source, event: CrewTestCompletedEvent): + received_events.append(event) + crew.test(n_iterations, llm_instance, inputs={"topic": "AI"}) # Ensure kickoff is called on the copied crew @@ -3352,13 +3397,17 @@ def test_crew_testing_function(kickoff_mock, copy_mock, crew_evaluator): crew_evaluator.assert_has_calls( [ - mock.call(crew,llm_instance), + mock.call(crew, llm_instance), mock.call().set_iteration(1), mock.call().set_iteration(2), mock.call().print_crew_evaluation_result(), ] ) + assert len(received_events) == 2 + assert isinstance(received_events[0], CrewTestStartedEvent) + assert isinstance(received_events[1], CrewTestCompletedEvent) + @pytest.mark.vcr(filter_headers=["authorization"]) def test_hierarchical_verbose_manager_agent(): diff --git a/tests/flow/test_state_utils.py b/tests/flow/test_state_utils.py index 1f71cd981..1b135f36b 100644 --- a/tests/flow/test_state_utils.py +++ b/tests/flow/test_state_utils.py @@ -6,7 +6,7 @@ import pytest from pydantic import BaseModel from crewai.flow import Flow -from crewai.flow.state_utils import export_state +from crewai.flow.state_utils import export_state, to_string class Address(BaseModel): @@ -119,16 +119,10 @@ def test_pydantic_model_serialization(mock_flow): ) result = export_state(flow) - - assert result["single_model"]["street"] == "123 Main St" - - assert result["nested_model"]["name"] == "John Doe" - assert result["nested_model"]["address"]["city"] == "Tech City" - assert result["nested_model"]["birthday"] == "1994-01-01" - - assert len(result["model_list"]) == 2 - assert all(m["street"] == "123 Main St" for m in result["model_list"]) - assert result["model_dict"]["home"]["city"] == "Tech City" + assert ( + to_string(result) + == '{"single_model": {"street": "123 Main St", "city": "Tech City", "country": "Pythonia"}, "nested_model": {"name": "John Doe", "age": 30, "address": {"street": "123 Main St", "city": "Tech City", "country": "Pythonia"}, "birthday": "1994-01-01", "skills": ["Python", "Testing"]}, "model_list": [{"street": "123 Main St", "city": "Tech City", "country": "Pythonia"}, {"street": "123 Main St", "city": "Tech City", "country": "Pythonia"}], "model_dict": {"home": {"street": "123 Main St", "city": "Tech City", "country": "Pythonia"}}}' + ) def test_depth_limit(mock_flow): diff --git a/tests/flow_test.py b/tests/flow_test.py index d036f7987..b2edcfa5a 100644 --- a/tests/flow_test.py +++ b/tests/flow_test.py @@ -7,12 +7,14 @@ import pytest from pydantic import BaseModel from crewai.flow.flow import Flow, and_, listen, or_, router, start -from crewai.flow.flow_events import ( +from crewai.utilities.events import ( FlowFinishedEvent, FlowStartedEvent, MethodExecutionFinishedEvent, MethodExecutionStartedEvent, + crewai_event_bus, ) +from crewai.utilities.events.flow_events import FlowPlotEvent def test_simple_sequential_flow(): @@ -434,90 +436,65 @@ def test_unstructured_flow_event_emission(): @listen(finish_poem) def save_poem_to_database(self): # A method without args/kwargs to ensure events are sent correctly - pass - - event_log = [] - - def handle_event(_, event): - event_log.append(event) + return "roses are red\nviolets are blue" flow = PoemFlow() - flow.event_emitter.connect(handle_event) + received_events = [] + + @crewai_event_bus.on(FlowStartedEvent) + def handle_flow_start(source, event): + received_events.append(event) + + @crewai_event_bus.on(MethodExecutionStartedEvent) + def handle_method_start(source, event): + received_events.append(event) + + @crewai_event_bus.on(FlowFinishedEvent) + def handle_flow_end(source, event): + received_events.append(event) + flow.kickoff(inputs={"separator": ", "}) + assert isinstance(received_events[0], FlowStartedEvent) + assert received_events[0].flow_name == "PoemFlow" + assert received_events[0].inputs == {"separator": ", "} + assert isinstance(received_events[0].timestamp, datetime) - assert isinstance(event_log[0], FlowStartedEvent) - assert event_log[0].flow_name == "PoemFlow" - assert event_log[0].inputs == {"separator": ", "} - assert isinstance(event_log[0].timestamp, datetime) - - # Asserting for concurrent start method executions in a for loop as you - # can't guarantee ordering in asynchronous executions - for i in range(1, 5): - event = event_log[i] + # All subsequent events are MethodExecutionStartedEvent + for event in received_events[1:-1]: + assert isinstance(event, MethodExecutionStartedEvent) + assert event.flow_name == "PoemFlow" assert isinstance(event.state, dict) assert isinstance(event.state["id"], str) + assert event.state["separator"] == ", " - if event.method_name == "prepare_flower": - if isinstance(event, MethodExecutionStartedEvent): - assert event.params == {} - assert event.state["separator"] == ", " - elif isinstance(event, MethodExecutionFinishedEvent): - assert event.result == "foo" - assert event.state["flower"] == "roses" - assert event.state["separator"] == ", " - else: - assert False, "Unexpected event type for prepare_flower" - elif event.method_name == "prepare_color": - if isinstance(event, MethodExecutionStartedEvent): - assert event.params == {} - assert event.state["separator"] == ", " - elif isinstance(event, MethodExecutionFinishedEvent): - assert event.result == "bar" - assert event.state["color"] == "red" - assert event.state["separator"] == ", " - else: - assert False, "Unexpected event type for prepare_color" - else: - assert False, f"Unexpected method {event.method_name} in prepare events" + assert received_events[1].method_name == "prepare_flower" + assert received_events[1].params == {} + assert "flower" not in received_events[1].state - assert isinstance(event_log[5], MethodExecutionStartedEvent) - assert event_log[5].method_name == "write_first_sentence" - assert event_log[5].params == {} - assert isinstance(event_log[5].state, dict) - assert event_log[5].state["flower"] == "roses" - assert event_log[5].state["color"] == "red" - assert event_log[5].state["separator"] == ", " + assert received_events[2].method_name == "prepare_color" + assert received_events[2].params == {} + print("received_events[2]", received_events[2]) + assert "flower" in received_events[2].state - assert isinstance(event_log[6], MethodExecutionFinishedEvent) - assert event_log[6].method_name == "write_first_sentence" - assert event_log[6].result == "roses are red" + assert received_events[3].method_name == "write_first_sentence" + assert received_events[3].params == {} + assert received_events[3].state["flower"] == "roses" + assert received_events[3].state["color"] == "red" - assert isinstance(event_log[7], MethodExecutionStartedEvent) - assert event_log[7].method_name == "finish_poem" - assert event_log[7].params == {"_0": "roses are red"} - assert isinstance(event_log[7].state, dict) - assert event_log[7].state["flower"] == "roses" - assert event_log[7].state["color"] == "red" + assert received_events[4].method_name == "finish_poem" + assert received_events[4].params == {"_0": "roses are red"} + assert received_events[4].state["flower"] == "roses" + assert received_events[4].state["color"] == "red" - assert isinstance(event_log[8], MethodExecutionFinishedEvent) - assert event_log[8].method_name == "finish_poem" - assert event_log[8].result == "roses are red, violets are blue" + assert received_events[5].method_name == "save_poem_to_database" + assert received_events[5].params == {} + assert received_events[5].state["flower"] == "roses" + assert received_events[5].state["color"] == "red" - assert isinstance(event_log[9], MethodExecutionStartedEvent) - assert event_log[9].method_name == "save_poem_to_database" - assert event_log[9].params == {} - assert isinstance(event_log[9].state, dict) - assert event_log[9].state["flower"] == "roses" - assert event_log[9].state["color"] == "red" - - assert isinstance(event_log[10], MethodExecutionFinishedEvent) - assert event_log[10].method_name == "save_poem_to_database" - assert event_log[10].result is None - - assert isinstance(event_log[11], FlowFinishedEvent) - assert event_log[11].flow_name == "PoemFlow" - assert event_log[11].result is None - assert isinstance(event_log[11].timestamp, datetime) + assert isinstance(received_events[6], FlowFinishedEvent) + assert received_events[6].flow_name == "PoemFlow" + assert received_events[6].result == "roses are red\nviolets are blue" + assert isinstance(received_events[6].timestamp, datetime) def test_structured_flow_event_emission(): @@ -538,40 +515,54 @@ def test_structured_flow_event_emission(): self.state.sent = True return f"Welcome, {self.state.name}!" - event_log = [] - - def handle_event(_, event): - event_log.append(event) - flow = OnboardingFlow() - flow.event_emitter.connect(handle_event) flow.kickoff(inputs={"name": "Anakin"}) - assert isinstance(event_log[0], FlowStartedEvent) - assert event_log[0].flow_name == "OnboardingFlow" - assert event_log[0].inputs == {"name": "Anakin"} - assert isinstance(event_log[0].timestamp, datetime) + received_events = [] - assert isinstance(event_log[1], MethodExecutionStartedEvent) - assert event_log[1].method_name == "user_signs_up" + @crewai_event_bus.on(FlowStartedEvent) + def handle_flow_start(source, event): + received_events.append(event) - assert isinstance(event_log[2], MethodExecutionFinishedEvent) - assert event_log[2].method_name == "user_signs_up" + @crewai_event_bus.on(MethodExecutionStartedEvent) + def handle_method_start(source, event): + received_events.append(event) - assert isinstance(event_log[3], MethodExecutionStartedEvent) - assert event_log[3].method_name == "send_welcome_message" - assert event_log[3].params == {} - assert getattr(event_log[3].state, "sent") is False + @crewai_event_bus.on(MethodExecutionFinishedEvent) + def handle_method_end(source, event): + received_events.append(event) - assert isinstance(event_log[4], MethodExecutionFinishedEvent) - assert event_log[4].method_name == "send_welcome_message" - assert getattr(event_log[4].state, "sent") is True - assert event_log[4].result == "Welcome, Anakin!" + @crewai_event_bus.on(FlowFinishedEvent) + def handle_flow_end(source, event): + received_events.append(event) - assert isinstance(event_log[5], FlowFinishedEvent) - assert event_log[5].flow_name == "OnboardingFlow" - assert event_log[5].result == "Welcome, Anakin!" - assert isinstance(event_log[5].timestamp, datetime) + flow.kickoff(inputs={"name": "Anakin"}) + + assert isinstance(received_events[0], FlowStartedEvent) + assert received_events[0].flow_name == "OnboardingFlow" + assert received_events[0].inputs == {"name": "Anakin"} + assert isinstance(received_events[0].timestamp, datetime) + + assert isinstance(received_events[1], MethodExecutionStartedEvent) + assert received_events[1].method_name == "user_signs_up" + + assert isinstance(received_events[2], MethodExecutionFinishedEvent) + assert received_events[2].method_name == "user_signs_up" + + assert isinstance(received_events[3], MethodExecutionStartedEvent) + assert received_events[3].method_name == "send_welcome_message" + assert received_events[3].params == {} + assert getattr(received_events[3].state, "sent") is False + + assert isinstance(received_events[4], MethodExecutionFinishedEvent) + assert received_events[4].method_name == "send_welcome_message" + assert getattr(received_events[4].state, "sent") is True + assert received_events[4].result == "Welcome, Anakin!" + + assert isinstance(received_events[5], FlowFinishedEvent) + assert received_events[5].flow_name == "OnboardingFlow" + assert received_events[5].result == "Welcome, Anakin!" + assert isinstance(received_events[5].timestamp, datetime) def test_stateless_flow_event_emission(): @@ -593,30 +584,73 @@ def test_stateless_flow_event_emission(): event_log.append(event) flow = StatelessFlow() - flow.event_emitter.connect(handle_event) + received_events = [] + + @crewai_event_bus.on(FlowStartedEvent) + def handle_flow_start(source, event): + received_events.append(event) + + @crewai_event_bus.on(MethodExecutionStartedEvent) + def handle_method_start(source, event): + received_events.append(event) + + @crewai_event_bus.on(MethodExecutionFinishedEvent) + def handle_method_end(source, event): + received_events.append(event) + + @crewai_event_bus.on(FlowFinishedEvent) + def handle_flow_end(source, event): + received_events.append(event) + flow.kickoff() - assert isinstance(event_log[0], FlowStartedEvent) - assert event_log[0].flow_name == "StatelessFlow" - assert event_log[0].inputs is None - assert isinstance(event_log[0].timestamp, datetime) + assert isinstance(received_events[0], FlowStartedEvent) + assert received_events[0].flow_name == "StatelessFlow" + assert received_events[0].inputs is None + assert isinstance(received_events[0].timestamp, datetime) - assert isinstance(event_log[1], MethodExecutionStartedEvent) - assert event_log[1].method_name == "init" + assert isinstance(received_events[1], MethodExecutionStartedEvent) + assert received_events[1].method_name == "init" - assert isinstance(event_log[2], MethodExecutionFinishedEvent) - assert event_log[2].method_name == "init" + assert isinstance(received_events[2], MethodExecutionFinishedEvent) + assert received_events[2].method_name == "init" - assert isinstance(event_log[3], MethodExecutionStartedEvent) - assert event_log[3].method_name == "process" + assert isinstance(received_events[3], MethodExecutionStartedEvent) + assert received_events[3].method_name == "process" - assert isinstance(event_log[4], MethodExecutionFinishedEvent) - assert event_log[4].method_name == "process" + assert isinstance(received_events[4], MethodExecutionFinishedEvent) + assert received_events[4].method_name == "process" - assert isinstance(event_log[5], FlowFinishedEvent) - assert event_log[5].flow_name == "StatelessFlow" + assert isinstance(received_events[5], FlowFinishedEvent) + assert received_events[5].flow_name == "StatelessFlow" assert ( - event_log[5].result + received_events[5].result == "Deeds will not be less valiant because they are unpraised." ) - assert isinstance(event_log[5].timestamp, datetime) + assert isinstance(received_events[5].timestamp, datetime) + + +def test_flow_plotting(): + class StatelessFlow(Flow): + @start() + def init(self): + return "Initializing flow..." + + @listen(init) + def process(self): + return "Deeds will not be less valiant because they are unpraised." + + flow = StatelessFlow() + flow.kickoff() + received_events = [] + + @crewai_event_bus.on(FlowPlotEvent) + def handle_flow_plot(source, event): + received_events.append(event) + + flow.plot("test_flow") + + assert len(received_events) == 1 + assert isinstance(received_events[0], FlowPlotEvent) + assert received_events[0].flow_name == "StatelessFlow" + assert isinstance(received_events[0].timestamp, datetime) diff --git a/tests/llm_test.py b/tests/llm_test.py index 2e5faf774..00bb69aa5 100644 --- a/tests/llm_test.py +++ b/tests/llm_test.py @@ -7,7 +7,8 @@ from pydantic import BaseModel from crewai.agents.agent_builder.utilities.base_token_process import TokenProcess from crewai.llm import LLM -from crewai.tools import tool +from crewai.utilities.events import crewai_event_bus +from crewai.utilities.events.tool_usage_events import ToolExecutionErrorEvent from crewai.utilities.token_counter_callback import TokenCalcHandler @@ -291,32 +292,36 @@ def anthropic_llm(): """Fixture providing an Anthropic LLM instance.""" return LLM(model="anthropic/claude-3-sonnet") + @pytest.fixture def system_message(): """Fixture providing a system message.""" return {"role": "system", "content": "test"} + @pytest.fixture def user_message(): """Fixture providing a user message.""" return {"role": "user", "content": "test"} + def test_anthropic_message_formatting_edge_cases(anthropic_llm): """Test edge cases for Anthropic message formatting.""" # Test None messages with pytest.raises(TypeError, match="Messages cannot be None"): anthropic_llm._format_messages_for_provider(None) - + # Test empty message list formatted = anthropic_llm._format_messages_for_provider([]) assert len(formatted) == 1 assert formatted[0]["role"] == "user" assert formatted[0]["content"] == "." - + # Test invalid message format with pytest.raises(TypeError, match="Invalid message format"): anthropic_llm._format_messages_for_provider([{"invalid": "message"}]) + def test_anthropic_model_detection(): """Test Anthropic model detection with various formats.""" models = [ @@ -327,11 +332,12 @@ def test_anthropic_model_detection(): ("", False), ("anthropomorphic", False), # Should not match partial words ] - + for model, expected in models: llm = LLM(model=model) assert llm.is_anthropic == expected, f"Failed for model: {model}" + def test_anthropic_message_formatting(anthropic_llm, system_message, user_message): """Test Anthropic message formatting with fixtures.""" # Test when first message is system @@ -371,3 +377,51 @@ def test_deepseek_r1_with_open_router(): result = llm.call("What is the capital of France?") assert isinstance(result, str) assert "Paris" in result + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_tool_execution_error_event(): + llm = LLM(model="gpt-4o-mini") + + def failing_tool(param: str) -> str: + """This tool always fails.""" + raise Exception("Tool execution failed!") + + tool_schema = { + "type": "function", + "function": { + "name": "failing_tool", + "description": "This tool always fails.", + "parameters": { + "type": "object", + "properties": { + "param": {"type": "string", "description": "A test parameter"} + }, + "required": ["param"], + }, + }, + } + + received_events = [] + + @crewai_event_bus.on(ToolExecutionErrorEvent) + def event_handler(source, event): + received_events.append(event) + + available_functions = {"failing_tool": failing_tool} + + messages = [{"role": "user", "content": "Use the failing tool"}] + + llm.call( + messages, + tools=[tool_schema], + available_functions=available_functions, + ) + + assert len(received_events) == 1 + event = received_events[0] + assert isinstance(event, ToolExecutionErrorEvent) + assert event.tool_name == "failing_tool" + assert event.tool_args == {"param": "test"} + assert event.tool_class == failing_tool + assert "Tool execution failed!" in event.error diff --git a/tests/test_flow_persistence.py b/tests/test_flow_persistence.py index e51806b05..cf3bb22f0 100644 --- a/tests/test_flow_persistence.py +++ b/tests/test_flow_persistence.py @@ -13,11 +13,12 @@ from crewai.flow.persistence.sqlite import SQLiteFlowPersistence class TestState(FlowState): """Test state model with required id field.""" + counter: int = 0 message: str = "" -def test_persist_decorator_saves_state(tmp_path): +def test_persist_decorator_saves_state(tmp_path, caplog): """Test that @persist decorator saves state in SQLite.""" db_path = os.path.join(tmp_path, "test_flows.db") persistence = SQLiteFlowPersistence(db_path) @@ -73,7 +74,6 @@ def test_flow_state_restoration(tmp_path): # First flow execution to create initial state class RestorableFlow(Flow[TestState]): - @start() @persist(persistence) def set_message(self): @@ -89,10 +89,7 @@ def test_flow_state_restoration(tmp_path): # Test case 1: Restore using restore_uuid with field override flow2 = RestorableFlow(persistence=persistence) - flow2.kickoff(inputs={ - "id": original_uuid, - "counter": 43 - }) + flow2.kickoff(inputs={"id": original_uuid, "counter": 43}) # Verify state restoration and selective field override assert flow2.state.id == original_uuid @@ -101,10 +98,7 @@ def test_flow_state_restoration(tmp_path): # Test case 2: Restore using kwargs['id'] flow3 = RestorableFlow(persistence=persistence) - flow3.kickoff(inputs={ - "id": original_uuid, - "message": "Updated message" - }) + flow3.kickoff(inputs={"id": original_uuid, "message": "Updated message"}) # Verify state restoration and selective field override assert flow3.state.id == original_uuid @@ -174,3 +168,43 @@ def test_multiple_method_persistence(tmp_path): final_state = flow2.state assert final_state.counter == 99999 assert final_state.message == "Step 99999" + + +def test_persist_decorator_verbose_logging(tmp_path, caplog): + """Test that @persist decorator's verbose parameter controls logging.""" + # Set logging level to ensure we capture all logs + caplog.set_level("INFO") + + db_path = os.path.join(tmp_path, "test_flows.db") + persistence = SQLiteFlowPersistence(db_path) + + # Test with verbose=False (default) + class QuietFlow(Flow[Dict[str, str]]): + initial_state = dict() + + @start() + @persist(persistence) # Default verbose=False + def init_step(self): + self.state["message"] = "Hello, World!" + self.state["id"] = "test-uuid-1" + + flow = QuietFlow(persistence=persistence) + flow.kickoff() + assert "Saving flow state" not in caplog.text + + # Clear the log + caplog.clear() + + # Test with verbose=True + class VerboseFlow(Flow[Dict[str, str]]): + initial_state = dict() + + @start() + @persist(persistence, verbose=True) + def init_step(self): + self.state["message"] = "Hello, World!" + self.state["id"] = "test-uuid-2" + + flow = VerboseFlow(persistence=persistence) + flow.kickoff() + assert "Saving flow state" in caplog.text diff --git a/tests/tools/test_tool_usage.py b/tests/tools/test_tool_usage.py index 7b2ccd416..e09d4d537 100644 --- a/tests/tools/test_tool_usage.py +++ b/tests/tools/test_tool_usage.py @@ -1,6 +1,6 @@ import json import random -from unittest.mock import MagicMock +from unittest.mock import MagicMock, patch import pytest from pydantic import BaseModel, Field @@ -8,6 +8,11 @@ from pydantic import BaseModel, Field from crewai import Agent, Task from crewai.tools import BaseTool from crewai.tools.tool_usage import ToolUsage +from crewai.utilities.events import crewai_event_bus +from crewai.utilities.events.tool_usage_events import ( + ToolSelectionErrorEvent, + ToolValidateInputErrorEvent, +) class RandomNumberToolInput(BaseModel): @@ -226,7 +231,7 @@ def test_validate_tool_input_with_special_characters(): ) # Input with special characters - tool_input = '{"message": "Hello, world! \u263A", "valid": True}' + tool_input = '{"message": "Hello, world! \u263a", "valid": True}' expected_arguments = {"message": "Hello, world! ☺", "valid": True} arguments = tool_usage._validate_tool_input(tool_input) @@ -331,6 +336,19 @@ def test_validate_tool_input_with_trailing_commas(): def test_validate_tool_input_invalid_input(): + # Create mock agent with proper string values + mock_agent = MagicMock() + mock_agent.key = "test_agent_key" # Must be a string + mock_agent.role = "test_agent_role" # Must be a string + mock_agent._original_role = "test_agent_role" # Must be a string + mock_agent.i18n = MagicMock() + mock_agent.verbose = False + + # Create mock action with proper string value + mock_action = MagicMock() + mock_action.tool = "test_tool" # Must be a string + mock_action.tool_input = "test_input" # Must be a string + tool_usage = ToolUsage( tools_handler=MagicMock(), tools=[], @@ -339,8 +357,8 @@ def test_validate_tool_input_invalid_input(): tools_names="", task=MagicMock(), function_calling_llm=None, - agent=MagicMock(), - action=MagicMock(), + agent=mock_agent, + action=mock_action, ) invalid_inputs = [ @@ -360,7 +378,7 @@ def test_validate_tool_input_invalid_input(): # Test for None input separately arguments = tool_usage._validate_tool_input(None) - assert arguments == {} # Expecting an empty dictionary + assert arguments == {} def test_validate_tool_input_complex_structure(): @@ -468,18 +486,141 @@ def test_validate_tool_input_large_json_content(): assert arguments == expected_arguments -def test_validate_tool_input_none_input(): +def test_tool_selection_error_event_direct(): + """Test tool selection error event emission directly from ToolUsage class.""" + mock_agent = MagicMock() + mock_agent.key = "test_key" + mock_agent.role = "test_role" + mock_agent.i18n = MagicMock() + mock_agent.verbose = False + + mock_task = MagicMock() + mock_tools_handler = MagicMock() + + class TestTool(BaseTool): + name: str = "Test Tool" + description: str = "A test tool" + + def _run(self, input: dict) -> str: + return "test result" + + test_tool = TestTool() + tool_usage = ToolUsage( - tools_handler=MagicMock(), - tools=[], - original_tools=[], - tools_description="", - tools_names="", - task=MagicMock(), + tools_handler=mock_tools_handler, + tools=[test_tool], + original_tools=[test_tool], + tools_description="Test Tool Description", + tools_names="Test Tool", + task=mock_task, function_calling_llm=None, - agent=MagicMock(), + agent=mock_agent, action=MagicMock(), ) - arguments = tool_usage._validate_tool_input(None) - assert arguments == {} # Expecting an empty dictionary + received_events = [] + + @crewai_event_bus.on(ToolSelectionErrorEvent) + def event_handler(source, event): + received_events.append(event) + + with pytest.raises(Exception) as exc_info: + tool_usage._select_tool("Non Existent Tool") + assert len(received_events) == 1 + event = received_events[0] + assert isinstance(event, ToolSelectionErrorEvent) + assert event.agent_key == "test_key" + assert event.agent_role == "test_role" + assert event.tool_name == "Non Existent Tool" + assert event.tool_args == {} + assert event.tool_class == "Test Tool Description" + assert "don't exist" in event.error + + received_events.clear() + with pytest.raises(Exception) as exc_info: + tool_usage._select_tool("") + + assert len(received_events) == 1 + event = received_events[0] + assert isinstance(event, ToolSelectionErrorEvent) + assert event.agent_key == "test_key" + assert event.agent_role == "test_role" + assert event.tool_name == "" + assert event.tool_args == {} + assert event.tool_class == "Test Tool Description" + assert "forgot the Action name" in event.error + + +def test_tool_validate_input_error_event(): + """Test tool validation input error event emission from ToolUsage class.""" + # Mock agent and required components + mock_agent = MagicMock() + mock_agent.key = "test_key" + mock_agent.role = "test_role" + mock_agent.verbose = False + mock_agent._original_role = "test_role" + + # Mock i18n with error message + mock_i18n = MagicMock() + mock_i18n.errors.return_value = ( + "Tool input must be a valid dictionary in JSON or Python literal format" + ) + mock_agent.i18n = mock_i18n + + # Mock task and tools handler + mock_task = MagicMock() + mock_tools_handler = MagicMock() + + # Mock printer + mock_printer = MagicMock() + + # Create test tool + class TestTool(BaseTool): + name: str = "Test Tool" + description: str = "A test tool" + + def _run(self, input: dict) -> str: + return "test result" + + test_tool = TestTool() + + # Create ToolUsage instance + tool_usage = ToolUsage( + tools_handler=mock_tools_handler, + tools=[test_tool], + original_tools=[test_tool], + tools_description="Test Tool Description", + tools_names="Test Tool", + task=mock_task, + function_calling_llm=None, + agent=mock_agent, + action=MagicMock(tool="test_tool"), + ) + tool_usage._printer = mock_printer + + # Mock all parsing attempts to fail + with ( + patch("json.loads", side_effect=json.JSONDecodeError("Test Error", "", 0)), + patch("ast.literal_eval", side_effect=ValueError), + patch("json5.loads", side_effect=json.JSONDecodeError("Test Error", "", 0)), + patch("json_repair.repair_json", side_effect=Exception("Failed to repair")), + ): + received_events = [] + + @crewai_event_bus.on(ToolValidateInputErrorEvent) + def event_handler(source, event): + received_events.append(event) + + # Test invalid input + invalid_input = "invalid json {[}" + with pytest.raises(Exception) as exc_info: + tool_usage._validate_tool_input(invalid_input) + + # Verify event was emitted + assert len(received_events) == 1, "Expected one event to be emitted" + event = received_events[0] + assert isinstance(event, ToolValidateInputErrorEvent) + assert event.agent_key == "test_key" + assert event.agent_role == "test_role" + assert event.tool_name == "test_tool" + assert "must be a valid dictionary" in event.error diff --git a/tests/traces/test_unified_trace_controller.py b/tests/traces/test_unified_trace_controller.py new file mode 100644 index 000000000..b14fb5d2d --- /dev/null +++ b/tests/traces/test_unified_trace_controller.py @@ -0,0 +1,360 @@ +import os +from datetime import UTC, datetime +from unittest.mock import MagicMock, patch +from uuid import UUID + +import pytest + +from crewai.traces.context import TraceContext +from crewai.traces.enums import CrewType, RunType, TraceType +from crewai.traces.models import ( + CrewTrace, + FlowStepIO, + LLMRequest, + LLMResponse, +) +from crewai.traces.unified_trace_controller import ( + UnifiedTraceController, + init_crew_main_trace, + init_flow_main_trace, + should_trace, + trace_flow_step, + trace_llm_call, +) + + +class TestUnifiedTraceController: + @pytest.fixture + def basic_trace_controller(self): + return UnifiedTraceController( + trace_type=TraceType.LLM_CALL, + run_type=RunType.KICKOFF, + crew_type=CrewType.CREW, + run_id="test-run-id", + agent_role="test-agent", + task_name="test-task", + task_description="test description", + task_id="test-task-id", + ) + + def test_initialization(self, basic_trace_controller): + """Test basic initialization of UnifiedTraceController""" + assert basic_trace_controller.trace_type == TraceType.LLM_CALL + assert basic_trace_controller.run_type == RunType.KICKOFF + assert basic_trace_controller.crew_type == CrewType.CREW + assert basic_trace_controller.run_id == "test-run-id" + assert basic_trace_controller.agent_role == "test-agent" + assert basic_trace_controller.task_name == "test-task" + assert basic_trace_controller.task_description == "test description" + assert basic_trace_controller.task_id == "test-task-id" + assert basic_trace_controller.status == "running" + assert isinstance(UUID(basic_trace_controller.trace_id), UUID) + + def test_start_trace(self, basic_trace_controller): + """Test starting a trace""" + result = basic_trace_controller.start_trace() + assert result == basic_trace_controller + assert basic_trace_controller.start_time is not None + assert isinstance(basic_trace_controller.start_time, datetime) + + def test_end_trace_success(self, basic_trace_controller): + """Test ending a trace successfully""" + basic_trace_controller.start_trace() + basic_trace_controller.end_trace(result={"test": "result"}) + + assert basic_trace_controller.end_time is not None + assert basic_trace_controller.status == "completed" + assert basic_trace_controller.error is None + assert basic_trace_controller.context.get("response") == {"test": "result"} + + def test_end_trace_with_error(self, basic_trace_controller): + """Test ending a trace with an error""" + basic_trace_controller.start_trace() + basic_trace_controller.end_trace(error="Test error occurred") + + assert basic_trace_controller.end_time is not None + assert basic_trace_controller.status == "error" + assert basic_trace_controller.error == "Test error occurred" + + def test_add_child_trace(self, basic_trace_controller): + """Test adding a child trace""" + child_trace = {"id": "child-1", "type": "test"} + basic_trace_controller.add_child_trace(child_trace) + assert len(basic_trace_controller.children) == 1 + assert basic_trace_controller.children[0] == child_trace + + def test_to_crew_trace_llm_call(self): + """Test converting to CrewTrace for LLM call""" + test_messages = [{"role": "user", "content": "test"}] + test_response = { + "content": "test response", + "finish_reason": "stop", + } + + controller = UnifiedTraceController( + trace_type=TraceType.LLM_CALL, + run_type=RunType.KICKOFF, + crew_type=CrewType.CREW, + run_id="test-run-id", + context={ + "messages": test_messages, + "temperature": 0.7, + "max_tokens": 100, + }, + ) + + # Set model and messages in the context + controller.context["model"] = "gpt-4" + controller.context["messages"] = test_messages + + controller.start_trace() + controller.end_trace(result=test_response) + + crew_trace = controller.to_crew_trace() + assert isinstance(crew_trace, CrewTrace) + assert isinstance(crew_trace.request, LLMRequest) + assert isinstance(crew_trace.response, LLMResponse) + assert crew_trace.request.model == "gpt-4" + assert crew_trace.request.messages == test_messages + assert crew_trace.response.content == test_response["content"] + assert crew_trace.response.finish_reason == test_response["finish_reason"] + + def test_to_crew_trace_flow_step(self): + """Test converting to CrewTrace for flow step""" + flow_step_data = { + "function_name": "test_function", + "inputs": {"param1": "value1"}, + "metadata": {"meta": "data"}, + } + + controller = UnifiedTraceController( + trace_type=TraceType.FLOW_STEP, + run_type=RunType.KICKOFF, + crew_type=CrewType.FLOW, + run_id="test-run-id", + flow_step=flow_step_data, + ) + + controller.start_trace() + controller.end_trace(result="test result") + + crew_trace = controller.to_crew_trace() + assert isinstance(crew_trace, CrewTrace) + assert isinstance(crew_trace.flow_step, FlowStepIO) + assert crew_trace.flow_step.function_name == "test_function" + assert crew_trace.flow_step.inputs == {"param1": "value1"} + assert crew_trace.flow_step.outputs == {"result": "test result"} + + def test_should_trace(self): + """Test should_trace function""" + with patch.dict(os.environ, {"CREWAI_ENABLE_TRACING": "true"}): + assert should_trace() is True + + with patch.dict(os.environ, {"CREWAI_ENABLE_TRACING": "false"}): + assert should_trace() is False + + with patch.dict(os.environ, clear=True): + assert should_trace() is False + + @pytest.mark.asyncio + async def test_trace_flow_step_decorator(self): + """Test trace_flow_step decorator""" + + class TestFlow: + flow_id = "test-flow-id" + + @trace_flow_step + async def test_method(self, method_name, method, *args, **kwargs): + return "test result" + + with patch.dict(os.environ, {"CREWAI_ENABLE_TRACING": "true"}): + flow = TestFlow() + result = await flow.test_method("test_method", lambda x: x, arg1="value1") + assert result == "test result" + + def test_trace_llm_call_decorator(self): + """Test trace_llm_call decorator""" + + class TestLLM: + model = "gpt-4" + temperature = 0.7 + max_tokens = 100 + stop = None + + def _get_execution_context(self): + return MagicMock(), MagicMock() + + def _get_new_messages(self, messages): + return messages + + def _get_new_tool_results(self, agent): + return [] + + @trace_llm_call + def test_method(self, params): + return { + "choices": [ + { + "message": {"content": "test response"}, + "finish_reason": "stop", + } + ], + "usage": { + "total_tokens": 50, + "prompt_tokens": 20, + "completion_tokens": 30, + }, + } + + with patch.dict(os.environ, {"CREWAI_ENABLE_TRACING": "true"}): + llm = TestLLM() + result = llm.test_method({"messages": []}) + assert result["choices"][0]["message"]["content"] == "test response" + + def test_init_crew_main_trace_kickoff(self): + """Test init_crew_main_trace in kickoff mode""" + trace_context = None + + class TestCrew: + id = "test-crew-id" + _test = False + _train = False + + @init_crew_main_trace + def test_method(self): + nonlocal trace_context + trace_context = TraceContext.get_current() + return "test result" + + with patch.dict(os.environ, {"CREWAI_ENABLE_TRACING": "true"}): + crew = TestCrew() + result = test_method(crew) + assert result == "test result" + assert trace_context is not None + assert trace_context.trace_type == TraceType.LLM_CALL + assert trace_context.run_type == RunType.KICKOFF + assert trace_context.crew_type == CrewType.CREW + assert trace_context.run_id == str(crew.id) + + def test_init_crew_main_trace_test_mode(self): + """Test init_crew_main_trace in test mode""" + trace_context = None + + class TestCrew: + id = "test-crew-id" + _test = True + _train = False + + @init_crew_main_trace + def test_method(self): + nonlocal trace_context + trace_context = TraceContext.get_current() + return "test result" + + with patch.dict(os.environ, {"CREWAI_ENABLE_TRACING": "true"}): + crew = TestCrew() + result = test_method(crew) + assert result == "test result" + assert trace_context is not None + assert trace_context.run_type == RunType.TEST + + def test_init_crew_main_trace_train_mode(self): + """Test init_crew_main_trace in train mode""" + trace_context = None + + class TestCrew: + id = "test-crew-id" + _test = False + _train = True + + @init_crew_main_trace + def test_method(self): + nonlocal trace_context + trace_context = TraceContext.get_current() + return "test result" + + with patch.dict(os.environ, {"CREWAI_ENABLE_TRACING": "true"}): + crew = TestCrew() + result = test_method(crew) + assert result == "test result" + assert trace_context is not None + assert trace_context.run_type == RunType.TRAIN + + @pytest.mark.asyncio + async def test_init_flow_main_trace(self): + """Test init_flow_main_trace decorator""" + trace_context = None + test_inputs = {"test": "input"} + + class TestFlow: + flow_id = "test-flow-id" + + @init_flow_main_trace + async def test_method(self, **kwargs): + nonlocal trace_context + trace_context = TraceContext.get_current() + # Verify the context is set during execution + assert trace_context.context["context"]["inputs"] == test_inputs + return "test result" + + with patch.dict(os.environ, {"CREWAI_ENABLE_TRACING": "true"}): + flow = TestFlow() + result = await flow.test_method(inputs=test_inputs) + assert result == "test result" + assert trace_context is not None + assert trace_context.trace_type == TraceType.FLOW_STEP + assert trace_context.crew_type == CrewType.FLOW + assert trace_context.run_type == RunType.KICKOFF + assert trace_context.run_id == str(flow.flow_id) + assert trace_context.context["context"]["inputs"] == test_inputs + + def test_trace_context_management(self): + """Test TraceContext management""" + trace1 = UnifiedTraceController( + trace_type=TraceType.LLM_CALL, + run_type=RunType.KICKOFF, + crew_type=CrewType.CREW, + run_id="test-run-1", + ) + + trace2 = UnifiedTraceController( + trace_type=TraceType.FLOW_STEP, + run_type=RunType.TEST, + crew_type=CrewType.FLOW, + run_id="test-run-2", + ) + + # Test that context is initially empty + assert TraceContext.get_current() is None + + # Test setting and getting context + with TraceContext.set_current(trace1): + assert TraceContext.get_current() == trace1 + + # Test nested context + with TraceContext.set_current(trace2): + assert TraceContext.get_current() == trace2 + + # Test context restoration after nested block + assert TraceContext.get_current() == trace1 + + # Test context cleanup after with block + assert TraceContext.get_current() is None + + def test_trace_context_error_handling(self): + """Test TraceContext error handling""" + trace = UnifiedTraceController( + trace_type=TraceType.LLM_CALL, + run_type=RunType.KICKOFF, + crew_type=CrewType.CREW, + run_id="test-run", + ) + + # Test that context is properly cleaned up even if an error occurs + try: + with TraceContext.set_current(trace): + raise ValueError("Test error") + except ValueError: + pass + + assert TraceContext.get_current() is None diff --git a/tests/utilities/cassettes/test_agent_emits_execution_started_and_completed_events.yaml b/tests/utilities/cassettes/test_agent_emits_execution_started_and_completed_events.yaml new file mode 100644 index 000000000..3a142e7af --- /dev/null +++ b/tests/utilities/cassettes/test_agent_emits_execution_started_and_completed_events.yaml @@ -0,0 +1,243 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nTo + give my best complete final answer to the task respond using 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: Just say hi\n\nThis is the expect criteria for your + final answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '836' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AzTXAk4GatJOmLO9sEOCCITIjf1Dx\",\n \"object\": + \"chat.completion\",\n \"created\": 1739214900,\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: hi\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 161,\n \"completion_tokens\": 12,\n \"total_tokens\": 173,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 90fe6ce92eba67b3-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 10 Feb 2025 19:15:01 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=pjX1I6y8RlqCjS.gvOqvXk4vM69UNwFwmslh1BhALNg-1739214901-1.0.1.1-nJcNlSdNcug82eDl7KSvteLbsg0xCiEh2yI1TZX2jMAblL7AMQ8LFhvXkJLlAMfk49RMzRzWy2aiQgeM7WRHPg; + path=/; expires=Mon, 10-Feb-25 19:45:01 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=efIHP1NUsh1dFewGJBu4YoBu6hhGa8vjOOKQglYQGno-1739214901306-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 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '571' + 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: + - '149999810' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_a95183a7a85e6bdfe381b2510bf70f34 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "Assess the quality of the task + completed based on the description, expected output, and actual results.\n\nTask + Description:\nJust say hi\n\nExpected Output:\nhi\n\nActual Output:\nhi\n\nPlease + provide:\n- Bullet points suggestions to improve future similar tasks\n- A score + from 0 to 10 evaluating on completion, quality, and overall performance- Entities + extracted from the task output, if any, their type, description, and relationships"}], + "model": "gpt-4o-mini", "tool_choice": {"type": "function", "function": {"name": + "TaskEvaluation"}}, "tools": [{"type": "function", "function": {"name": "TaskEvaluation", + "description": "Correctly extracted `TaskEvaluation` with all the required parameters + with correct types", "parameters": {"$defs": {"Entity": {"properties": {"name": + {"description": "The name of the entity.", "title": "Name", "type": "string"}, + "type": {"description": "The type of the entity.", "title": "Type", "type": + "string"}, "description": {"description": "Description of the entity.", "title": + "Description", "type": "string"}, "relationships": {"description": "Relationships + of the entity.", "items": {"type": "string"}, "title": "Relationships", "type": + "array"}}, "required": ["name", "type", "description", "relationships"], "title": + "Entity", "type": "object"}}, "properties": {"suggestions": {"description": + "Suggestions to improve future similar tasks.", "items": {"type": "string"}, + "title": "Suggestions", "type": "array"}, "quality": {"description": "A score + from 0 to 10 evaluating on completion, quality, and overall performance, all + taking into account the task description, expected output, and the result of + the task.", "title": "Quality", "type": "number"}, "entities": {"description": + "Entities extracted from the task output.", "items": {"$ref": "#/$defs/Entity"}, + "title": "Entities", "type": "array"}}, "required": ["entities", "quality", + "suggestions"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1962' + content-type: + - application/json + cookie: + - __cf_bm=pjX1I6y8RlqCjS.gvOqvXk4vM69UNwFwmslh1BhALNg-1739214901-1.0.1.1-nJcNlSdNcug82eDl7KSvteLbsg0xCiEh2yI1TZX2jMAblL7AMQ8LFhvXkJLlAMfk49RMzRzWy2aiQgeM7WRHPg; + _cfuvid=efIHP1NUsh1dFewGJBu4YoBu6hhGa8vjOOKQglYQGno-1739214901306-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AzTXDcgKWq3yosIyBal8LcY8dDrn1\",\n \"object\": + \"chat.completion\",\n \"created\": 1739214903,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n + \ \"id\": \"call_c41SAnqyEKNXEAZd5XV3jKF3\",\n \"type\": + \"function\",\n \"function\": {\n \"name\": \"TaskEvaluation\",\n + \ \"arguments\": \"{\\\"suggestions\\\":[\\\"Consider specifying + the tone or context of the greeting for more engaging interactions.\\\",\\\"Clarify + if additional greetings or responses are acceptable to enhance the task's scope.\\\"],\\\"quality\\\":10,\\\"entities\\\":[] + }\"\n }\n }\n ],\n \"refusal\": null\n },\n + \ \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }\n ],\n + \ \"usage\": {\n \"prompt_tokens\": 273,\n \"completion_tokens\": 43,\n + \ \"total_tokens\": 316,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 90fe6cf8c96e67b3-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 10 Feb 2025 19:15:04 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: + - '1181' + 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: + - '149999876' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_b2286c8ae6f9b2a42f46a3e2c52b4211 + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_crew_emits_end_kickoff_event.yaml b/tests/utilities/cassettes/test_crew_emits_end_kickoff_event.yaml new file mode 100644 index 000000000..c20dc4d92 --- /dev/null +++ b/tests/utilities/cassettes/test_crew_emits_end_kickoff_event.yaml @@ -0,0 +1,315 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nTo + give my best complete final answer to the task respond using 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: Just say hi\n\nThis is the expect criteria for your + final answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '836' + content-type: + - application/json + cookie: + - __cf_bm=4s6sWmJ49B9F_wNc1STtdZF1nikfl6uN9_ov3Xzfa8U-1738698987-1.0.1.1-lmbRRS1MHrDbnU93Gh16CP3qNczxxIrQnyBU7vpHSwNf6PdmuWOHKd1mkl5SBx6rg7p1NLaNUMyqDDcE0Mvjzw; + _cfuvid=Cl48aI8.jSRja0Pqr6Jrh3mAnigd4rDn6lhGicyjMPY-1738698987673-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AxJK2OCJSkUj1plgbj59b4dC39QV2\",\n \"object\": + \"chat.completion\",\n \"created\": 1738698990,\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: hi\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 161,\n \"completion_tokens\": 12,\n \"total_tokens\": 173,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 90cd396c0ab71698-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 04 Feb 2025 19:56:30 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '951' + 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: + - '149999810' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_2c3cb5caed61ccd1e058ef3e6301c691 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + Cq0TCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkShBMKEgoQY3Jld2FpLnRl + bGVtZXRyeRKkBwoQzBQBWCz+GLuI1awj3OPWrRIIGpT16t5bk6MqDENyZXcgQ3JlYXRlZDABOUBz + OyuEGSEYQYDBSCuEGSEYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjBKGgoOcHl0aG9uX3Zl + cnNpb24SCAoGMy4xMi44Si4KCGNyZXdfa2V5EiIKIGU1ODA3MDFkNTJlYjY1YWZmMjRlZWZlNzhj + NzQ2MjhjSjEKB2NyZXdfaWQSJgokMDE3NjQ5ZWMtYTBlMS00MzYxLWFlNjgtYzA1N2E3ZGM5YzI5 + ShwKDGNyZXdfcHJvY2VzcxIMCgpzZXF1ZW50aWFsShEKC2NyZXdfbWVtb3J5EgIQAEoaChRjcmV3 + X251bWJlcl9vZl90YXNrcxICGAFKGwoVY3Jld19udW1iZXJfb2ZfYWdlbnRzEgIYAUrRAgoLY3Jl + d19hZ2VudHMSwQIKvgJbeyJrZXkiOiAiYWQxNTMxNjFjNWM1YTg1NmFhMGQwNmIyNDljNGM2NGEi + LCAiaWQiOiAiOGU3NzgyN2QtN2Y2OC00ZDA2LWI2YTctOWI4YjRkMGE0YzMzIiwgInJvbGUiOiAi + YmFzZV9hZ2VudCIsICJ2ZXJib3NlPyI6IGZhbHNlLCAibWF4X2l0ZXIiOiAyMCwgIm1heF9ycG0i + OiBudWxsLCAiZnVuY3Rpb25fY2FsbGluZ19sbG0iOiAiIiwgImxsbSI6ICJncHQtNG8tbWluaSIs + ICJkZWxlZ2F0aW9uX2VuYWJsZWQ/IjogZmFsc2UsICJhbGxvd19jb2RlX2V4ZWN1dGlvbj8iOiBm + YWxzZSwgIm1heF9yZXRyeV9saW1pdCI6IDIsICJ0b29sc19uYW1lcyI6IFtdfV1K/wEKCmNyZXdf + dGFza3MS8AEK7QFbeyJrZXkiOiAiMWIxNWVmMjM5MTViMjc1NWU4OWEwZWMzYjI2YTEzZDIiLCAi + aWQiOiAiOTJiZDIzMWYtYzAxMC00ZDI3LWIxNGYtZjE5NjEyZTBmZTkzIiwgImFzeW5jX2V4ZWN1 + dGlvbj8iOiBmYWxzZSwgImh1bWFuX2lucHV0PyI6IGZhbHNlLCAiYWdlbnRfcm9sZSI6ICJiYXNl + X2FnZW50IiwgImFnZW50X2tleSI6ICJhZDE1MzE2MWM1YzVhODU2YWEwZDA2YjI0OWM0YzY0YSIs + ICJ0b29sc19uYW1lcyI6IFtdfV16AhgBhQEAAQAAEo4CChC22Au0eMkAAjV6cfU1NrNIEggxb1Bq + Xnll/ioMVGFzayBDcmVhdGVkMAE5IOJaK4QZIRhBwG5bK4QZIRhKLgoIY3Jld19rZXkSIgogZTU4 + MDcwMWQ1MmViNjVhZmYyNGVlZmU3OGM3NDYyOGNKMQoHY3Jld19pZBImCiQwMTc2NDllYy1hMGUx + LTQzNjEtYWU2OC1jMDU3YTdkYzljMjlKLgoIdGFza19rZXkSIgogMWIxNWVmMjM5MTViMjc1NWU4 + OWEwZWMzYjI2YTEzZDJKMQoHdGFza19pZBImCiQ5MmJkMjMxZi1jMDEwLTRkMjctYjE0Zi1mMTk2 + MTJlMGZlOTN6AhgBhQEAAQAAEqQHChC63jCLGR8RP8RmYiHrdNVeEggZ39ffmGm5xyoMQ3JldyBD + cmVhdGVkMAE5GFEe04QZIRhBELEq04QZIRhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMEoa + Cg5weXRob25fdmVyc2lvbhIICgYzLjEyLjhKLgoIY3Jld19rZXkSIgogZTU4MDcwMWQ1MmViNjVh + ZmYyNGVlZmU3OGM3NDYyOGNKMQoHY3Jld19pZBImCiQ5MTY4YmQxNC0yN2Q2LTQ3NWMtODljOC01 + NjJjOTAyMGIxOTBKHAoMY3Jld19wcm9jZXNzEgwKCnNlcXVlbnRpYWxKEQoLY3Jld19tZW1vcnkS + AhAAShoKFGNyZXdfbnVtYmVyX29mX3Rhc2tzEgIYAUobChVjcmV3X251bWJlcl9vZl9hZ2VudHMS + AhgBStECCgtjcmV3X2FnZW50cxLBAgq+Alt7ImtleSI6ICJhZDE1MzE2MWM1YzVhODU2YWEwZDA2 + YjI0OWM0YzY0YSIsICJpZCI6ICI4ZTc3ODI3ZC03ZjY4LTRkMDYtYjZhNy05YjhiNGQwYTRjMzMi + LCAicm9sZSI6ICJiYXNlX2FnZW50IiwgInZlcmJvc2U/IjogZmFsc2UsICJtYXhfaXRlciI6IDIw + LCAibWF4X3JwbSI6IG51bGwsICJmdW5jdGlvbl9jYWxsaW5nX2xsbSI6ICIiLCAibGxtIjogImdw + dC00by1taW5pIiwgImRlbGVnYXRpb25fZW5hYmxlZD8iOiBmYWxzZSwgImFsbG93X2NvZGVfZXhl + Y3V0aW9uPyI6IGZhbHNlLCAibWF4X3JldHJ5X2xpbWl0IjogMiwgInRvb2xzX25hbWVzIjogW119 + XUr/AQoKY3Jld190YXNrcxLwAQrtAVt7ImtleSI6ICIxYjE1ZWYyMzkxNWIyNzU1ZTg5YTBlYzNi + MjZhMTNkMiIsICJpZCI6ICI5MmJkMjMxZi1jMDEwLTRkMjctYjE0Zi1mMTk2MTJlMGZlOTMiLCAi + YXN5bmNfZXhlY3V0aW9uPyI6IGZhbHNlLCAiaHVtYW5faW5wdXQ/IjogZmFsc2UsICJhZ2VudF9y + b2xlIjogImJhc2VfYWdlbnQiLCAiYWdlbnRfa2V5IjogImFkMTUzMTYxYzVjNWE4NTZhYTBkMDZi + MjQ5YzRjNjRhIiwgInRvb2xzX25hbWVzIjogW119XXoCGAGFAQABAAASjgIKEOo6FGs7r9hHrN+f + qhMTUysSCJgbYV+vQMbCKgxUYXNrIENyZWF0ZWQwATlAxjrThBkhGEEYIDvThBkhGEouCghjcmV3 + X2tleRIiCiBlNTgwNzAxZDUyZWI2NWFmZjI0ZWVmZTc4Yzc0NjI4Y0oxCgdjcmV3X2lkEiYKJDkx + NjhiZDE0LTI3ZDYtNDc1Yy04OWM4LTU2MmM5MDIwYjE5MEouCgh0YXNrX2tleRIiCiAxYjE1ZWYy + MzkxNWIyNzU1ZTg5YTBlYzNiMjZhMTNkMkoxCgd0YXNrX2lkEiYKJDkyYmQyMzFmLWMwMTAtNGQy + Ny1iMTRmLWYxOTYxMmUwZmU5M3oCGAGFAQABAAA= + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '2480' + 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: + - Tue, 04 Feb 2025 19:56:31 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Assess the quality of the task + completed based on the description, expected output, and actual results.\n\nTask + Description:\nJust say hi\n\nExpected Output:\nhi\n\nActual Output:\nhi\n\nPlease + provide:\n- Bullet points suggestions to improve future similar tasks\n- A score + from 0 to 10 evaluating on completion, quality, and overall performance- Entities + extracted from the task output, if any, their type, description, and relationships"}], + "model": "gpt-4o-mini", "tool_choice": {"type": "function", "function": {"name": + "TaskEvaluation"}}, "tools": [{"type": "function", "function": {"name": "TaskEvaluation", + "description": "Correctly extracted `TaskEvaluation` with all the required parameters + with correct types", "parameters": {"$defs": {"Entity": {"properties": {"name": + {"description": "The name of the entity.", "title": "Name", "type": "string"}, + "type": {"description": "The type of the entity.", "title": "Type", "type": + "string"}, "description": {"description": "Description of the entity.", "title": + "Description", "type": "string"}, "relationships": {"description": "Relationships + of the entity.", "items": {"type": "string"}, "title": "Relationships", "type": + "array"}}, "required": ["name", "type", "description", "relationships"], "title": + "Entity", "type": "object"}}, "properties": {"suggestions": {"description": + "Suggestions to improve future similar tasks.", "items": {"type": "string"}, + "title": "Suggestions", "type": "array"}, "quality": {"description": "A score + from 0 to 10 evaluating on completion, quality, and overall performance, all + taking into account the task description, expected output, and the result of + the task.", "title": "Quality", "type": "number"}, "entities": {"description": + "Entities extracted from the task output.", "items": {"$ref": "#/$defs/Entity"}, + "title": "Entities", "type": "array"}}, "required": ["entities", "quality", + "suggestions"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1962' + content-type: + - application/json + cookie: + - __cf_bm=4s6sWmJ49B9F_wNc1STtdZF1nikfl6uN9_ov3Xzfa8U-1738698987-1.0.1.1-lmbRRS1MHrDbnU93Gh16CP3qNczxxIrQnyBU7vpHSwNf6PdmuWOHKd1mkl5SBx6rg7p1NLaNUMyqDDcE0Mvjzw; + _cfuvid=Cl48aI8.jSRja0Pqr6Jrh3mAnigd4rDn6lhGicyjMPY-1738698987673-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AxJK3bJiyqGhPeqdCcCjoeNavGHrR\",\n \"object\": + \"chat.completion\",\n \"created\": 1738698991,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n + \ \"id\": \"call_uAFkclWHIRqgrXFrQFcEoUIS\",\n \"type\": + \"function\",\n \"function\": {\n \"name\": \"TaskEvaluation\",\n + \ \"arguments\": \"{\\\"suggestions\\\":[\\\"Include additional + context for the greeting to make it more meaningful.\\\",\\\"Specify if you + want a casual or formal tone for greetings.\\\",\\\"Provide examples of variations + of the greeting if necessary.\\\"],\\\"quality\\\":10,\\\"entities\\\":[],\\\"relationships\\\":[]}\"\n + \ }\n }\n ],\n \"refusal\": null\n },\n + \ \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }\n ],\n + \ \"usage\": {\n \"prompt_tokens\": 273,\n \"completion_tokens\": 50,\n + \ \"total_tokens\": 323,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-RAY: + - 90cd3973589f1698-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 04 Feb 2025 19:56:32 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '1408' + 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: + - '149999876' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_519fd27ca3d5da4d541c4331654e0520 + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_crew_emits_end_task_event.yaml b/tests/utilities/cassettes/test_crew_emits_end_task_event.yaml new file mode 100644 index 000000000..09cb318d2 --- /dev/null +++ b/tests/utilities/cassettes/test_crew_emits_end_task_event.yaml @@ -0,0 +1,357 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nTo + give my best complete final answer to the task respond using 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: Just say hi\n\nThis is the expect criteria for your + final answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '836' + content-type: + - application/json + cookie: + - __cf_bm=nedOdWE1YnKQYt1kSbrcA.zhwa3bZDzmZqTOjZYER0c-1738700521-1.0.1.1-xQk9iXOvqvyXNhkIOgc8Ws2WYcT1mJFkDCvCC8xA5joFD8QfNrBIAr_Qs6sIxt2EzXyeFwBA6gA8ZgWApCHx0Q; + _cfuvid=Cl48aI8.jSRja0Pqr6Jrh3mAnigd4rDn6lhGicyjMPY-1738698987673-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AxJlK2np8dMxYgsDIuyz2TSKKELWh\",\n \"object\": + \"chat.completion\",\n \"created\": 1738700682,\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: hi\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 161,\n \"completion_tokens\": 12,\n \"total_tokens\": 173,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 90cd62c1fdb0fa6a-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 04 Feb 2025 20:24:42 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '326' + 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: + - '149999810' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_22be86be6fd9d69ca8d310ef534e7bec + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + Cp0mCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkS9CUKEgoQY3Jld2FpLnRl + bGVtZXRyeRKkBwoQfRmsiIy66Scw43CcUw5ZiBIIfYDEhWJTOTkqDENyZXcgQ3JlYXRlZDABOcD6 + XvsOGyEYQWC2bPsOGyEYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjBKGgoOcHl0aG9uX3Zl + cnNpb24SCAoGMy4xMi44Si4KCGNyZXdfa2V5EiIKIGU1ODA3MDFkNTJlYjY1YWZmMjRlZWZlNzhj + NzQ2MjhjSjEKB2NyZXdfaWQSJgokMDMzNTZiYmEtMzJmZC00OThmLTgxYTItYzc1ZDBkMzc2N2Qx + ShwKDGNyZXdfcHJvY2VzcxIMCgpzZXF1ZW50aWFsShEKC2NyZXdfbWVtb3J5EgIQAEoaChRjcmV3 + X251bWJlcl9vZl90YXNrcxICGAFKGwoVY3Jld19udW1iZXJfb2ZfYWdlbnRzEgIYAUrRAgoLY3Jl + d19hZ2VudHMSwQIKvgJbeyJrZXkiOiAiYWQxNTMxNjFjNWM1YTg1NmFhMGQwNmIyNDljNGM2NGEi + LCAiaWQiOiAiZjY5YTRmYTMtMzQ4OC00MmFhLTlhMTQtMGEzZmEyOWJmYjZjIiwgInJvbGUiOiAi + YmFzZV9hZ2VudCIsICJ2ZXJib3NlPyI6IGZhbHNlLCAibWF4X2l0ZXIiOiAyMCwgIm1heF9ycG0i + OiBudWxsLCAiZnVuY3Rpb25fY2FsbGluZ19sbG0iOiAiIiwgImxsbSI6ICJncHQtNG8tbWluaSIs + ICJkZWxlZ2F0aW9uX2VuYWJsZWQ/IjogZmFsc2UsICJhbGxvd19jb2RlX2V4ZWN1dGlvbj8iOiBm + YWxzZSwgIm1heF9yZXRyeV9saW1pdCI6IDIsICJ0b29sc19uYW1lcyI6IFtdfV1K/wEKCmNyZXdf + dGFza3MS8AEK7QFbeyJrZXkiOiAiMWIxNWVmMjM5MTViMjc1NWU4OWEwZWMzYjI2YTEzZDIiLCAi + aWQiOiAiNDllNzk0MmMtZTJiMy00YmE1LTg5MTUtMTYwYjQxMDU2ZmVlIiwgImFzeW5jX2V4ZWN1 + dGlvbj8iOiBmYWxzZSwgImh1bWFuX2lucHV0PyI6IGZhbHNlLCAiYWdlbnRfcm9sZSI6ICJiYXNl + X2FnZW50IiwgImFnZW50X2tleSI6ICJhZDE1MzE2MWM1YzVhODU2YWEwZDA2YjI0OWM0YzY0YSIs + ICJ0b29sc19uYW1lcyI6IFtdfV16AhgBhQEAAQAAEo4CChCLgjutPq/3tkNyPqVjfbZhEgjhB7lb + clxzdyoMVGFzayBDcmVhdGVkMAE5CC9++w4bIRhBeMN++w4bIRhKLgoIY3Jld19rZXkSIgogZTU4 + MDcwMWQ1MmViNjVhZmYyNGVlZmU3OGM3NDYyOGNKMQoHY3Jld19pZBImCiQwMzM1NmJiYS0zMmZk + LTQ5OGYtODFhMi1jNzVkMGQzNzY3ZDFKLgoIdGFza19rZXkSIgogMWIxNWVmMjM5MTViMjc1NWU4 + OWEwZWMzYjI2YTEzZDJKMQoHdGFza19pZBImCiQ0OWU3OTQyYy1lMmIzLTRiYTUtODkxNS0xNjBi + NDEwNTZmZWV6AhgBhQEAAQAAEqQHChC7SpRSs6eG9XFmYuMQgghQEghpZMlScOy2DyoMQ3JldyBD + cmVhdGVkMAE50O2cAA8bIRhBOFmrAA8bIRhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMEoa + Cg5weXRob25fdmVyc2lvbhIICgYzLjEyLjhKLgoIY3Jld19rZXkSIgogZTU4MDcwMWQ1MmViNjVh + ZmYyNGVlZmU3OGM3NDYyOGNKMQoHY3Jld19pZBImCiRlYTQ1MWY2OS00Zjk3LTQ4MjYtOWNlYi04 + NTAzMDk2MTQ2MDlKHAoMY3Jld19wcm9jZXNzEgwKCnNlcXVlbnRpYWxKEQoLY3Jld19tZW1vcnkS + AhAAShoKFGNyZXdfbnVtYmVyX29mX3Rhc2tzEgIYAUobChVjcmV3X251bWJlcl9vZl9hZ2VudHMS + AhgBStECCgtjcmV3X2FnZW50cxLBAgq+Alt7ImtleSI6ICJhZDE1MzE2MWM1YzVhODU2YWEwZDA2 + YjI0OWM0YzY0YSIsICJpZCI6ICJmNjlhNGZhMy0zNDg4LTQyYWEtOWExNC0wYTNmYTI5YmZiNmMi + LCAicm9sZSI6ICJiYXNlX2FnZW50IiwgInZlcmJvc2U/IjogZmFsc2UsICJtYXhfaXRlciI6IDIw + LCAibWF4X3JwbSI6IG51bGwsICJmdW5jdGlvbl9jYWxsaW5nX2xsbSI6ICIiLCAibGxtIjogImdw + dC00by1taW5pIiwgImRlbGVnYXRpb25fZW5hYmxlZD8iOiBmYWxzZSwgImFsbG93X2NvZGVfZXhl + Y3V0aW9uPyI6IGZhbHNlLCAibWF4X3JldHJ5X2xpbWl0IjogMiwgInRvb2xzX25hbWVzIjogW119 + XUr/AQoKY3Jld190YXNrcxLwAQrtAVt7ImtleSI6ICIxYjE1ZWYyMzkxNWIyNzU1ZTg5YTBlYzNi + MjZhMTNkMiIsICJpZCI6ICI0OWU3OTQyYy1lMmIzLTRiYTUtODkxNS0xNjBiNDEwNTZmZWUiLCAi + YXN5bmNfZXhlY3V0aW9uPyI6IGZhbHNlLCAiaHVtYW5faW5wdXQ/IjogZmFsc2UsICJhZ2VudF9y + b2xlIjogImJhc2VfYWdlbnQiLCAiYWdlbnRfa2V5IjogImFkMTUzMTYxYzVjNWE4NTZhYTBkMDZi + MjQ5YzRjNjRhIiwgInRvb2xzX25hbWVzIjogW119XXoCGAGFAQABAAASjgIKEM1q5zTl6Q6WKHPQ + eIqEm7sSCCWi2wvaFqpfKgxUYXNrIENyZWF0ZWQwATmIObwADxshGEEAo7wADxshGEouCghjcmV3 + X2tleRIiCiBlNTgwNzAxZDUyZWI2NWFmZjI0ZWVmZTc4Yzc0NjI4Y0oxCgdjcmV3X2lkEiYKJGVh + NDUxZjY5LTRmOTctNDgyNi05Y2ViLTg1MDMwOTYxNDYwOUouCgh0YXNrX2tleRIiCiAxYjE1ZWYy + MzkxNWIyNzU1ZTg5YTBlYzNiMjZhMTNkMkoxCgd0YXNrX2lkEiYKJDQ5ZTc5NDJjLWUyYjMtNGJh + NS04OTE1LTE2MGI0MTA1NmZlZXoCGAGFAQABAAASpAcKEEhIZzGdZRAdvfcluDR5qvESCFMGo60X + V/dYKgxDcmV3IENyZWF0ZWQwATnY8LgBDxshGEGQrsUBDxshGEobCg5jcmV3YWlfdmVyc2lvbhIJ + CgcwLjEwMC4wShoKDnB5dGhvbl92ZXJzaW9uEggKBjMuMTIuOEouCghjcmV3X2tleRIiCiBlNTgw + NzAxZDUyZWI2NWFmZjI0ZWVmZTc4Yzc0NjI4Y0oxCgdjcmV3X2lkEiYKJDA3MDJmOGU1LWRjMTYt + NDlhYi1hMWY1LThjOWQyY2IwMDYwYkocCgxjcmV3X3Byb2Nlc3MSDAoKc2VxdWVudGlhbEoRCgtj + cmV3X21lbW9yeRICEABKGgoUY3Jld19udW1iZXJfb2ZfdGFza3MSAhgBShsKFWNyZXdfbnVtYmVy + X29mX2FnZW50cxICGAFK0QIKC2NyZXdfYWdlbnRzEsECCr4CW3sia2V5IjogImFkMTUzMTYxYzVj + NWE4NTZhYTBkMDZiMjQ5YzRjNjRhIiwgImlkIjogImY2OWE0ZmEzLTM0ODgtNDJhYS05YTE0LTBh + M2ZhMjliZmI2YyIsICJyb2xlIjogImJhc2VfYWdlbnQiLCAidmVyYm9zZT8iOiBmYWxzZSwgIm1h + eF9pdGVyIjogMjAsICJtYXhfcnBtIjogbnVsbCwgImZ1bmN0aW9uX2NhbGxpbmdfbGxtIjogIiIs + ICJsbG0iOiAiZ3B0LTRvLW1pbmkiLCAiZGVsZWdhdGlvbl9lbmFibGVkPyI6IGZhbHNlLCAiYWxs + b3dfY29kZV9leGVjdXRpb24/IjogZmFsc2UsICJtYXhfcmV0cnlfbGltaXQiOiAyLCAidG9vbHNf + bmFtZXMiOiBbXX1dSv8BCgpjcmV3X3Rhc2tzEvABCu0BW3sia2V5IjogIjFiMTVlZjIzOTE1YjI3 + NTVlODlhMGVjM2IyNmExM2QyIiwgImlkIjogIjQ5ZTc5NDJjLWUyYjMtNGJhNS04OTE1LTE2MGI0 + MTA1NmZlZSIsICJhc3luY19leGVjdXRpb24/IjogZmFsc2UsICJodW1hbl9pbnB1dD8iOiBmYWxz + ZSwgImFnZW50X3JvbGUiOiAiYmFzZV9hZ2VudCIsICJhZ2VudF9rZXkiOiAiYWQxNTMxNjFjNWM1 + YTg1NmFhMGQwNmIyNDljNGM2NGEiLCAidG9vbHNfbmFtZXMiOiBbXX1degIYAYUBAAEAABKOAgoQ + PkgvMtq3aT5YPXE8gCRxPBIIMx/zQOuC+8sqDFRhc2sgQ3JlYXRlZDABOYjk2AEPGyEYQZiI2QEP + GyEYSi4KCGNyZXdfa2V5EiIKIGU1ODA3MDFkNTJlYjY1YWZmMjRlZWZlNzhjNzQ2MjhjSjEKB2Ny + ZXdfaWQSJgokMDcwMmY4ZTUtZGMxNi00OWFiLWExZjUtOGM5ZDJjYjAwNjBiSi4KCHRhc2tfa2V5 + EiIKIDFiMTVlZjIzOTE1YjI3NTVlODlhMGVjM2IyNmExM2QySjEKB3Rhc2tfaWQSJgokNDllNzk0 + MmMtZTJiMy00YmE1LTg5MTUtMTYwYjQxMDU2ZmVlegIYAYUBAAEAABKkBwoQex7nA0gUUrZHbN6F + gWp/gBIIKPd4fiRi7DwqDENyZXcgQ3JlYXRlZDABOTiIrAIPGyEYQdCAtwIPGyEYShsKDmNyZXdh + aV92ZXJzaW9uEgkKBzAuMTAwLjBKGgoOcHl0aG9uX3ZlcnNpb24SCAoGMy4xMi44Si4KCGNyZXdf + a2V5EiIKIGU1ODA3MDFkNTJlYjY1YWZmMjRlZWZlNzhjNzQ2MjhjSjEKB2NyZXdfaWQSJgokMGNm + YjUzZWItMDA2Mi00YmVmLTk1ZTgtMDgwMjQ3NmNkMWRlShwKDGNyZXdfcHJvY2VzcxIMCgpzZXF1 + ZW50aWFsShEKC2NyZXdfbWVtb3J5EgIQAEoaChRjcmV3X251bWJlcl9vZl90YXNrcxICGAFKGwoV + Y3Jld19udW1iZXJfb2ZfYWdlbnRzEgIYAUrRAgoLY3Jld19hZ2VudHMSwQIKvgJbeyJrZXkiOiAi + YWQxNTMxNjFjNWM1YTg1NmFhMGQwNmIyNDljNGM2NGEiLCAiaWQiOiAiZjY5YTRmYTMtMzQ4OC00 + MmFhLTlhMTQtMGEzZmEyOWJmYjZjIiwgInJvbGUiOiAiYmFzZV9hZ2VudCIsICJ2ZXJib3NlPyI6 + IGZhbHNlLCAibWF4X2l0ZXIiOiAyMCwgIm1heF9ycG0iOiBudWxsLCAiZnVuY3Rpb25fY2FsbGlu + Z19sbG0iOiAiIiwgImxsbSI6ICJncHQtNG8tbWluaSIsICJkZWxlZ2F0aW9uX2VuYWJsZWQ/Ijog + ZmFsc2UsICJhbGxvd19jb2RlX2V4ZWN1dGlvbj8iOiBmYWxzZSwgIm1heF9yZXRyeV9saW1pdCI6 + IDIsICJ0b29sc19uYW1lcyI6IFtdfV1K/wEKCmNyZXdfdGFza3MS8AEK7QFbeyJrZXkiOiAiMWIx + NWVmMjM5MTViMjc1NWU4OWEwZWMzYjI2YTEzZDIiLCAiaWQiOiAiNDllNzk0MmMtZTJiMy00YmE1 + LTg5MTUtMTYwYjQxMDU2ZmVlIiwgImFzeW5jX2V4ZWN1dGlvbj8iOiBmYWxzZSwgImh1bWFuX2lu + cHV0PyI6IGZhbHNlLCAiYWdlbnRfcm9sZSI6ICJiYXNlX2FnZW50IiwgImFnZW50X2tleSI6ICJh + ZDE1MzE2MWM1YzVhODU2YWEwZDA2YjI0OWM0YzY0YSIsICJ0b29sc19uYW1lcyI6IFtdfV16AhgB + hQEAAQAAEo4CChD+ymllejCksajGYDua8tgNEghnjlejrbuw2SoMVGFzayBDcmVhdGVkMAE5EDrI + Ag8bIRhBGIzIAg8bIRhKLgoIY3Jld19rZXkSIgogZTU4MDcwMWQ1MmViNjVhZmYyNGVlZmU3OGM3 + NDYyOGNKMQoHY3Jld19pZBImCiQwY2ZiNTNlYi0wMDYyLTRiZWYtOTVlOC0wODAyNDc2Y2QxZGVK + LgoIdGFza19rZXkSIgogMWIxNWVmMjM5MTViMjc1NWU4OWEwZWMzYjI2YTEzZDJKMQoHdGFza19p + ZBImCiQ0OWU3OTQyYy1lMmIzLTRiYTUtODkxNS0xNjBiNDEwNTZmZWV6AhgBhQEAAQAA + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '4896' + 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: + - Tue, 04 Feb 2025 20:24:47 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Assess the quality of the task + completed based on the description, expected output, and actual results.\n\nTask + Description:\nJust say hi\n\nExpected Output:\nhi\n\nActual Output:\nhi\n\nPlease + provide:\n- Bullet points suggestions to improve future similar tasks\n- A score + from 0 to 10 evaluating on completion, quality, and overall performance- Entities + extracted from the task output, if any, their type, description, and relationships"}], + "model": "gpt-4o-mini", "tool_choice": {"type": "function", "function": {"name": + "TaskEvaluation"}}, "tools": [{"type": "function", "function": {"name": "TaskEvaluation", + "description": "Correctly extracted `TaskEvaluation` with all the required parameters + with correct types", "parameters": {"$defs": {"Entity": {"properties": {"name": + {"description": "The name of the entity.", "title": "Name", "type": "string"}, + "type": {"description": "The type of the entity.", "title": "Type", "type": + "string"}, "description": {"description": "Description of the entity.", "title": + "Description", "type": "string"}, "relationships": {"description": "Relationships + of the entity.", "items": {"type": "string"}, "title": "Relationships", "type": + "array"}}, "required": ["name", "type", "description", "relationships"], "title": + "Entity", "type": "object"}}, "properties": {"suggestions": {"description": + "Suggestions to improve future similar tasks.", "items": {"type": "string"}, + "title": "Suggestions", "type": "array"}, "quality": {"description": "A score + from 0 to 10 evaluating on completion, quality, and overall performance, all + taking into account the task description, expected output, and the result of + the task.", "title": "Quality", "type": "number"}, "entities": {"description": + "Entities extracted from the task output.", "items": {"$ref": "#/$defs/Entity"}, + "title": "Entities", "type": "array"}}, "required": ["entities", "quality", + "suggestions"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1962' + content-type: + - application/json + cookie: + - __cf_bm=nedOdWE1YnKQYt1kSbrcA.zhwa3bZDzmZqTOjZYER0c-1738700521-1.0.1.1-xQk9iXOvqvyXNhkIOgc8Ws2WYcT1mJFkDCvCC8xA5joFD8QfNrBIAr_Qs6sIxt2EzXyeFwBA6gA8ZgWApCHx0Q; + _cfuvid=Cl48aI8.jSRja0Pqr6Jrh3mAnigd4rDn6lhGicyjMPY-1738698987673-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AxJlLVC3gCB9gRI0ZSkoPCZY7EwpQ\",\n \"object\": + \"chat.completion\",\n \"created\": 1738700683,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n + \ \"id\": \"call_mgwImOITW8lkjzAyf9Pp76cL\",\n \"type\": + \"function\",\n \"function\": {\n \"name\": \"TaskEvaluation\",\n + \ \"arguments\": \"{\\\"suggestions\\\":[\\\"Provide context or + additional information to make tasks more engaging.\\\",\\\"Encourage variations + in responses to make the interaction more dynamic.\\\"],\\\"quality\\\":10,\\\"entities\\\":[{\\\"name\\\":\\\"hi\\\",\\\"type\\\":\\\"greeting\\\",\\\"description\\\":\\\"A + common word used to initiate a conversation or express friendliness.\\\",\\\"relationships\\\":[\\\"initiates + conversation\\\",\\\"expresses friendliness\\\"]}]}\"\n }\n }\n + \ ],\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 273,\n \"completion_tokens\": 71,\n \"total_tokens\": 344,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 90cd62c4ba41fa6a-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 04 Feb 2025 20:24:50 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: + - '7347' + 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: + - '149999876' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_aec28dd3fe998d628754e8429623bf9e + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_crew_emits_kickoff_events.yaml b/tests/utilities/cassettes/test_crew_emits_kickoff_events.yaml new file mode 100644 index 000000000..2233bde21 --- /dev/null +++ b/tests/utilities/cassettes/test_crew_emits_kickoff_events.yaml @@ -0,0 +1,245 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nTo + give my best complete final answer to the task respond using 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: Just say hi\n\nThis is the expect criteria for your + final answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '836' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AxJIrSWAFqDEsNtLRhcM8vMHO9Ejw\",\n \"object\": + \"chat.completion\",\n \"created\": 1738698917,\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: hi\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 161,\n \"completion_tokens\": 12,\n \"total_tokens\": 173,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 90cd37a83f5f176a-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 04 Feb 2025 19:55:18 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=rKQWp4fbAvcCp4rasEN6DqiTjQfiWYpLfjcLpWcmzi0-1738698918-1.0.1.1-qlcCSdBY3KWbzVms0eLtz5ub5SSLGs_sRLxTdNhDk_purQuz9k6EFp8PHJfN3aP_sLnuyKnFlppM3.2k_dCtPQ; + path=/; expires=Tue, 04-Feb-25 20:25:18 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=Oi91zDXvjWohBYXSVqK4hFsq3_GZePEIIbi7b7wrjcI-1738698918130-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 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '894' + 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: + - '149999810' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_864253996bbc0f797f9a2c1b9247a0d5 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "Assess the quality of the task + completed based on the description, expected output, and actual results.\n\nTask + Description:\nJust say hi\n\nExpected Output:\nhi\n\nActual Output:\nhi\n\nPlease + provide:\n- Bullet points suggestions to improve future similar tasks\n- A score + from 0 to 10 evaluating on completion, quality, and overall performance- Entities + extracted from the task output, if any, their type, description, and relationships"}], + "model": "gpt-4o-mini", "tool_choice": {"type": "function", "function": {"name": + "TaskEvaluation"}}, "tools": [{"type": "function", "function": {"name": "TaskEvaluation", + "description": "Correctly extracted `TaskEvaluation` with all the required parameters + with correct types", "parameters": {"$defs": {"Entity": {"properties": {"name": + {"description": "The name of the entity.", "title": "Name", "type": "string"}, + "type": {"description": "The type of the entity.", "title": "Type", "type": + "string"}, "description": {"description": "Description of the entity.", "title": + "Description", "type": "string"}, "relationships": {"description": "Relationships + of the entity.", "items": {"type": "string"}, "title": "Relationships", "type": + "array"}}, "required": ["name", "type", "description", "relationships"], "title": + "Entity", "type": "object"}}, "properties": {"suggestions": {"description": + "Suggestions to improve future similar tasks.", "items": {"type": "string"}, + "title": "Suggestions", "type": "array"}, "quality": {"description": "A score + from 0 to 10 evaluating on completion, quality, and overall performance, all + taking into account the task description, expected output, and the result of + the task.", "title": "Quality", "type": "number"}, "entities": {"description": + "Entities extracted from the task output.", "items": {"$ref": "#/$defs/Entity"}, + "title": "Entities", "type": "array"}}, "required": ["entities", "quality", + "suggestions"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1962' + content-type: + - application/json + cookie: + - __cf_bm=rKQWp4fbAvcCp4rasEN6DqiTjQfiWYpLfjcLpWcmzi0-1738698918-1.0.1.1-qlcCSdBY3KWbzVms0eLtz5ub5SSLGs_sRLxTdNhDk_purQuz9k6EFp8PHJfN3aP_sLnuyKnFlppM3.2k_dCtPQ; + _cfuvid=Oi91zDXvjWohBYXSVqK4hFsq3_GZePEIIbi7b7wrjcI-1738698918130-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AxJIsVEppA04iGQh0k6sanKnVObrO\",\n \"object\": + \"chat.completion\",\n \"created\": 1738698918,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n + \ \"id\": \"call_AQ3iizjGWjEvk1SmhGCzjbf1\",\n \"type\": + \"function\",\n \"function\": {\n \"name\": \"TaskEvaluation\",\n + \ \"arguments\": \"{\\\"suggestions\\\":[\\\"Provide context for + the greeting, like a specific scenario or recipient.\\\",\\\"Encourage responses + or follow-ups to promote engagement.\\\",\\\"Specify the tone or formality of + the greeting, if relevant.\\\"],\\\"quality\\\":10,\\\"entities\\\":[{\\\"name\\\":\\\"hi\\\",\\\"type\\\":\\\"greeting\\\",\\\"description\\\":\\\"A + common informal expression used to initiate conversation or acknowledge someone.\\\",\\\"relationships\\\":[\\\"used + in conversation\\\",\\\"expresses friendliness\\\"]}]}\"\n }\n }\n + \ ],\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 273,\n \"completion_tokens\": 84,\n \"total_tokens\": 357,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 90cd37aec8c8176a-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 04 Feb 2025 19:55:21 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: + - '3269' + 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: + - '149999876' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_e6e67a3f5c6f2d48e0351cdce95edd97 + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_crew_emits_start_kickoff_event.yaml b/tests/utilities/cassettes/test_crew_emits_start_kickoff_event.yaml new file mode 100644 index 000000000..82333fe7d --- /dev/null +++ b/tests/utilities/cassettes/test_crew_emits_start_kickoff_event.yaml @@ -0,0 +1,243 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nTo + give my best complete final answer to the task respond using 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: Just say hi\n\nThis is the expect criteria for your + final answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '836' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AxJJzafmayYpGTsTAWbOyZkmQJNa5\",\n \"object\": + \"chat.completion\",\n \"created\": 1738698987,\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: hi\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 161,\n \"completion_tokens\": 12,\n \"total_tokens\": 173,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 90cd395b0e641698-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 04 Feb 2025 19:56:27 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=4s6sWmJ49B9F_wNc1STtdZF1nikfl6uN9_ov3Xzfa8U-1738698987-1.0.1.1-lmbRRS1MHrDbnU93Gh16CP3qNczxxIrQnyBU7vpHSwNf6PdmuWOHKd1mkl5SBx6rg7p1NLaNUMyqDDcE0Mvjzw; + path=/; expires=Tue, 04-Feb-25 20:26:27 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=Cl48aI8.jSRja0Pqr6Jrh3mAnigd4rDn6lhGicyjMPY-1738698987673-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: + - '839' + 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: + - '149999810' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_577b484a927b455c40ed80f9fd4d9106 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "Assess the quality of the task + completed based on the description, expected output, and actual results.\n\nTask + Description:\nJust say hi\n\nExpected Output:\nhi\n\nActual Output:\nhi\n\nPlease + provide:\n- Bullet points suggestions to improve future similar tasks\n- A score + from 0 to 10 evaluating on completion, quality, and overall performance- Entities + extracted from the task output, if any, their type, description, and relationships"}], + "model": "gpt-4o-mini", "tool_choice": {"type": "function", "function": {"name": + "TaskEvaluation"}}, "tools": [{"type": "function", "function": {"name": "TaskEvaluation", + "description": "Correctly extracted `TaskEvaluation` with all the required parameters + with correct types", "parameters": {"$defs": {"Entity": {"properties": {"name": + {"description": "The name of the entity.", "title": "Name", "type": "string"}, + "type": {"description": "The type of the entity.", "title": "Type", "type": + "string"}, "description": {"description": "Description of the entity.", "title": + "Description", "type": "string"}, "relationships": {"description": "Relationships + of the entity.", "items": {"type": "string"}, "title": "Relationships", "type": + "array"}}, "required": ["name", "type", "description", "relationships"], "title": + "Entity", "type": "object"}}, "properties": {"suggestions": {"description": + "Suggestions to improve future similar tasks.", "items": {"type": "string"}, + "title": "Suggestions", "type": "array"}, "quality": {"description": "A score + from 0 to 10 evaluating on completion, quality, and overall performance, all + taking into account the task description, expected output, and the result of + the task.", "title": "Quality", "type": "number"}, "entities": {"description": + "Entities extracted from the task output.", "items": {"$ref": "#/$defs/Entity"}, + "title": "Entities", "type": "array"}}, "required": ["entities", "quality", + "suggestions"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1962' + content-type: + - application/json + cookie: + - __cf_bm=4s6sWmJ49B9F_wNc1STtdZF1nikfl6uN9_ov3Xzfa8U-1738698987-1.0.1.1-lmbRRS1MHrDbnU93Gh16CP3qNczxxIrQnyBU7vpHSwNf6PdmuWOHKd1mkl5SBx6rg7p1NLaNUMyqDDcE0Mvjzw; + _cfuvid=Cl48aI8.jSRja0Pqr6Jrh3mAnigd4rDn6lhGicyjMPY-1738698987673-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AxJJz10KP7iadNPdKsbcsvHBa7cic\",\n \"object\": + \"chat.completion\",\n \"created\": 1738698987,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n + \ \"id\": \"call_czeHQgy5eiOVa0zlrtcfwepe\",\n \"type\": + \"function\",\n \"function\": {\n \"name\": \"TaskEvaluation\",\n + \ \"arguments\": \"{\\\"suggestions\\\":[\\\"Provide more context + or details for similar tasks to enhance output expectations.\\\",\\\"Encourage + creativity in responses for simple tasks to engage users more effectively.\\\"],\\\"quality\\\":10,\\\"entities\\\":[] + }\"\n }\n }\n ],\n \"refusal\": null\n },\n + \ \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }\n ],\n + \ \"usage\": {\n \"prompt_tokens\": 273,\n \"completion_tokens\": 40,\n + \ \"total_tokens\": 313,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-RAY: + - 90cd39615b281698-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 04 Feb 2025 19:56:29 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '1411' + 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: + - '149999876' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_3e717a80c7d9c5ea19893dd990aaae26 + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_crew_emits_start_task_event.yaml b/tests/utilities/cassettes/test_crew_emits_start_task_event.yaml new file mode 100644 index 000000000..e470049a7 --- /dev/null +++ b/tests/utilities/cassettes/test_crew_emits_start_task_event.yaml @@ -0,0 +1,245 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nTo + give my best complete final answer to the task respond using 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: Just say hi\n\nThis is the expect criteria for your + final answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '836' + content-type: + - application/json + cookie: + - __cf_bm=4s6sWmJ49B9F_wNc1STtdZF1nikfl6uN9_ov3Xzfa8U-1738698987-1.0.1.1-lmbRRS1MHrDbnU93Gh16CP3qNczxxIrQnyBU7vpHSwNf6PdmuWOHKd1mkl5SBx6rg7p1NLaNUMyqDDcE0Mvjzw; + _cfuvid=Cl48aI8.jSRja0Pqr6Jrh3mAnigd4rDn6lhGicyjMPY-1738698987673-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AxJiiHEQwIXsiG0Sd5wofcuhxVbo9\",\n \"object\": + \"chat.completion\",\n \"created\": 1738700520,\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: hi\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 161,\n \"completion_tokens\": 12,\n \"total_tokens\": 173,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 90cd5ecd0f7667ee-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 04 Feb 2025 20:22:01 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=nedOdWE1YnKQYt1kSbrcA.zhwa3bZDzmZqTOjZYER0c-1738700521-1.0.1.1-xQk9iXOvqvyXNhkIOgc8Ws2WYcT1mJFkDCvCC8xA5joFD8QfNrBIAr_Qs6sIxt2EzXyeFwBA6gA8ZgWApCHx0Q; + path=/; expires=Tue, 04-Feb-25 20:52:01 GMT; 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 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '450' + 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: + - '149999810' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_10eaafc81640a98a0a4789d270dd94d9 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "Assess the quality of the task + completed based on the description, expected output, and actual results.\n\nTask + Description:\nJust say hi\n\nExpected Output:\nhi\n\nActual Output:\nhi\n\nPlease + provide:\n- Bullet points suggestions to improve future similar tasks\n- A score + from 0 to 10 evaluating on completion, quality, and overall performance- Entities + extracted from the task output, if any, their type, description, and relationships"}], + "model": "gpt-4o-mini", "tool_choice": {"type": "function", "function": {"name": + "TaskEvaluation"}}, "tools": [{"type": "function", "function": {"name": "TaskEvaluation", + "description": "Correctly extracted `TaskEvaluation` with all the required parameters + with correct types", "parameters": {"$defs": {"Entity": {"properties": {"name": + {"description": "The name of the entity.", "title": "Name", "type": "string"}, + "type": {"description": "The type of the entity.", "title": "Type", "type": + "string"}, "description": {"description": "Description of the entity.", "title": + "Description", "type": "string"}, "relationships": {"description": "Relationships + of the entity.", "items": {"type": "string"}, "title": "Relationships", "type": + "array"}}, "required": ["name", "type", "description", "relationships"], "title": + "Entity", "type": "object"}}, "properties": {"suggestions": {"description": + "Suggestions to improve future similar tasks.", "items": {"type": "string"}, + "title": "Suggestions", "type": "array"}, "quality": {"description": "A score + from 0 to 10 evaluating on completion, quality, and overall performance, all + taking into account the task description, expected output, and the result of + the task.", "title": "Quality", "type": "number"}, "entities": {"description": + "Entities extracted from the task output.", "items": {"$ref": "#/$defs/Entity"}, + "title": "Entities", "type": "array"}}, "required": ["entities", "quality", + "suggestions"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1962' + content-type: + - application/json + cookie: + - __cf_bm=nedOdWE1YnKQYt1kSbrcA.zhwa3bZDzmZqTOjZYER0c-1738700521-1.0.1.1-xQk9iXOvqvyXNhkIOgc8Ws2WYcT1mJFkDCvCC8xA5joFD8QfNrBIAr_Qs6sIxt2EzXyeFwBA6gA8ZgWApCHx0Q; + _cfuvid=Cl48aI8.jSRja0Pqr6Jrh3mAnigd4rDn6lhGicyjMPY-1738698987673-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AxJijOhk12Ua6lS23IwtZTachfjq9\",\n \"object\": + \"chat.completion\",\n \"created\": 1738700521,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n + \ \"id\": \"call_DSteeMHHPf5RanJb8qjCo4qx\",\n \"type\": + \"function\",\n \"function\": {\n \"name\": \"TaskEvaluation\",\n + \ \"arguments\": \"{\\\"suggestions\\\":[\\\"Consider adding context + for the greeting to make it more engaging.\\\",\\\"Specify if any additional + information or tone is desired in the greeting.\\\"],\\\"quality\\\":10,\\\"entities\\\":[{\\\"name\\\":\\\"greeting\\\",\\\"type\\\":\\\"text\\\",\\\"description\\\":\\\"A + simple greeting phrase\\\",\\\"relationships\\\":[\\\"is a\\\",\\\"is part of + a conversation\\\"]}]}\"\n }\n }\n ],\n \"refusal\": + null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n + \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 273,\n \"completion_tokens\": + 67,\n \"total_tokens\": 340,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-RAY: + - 90cd5ed20cb267ee-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 04 Feb 2025 20:22:02 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '1624' + 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: + - '149999876' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_4ee944acdd3928afbf6c5562403b064a + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_crew_emits_task_failed_event.yaml b/tests/utilities/cassettes/test_crew_emits_task_failed_event.yaml new file mode 100644 index 000000000..db824bb3d --- /dev/null +++ b/tests/utilities/cassettes/test_crew_emits_task_failed_event.yaml @@ -0,0 +1,114 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nTo + give my best complete final answer to the task respond using 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: Just say hi\n\nThis is the expect criteria for your + final answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '836' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AzpkZLpCyjKT5d6Udfx4zAme2sOMy\",\n \"object\": + \"chat.completion\",\n \"created\": 1739300299,\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: hi\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 161,\n \"completion_tokens\": 12,\n \"total_tokens\": 173,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910691d3ab90ebef-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 11 Feb 2025 18:58:20 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=MOH5EY6n3p8JKY53.yz7qzLuLYsEB8QdQXH09loUMBM-1739300300-1.0.1.1-hjb4mk04sMygPFhoFyiySKZSqB_fN5PbhbOyn.kipa3.eLvk7EtriDyjvGkBFIAV13DYnc08BfF_l2kxdx9hfQ; + path=/; expires=Tue, 11-Feb-25 19:28:20 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=uu.cEiV.FfgvSvCdKOooDYJWrwjVEuFeGdQodijGUUI-1739300300232-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 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '1357' + 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: + - '149999810' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_2277503f851195e7d7a43b66eb044454 + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_multiple_handlers_for_same_event.yaml b/tests/utilities/cassettes/test_multiple_handlers_for_same_event.yaml new file mode 100644 index 000000000..c63663f4b --- /dev/null +++ b/tests/utilities/cassettes/test_multiple_handlers_for_same_event.yaml @@ -0,0 +1,111 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nTo + give my best complete final answer to the task respond using 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: Just say hi\n\nThis is the expect criteria for your + final answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '836' + content-type: + - application/json + cookie: + - _cfuvid=gsNyCo_jrDOolzf8SXHDaxQQrEgdR3jgv4OAH8MziDE-1739291824699-0.0.1.1-604800000; + __cf_bm=cRijYuylMGzRGxv3udQL5PhHOR5mRN_9_eLLwevlM_o-1739299455-1.0.1.1-Fszr_Msw0B1.IBMkiunP.VF2ilul1YGZZV8TqMcO3Q2SHvSlqfgm9NHgns1bJrm0wWRvHiCE7wdZfUAOx7T3Lg + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AzpWx6pctOvzu6xsbyg0XfSAc0q9V\",\n \"object\": + \"chat.completion\",\n \"created\": 1739299455,\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: hi\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 161,\n \"completion_tokens\": 12,\n \"total_tokens\": 173,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 91067d3ddc68fa16-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 11 Feb 2025 18:44:16 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: + - '703' + 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: + - '149999810' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_89222c00e4608e8557a135e91b223556 + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_register_handler_adds_new_handler.yaml b/tests/utilities/cassettes/test_register_handler_adds_new_handler.yaml new file mode 100644 index 000000000..b321c0ddb --- /dev/null +++ b/tests/utilities/cassettes/test_register_handler_adds_new_handler.yaml @@ -0,0 +1,114 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nTo + give my best complete final answer to the task respond using 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: Just say hi\n\nThis is the expect criteria for your + final answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '836' + content-type: + - application/json + cookie: + - _cfuvid=gsNyCo_jrDOolzf8SXHDaxQQrEgdR3jgv4OAH8MziDE-1739291824699-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AzpWxLzAcRzigZuIGmjP3ckQgxAom\",\n \"object\": + \"chat.completion\",\n \"created\": 1739299455,\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: hi\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 161,\n \"completion_tokens\": 12,\n \"total_tokens\": 173,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 91067d389e90fa16-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 11 Feb 2025 18:44:15 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=cRijYuylMGzRGxv3udQL5PhHOR5mRN_9_eLLwevlM_o-1739299455-1.0.1.1-Fszr_Msw0B1.IBMkiunP.VF2ilul1YGZZV8TqMcO3Q2SHvSlqfgm9NHgns1bJrm0wWRvHiCE7wdZfUAOx7T3Lg; + path=/; expires=Tue, 11-Feb-25 19:14:15 GMT; 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 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '716' + 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: + - '149999810' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_ef807dc3223d40332aae8a313e96ef3a + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_task_emits_failed_event_on_execution_error.yaml b/tests/utilities/cassettes/test_task_emits_failed_event_on_execution_error.yaml new file mode 100644 index 000000000..9c87bddaa --- /dev/null +++ b/tests/utilities/cassettes/test_task_emits_failed_event_on_execution_error.yaml @@ -0,0 +1,1004 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nYou + ONLY have access to the following tools, and should NEVER make up tools that + are not listed here:\n\nTool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error\n\nIMPORTANT: Use the following format in your + response:\n\n```\nThought: you should always think about what to do\nAction: + the action to take, only one name of [Say Hi], just the name, exactly as it''s + written.\nAction Input: the input to the action, just a simple JSON object, + enclosed in curly braces, using \" to wrap keys and values.\nObservation: the + result of the action\n```\n\nOnce all necessary information is gathered, return + the following format:\n\n```\nThought: I now know the final answer\nFinal Answer: + the final answer to the original input question\n```"}, {"role": "user", "content": + "\nCurrent Task: Just say hi\n\nThis is the expected criteria for your final + answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1303' + content-type: + - application/json + cookie: + - _cfuvid=Cl48aI8.jSRja0Pqr6Jrh3mAnigd4rDn6lhGicyjMPY-1738698987673-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0ceNVvGO3iTja3ZJM0GHPp7fptc6\",\n \"object\": + \"chat.completion\",\n \"created\": 1739488271,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: you should always think + about what to do\\nAction: Say Hi\\nAction Input: {}\",\n \"refusal\": + null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n + \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 261,\n \"completion_tokens\": + 22,\n \"total_tokens\": 283,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 91187efd98829e74-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 13 Feb 2025 23:11:12 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=XgZ48Kh_Np19KQZFMcdhitEO1hYoQQZmGISmqGQyAew-1739488272-1.0.1.1-71ljflXRwwgMFHqNdbWAIPe5U0Svfer60TB92nqmufsvx_NnPNO.ShrjIwdWBpJ6cQIh6szfk6FrIoioemqHgg; + path=/; expires=Thu, 13-Feb-25 23:41:12 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=eFYG1.FIv9a4z_Uqb0svvrE60EPh73_2qTAnZyFX9lA-1739488272138-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: + - '782' + 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: + - '149999697' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_67df2b150e90b637ec98ad5796dfe71d + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nYou + ONLY have access to the following tools, and should NEVER make up tools that + are not listed here:\n\nTool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error\n\nIMPORTANT: Use the following format in your + response:\n\n```\nThought: you should always think about what to do\nAction: + the action to take, only one name of [Say Hi], just the name, exactly as it''s + written.\nAction Input: the input to the action, just a simple JSON object, + enclosed in curly braces, using \" to wrap keys and values.\nObservation: the + result of the action\n```\n\nOnce all necessary information is gathered, return + the following format:\n\n```\nThought: I now know the final answer\nFinal Answer: + the final answer to the original input question\n```"}, {"role": "user", "content": + "\nCurrent Task: Just say hi\n\nThis is the expected criteria for your final + answer: hi\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:"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '2362' + content-type: + - application/json + cookie: + - _cfuvid=eFYG1.FIv9a4z_Uqb0svvrE60EPh73_2qTAnZyFX9lA-1739488272138-0.0.1.1-604800000; + __cf_bm=XgZ48Kh_Np19KQZFMcdhitEO1hYoQQZmGISmqGQyAew-1739488272-1.0.1.1-71ljflXRwwgMFHqNdbWAIPe5U0Svfer60TB92nqmufsvx_NnPNO.ShrjIwdWBpJ6cQIh6szfk6FrIoioemqHgg + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0ceOtrUJ80V8Li7rmZaP56XCp37M\",\n \"object\": + \"chat.completion\",\n \"created\": 1739488272,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: you should always think + about what to do\\nAction: Say Hi\\nAction Input: {}\",\n \"refusal\": + null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n + \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 494,\n \"completion_tokens\": + 22,\n \"total_tokens\": 516,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-RAY: + - 91187f05197b9e74-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 13 Feb 2025 23:11:12 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '545' + 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: + - '149999447' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_d7c1f2c3bae845e5083c5092852e051f + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nYou + ONLY have access to the following tools, and should NEVER make up tools that + are not listed here:\n\nTool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error\n\nIMPORTANT: Use the following format in your + response:\n\n```\nThought: you should always think about what to do\nAction: + the action to take, only one name of [Say Hi], just the name, exactly as it''s + written.\nAction Input: the input to the action, just a simple JSON object, + enclosed in curly braces, using \" to wrap keys and values.\nObservation: the + result of the action\n```\n\nOnce all necessary information is gathered, return + the following format:\n\n```\nThought: I now know the final answer\nFinal Answer: + the final answer to the original input question\n```"}, {"role": "user", "content": + "\nCurrent Task: Just say hi\n\nThis is the expected criteria for your final + answer: hi\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:"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '3421' + content-type: + - application/json + cookie: + - _cfuvid=eFYG1.FIv9a4z_Uqb0svvrE60EPh73_2qTAnZyFX9lA-1739488272138-0.0.1.1-604800000; + __cf_bm=XgZ48Kh_Np19KQZFMcdhitEO1hYoQQZmGISmqGQyAew-1739488272-1.0.1.1-71ljflXRwwgMFHqNdbWAIPe5U0Svfer60TB92nqmufsvx_NnPNO.ShrjIwdWBpJ6cQIh6szfk6FrIoioemqHgg + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0cePLitBGIhHl5SUU1C8s7cmjIEX\",\n \"object\": + \"chat.completion\",\n \"created\": 1739488273,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: you should always think + about what to do\\nAction: Say Hi\\nAction Input: {}\",\n \"refusal\": + null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n + \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 727,\n \"completion_tokens\": + 22,\n \"total_tokens\": 749,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-RAY: + - 91187f098ead9e74-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 13 Feb 2025 23:11:13 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '632' + 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: + - '149999196' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_6c82a00bbf8ab599a6a6cf521cb4bf52 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nYou + ONLY have access to the following tools, and should NEVER make up tools that + are not listed here:\n\nTool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error\n\nIMPORTANT: Use the following format in your + response:\n\n```\nThought: you should always think about what to do\nAction: + the action to take, only one name of [Say Hi], just the name, exactly as it''s + written.\nAction Input: the input to the action, just a simple JSON object, + enclosed in curly braces, using \" to wrap keys and values.\nObservation: the + result of the action\n```\n\nOnce all necessary information is gathered, return + the following format:\n\n```\nThought: I now know the final answer\nFinal Answer: + the final answer to the original input question\n```"}, {"role": "user", "content": + "\nCurrent Task: Just say hi\n\nThis is the expected criteria for your final + answer: hi\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:"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '4480' + content-type: + - application/json + cookie: + - _cfuvid=eFYG1.FIv9a4z_Uqb0svvrE60EPh73_2qTAnZyFX9lA-1739488272138-0.0.1.1-604800000; + __cf_bm=XgZ48Kh_Np19KQZFMcdhitEO1hYoQQZmGISmqGQyAew-1739488272-1.0.1.1-71ljflXRwwgMFHqNdbWAIPe5U0Svfer60TB92nqmufsvx_NnPNO.ShrjIwdWBpJ6cQIh6szfk6FrIoioemqHgg + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0cePDnVjWCsyTlSfvSmP1uUWVqJV\",\n \"object\": + \"chat.completion\",\n \"created\": 1739488273,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: you should always think + about what to do\\nAction: Say Hi\\nAction Input: {}\",\n \"refusal\": + null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n + \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 960,\n \"completion_tokens\": + 22,\n \"total_tokens\": 982,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 91187f0e0bd19e74-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 13 Feb 2025 23:11:14 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: + - '757' + 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: + - '149998945' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_83956b8df7f7137fec9ae6450f3c9a7b + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + CqIiCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkS+SEKEgoQY3Jld2FpLnRl + bGVtZXRyeRKkBwoQy3yskK/xR1Awm7D0OKZhbxIIH0xxCLM8S5cqDENyZXcgQ3JlYXRlZDABOXBZ + LLZd5yMYQYCpOrZd5yMYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjFKGgoOcHl0aG9uX3Zl + cnNpb24SCAoGMy4xMi44Si4KCGNyZXdfa2V5EiIKIGU1ODA3MDFkNTJlYjY1YWZmMjRlZWZlNzhj + NzQ2MjhjSjEKB2NyZXdfaWQSJgokOGQ4NDY3OGYtMDU0NC00MWFiLWIwMjQtMTFkYTRhMTgxNzhj + ShwKDGNyZXdfcHJvY2VzcxIMCgpzZXF1ZW50aWFsShEKC2NyZXdfbWVtb3J5EgIQAEoaChRjcmV3 + X251bWJlcl9vZl90YXNrcxICGAFKGwoVY3Jld19udW1iZXJfb2ZfYWdlbnRzEgIYAUrRAgoLY3Jl + d19hZ2VudHMSwQIKvgJbeyJrZXkiOiAiYWQxNTMxNjFjNWM1YTg1NmFhMGQwNmIyNDljNGM2NGEi + LCAiaWQiOiAiYWQ5OTg5ZTEtNDY5YS00YmQxLTg0ZjQtZWVlNjZhYTBiMjk3IiwgInJvbGUiOiAi + YmFzZV9hZ2VudCIsICJ2ZXJib3NlPyI6IGZhbHNlLCAibWF4X2l0ZXIiOiAyNSwgIm1heF9ycG0i + OiBudWxsLCAiZnVuY3Rpb25fY2FsbGluZ19sbG0iOiAiIiwgImxsbSI6ICJncHQtNG8tbWluaSIs + ICJkZWxlZ2F0aW9uX2VuYWJsZWQ/IjogZmFsc2UsICJhbGxvd19jb2RlX2V4ZWN1dGlvbj8iOiBm + YWxzZSwgIm1heF9yZXRyeV9saW1pdCI6IDIsICJ0b29sc19uYW1lcyI6IFtdfV1K/wEKCmNyZXdf + dGFza3MS8AEK7QFbeyJrZXkiOiAiMWIxNWVmMjM5MTViMjc1NWU4OWEwZWMzYjI2YTEzZDIiLCAi + aWQiOiAiNWUyMWIxOTQtMzE5Ni00NDBhLTg3ZTAtMWEyOGJkZjUxMGUzIiwgImFzeW5jX2V4ZWN1 + dGlvbj8iOiBmYWxzZSwgImh1bWFuX2lucHV0PyI6IGZhbHNlLCAiYWdlbnRfcm9sZSI6ICJiYXNl + X2FnZW50IiwgImFnZW50X2tleSI6ICJhZDE1MzE2MWM1YzVhODU2YWEwZDA2YjI0OWM0YzY0YSIs + ICJ0b29sc19uYW1lcyI6IFtdfV16AhgBhQEAAQAAEo4CChCvtNCi6SXalRPxb+3e9KHyEggbtBZr + f+eAqioMVGFzayBDcmVhdGVkMAE5oJFLtl3nIxhBkOdLtl3nIxhKLgoIY3Jld19rZXkSIgogZTU4 + MDcwMWQ1MmViNjVhZmYyNGVlZmU3OGM3NDYyOGNKMQoHY3Jld19pZBImCiQ4ZDg0Njc4Zi0wNTQ0 + LTQxYWItYjAyNC0xMWRhNGExODE3OGNKLgoIdGFza19rZXkSIgogMWIxNWVmMjM5MTViMjc1NWU4 + OWEwZWMzYjI2YTEzZDJKMQoHdGFza19pZBImCiQ1ZTIxYjE5NC0zMTk2LTQ0MGEtODdlMC0xYTI4 + YmRmNTEwZTN6AhgBhQEAAQAAEqQHChBgHAng7xhBnfS2/GYvkdYbEggsqqZdYq4kICoMQ3JldyBD + cmVhdGVkMAE5MC09t13nIxhBMPdFt13nIxhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMUoa + Cg5weXRob25fdmVyc2lvbhIICgYzLjEyLjhKLgoIY3Jld19rZXkSIgogZTU4MDcwMWQ1MmViNjVh + ZmYyNGVlZmU3OGM3NDYyOGNKMQoHY3Jld19pZBImCiRiMDQ0Njk5NC1jNzMxLTQ4MTQtYjQ0Zi04 + MGUzNmY0NmVlNjdKHAoMY3Jld19wcm9jZXNzEgwKCnNlcXVlbnRpYWxKEQoLY3Jld19tZW1vcnkS + AhAAShoKFGNyZXdfbnVtYmVyX29mX3Rhc2tzEgIYAUobChVjcmV3X251bWJlcl9vZl9hZ2VudHMS + AhgBStECCgtjcmV3X2FnZW50cxLBAgq+Alt7ImtleSI6ICJhZDE1MzE2MWM1YzVhODU2YWEwZDA2 + YjI0OWM0YzY0YSIsICJpZCI6ICJhZDk5ODllMS00NjlhLTRiZDEtODRmNC1lZWU2NmFhMGIyOTci + LCAicm9sZSI6ICJiYXNlX2FnZW50IiwgInZlcmJvc2U/IjogZmFsc2UsICJtYXhfaXRlciI6IDI1 + LCAibWF4X3JwbSI6IG51bGwsICJmdW5jdGlvbl9jYWxsaW5nX2xsbSI6ICIiLCAibGxtIjogImdw + dC00by1taW5pIiwgImRlbGVnYXRpb25fZW5hYmxlZD8iOiBmYWxzZSwgImFsbG93X2NvZGVfZXhl + Y3V0aW9uPyI6IGZhbHNlLCAibWF4X3JldHJ5X2xpbWl0IjogMiwgInRvb2xzX25hbWVzIjogW119 + XUr/AQoKY3Jld190YXNrcxLwAQrtAVt7ImtleSI6ICIxYjE1ZWYyMzkxNWIyNzU1ZTg5YTBlYzNi + MjZhMTNkMiIsICJpZCI6ICI1ZTIxYjE5NC0zMTk2LTQ0MGEtODdlMC0xYTI4YmRmNTEwZTMiLCAi + YXN5bmNfZXhlY3V0aW9uPyI6IGZhbHNlLCAiaHVtYW5faW5wdXQ/IjogZmFsc2UsICJhZ2VudF9y + b2xlIjogImJhc2VfYWdlbnQiLCAiYWdlbnRfa2V5IjogImFkMTUzMTYxYzVjNWE4NTZhYTBkMDZi + MjQ5YzRjNjRhIiwgInRvb2xzX25hbWVzIjogW119XXoCGAGFAQABAAASjgIKEPPkDbccpJ9jDuUl + rzqUoqQSCL6irICbXoxyKgxUYXNrIENyZWF0ZWQwATn4sVm3XecjGEGIF1q3XecjGEouCghjcmV3 + X2tleRIiCiBlNTgwNzAxZDUyZWI2NWFmZjI0ZWVmZTc4Yzc0NjI4Y0oxCgdjcmV3X2lkEiYKJGIw + NDQ2OTk0LWM3MzEtNDgxNC1iNDRmLTgwZTM2ZjQ2ZWU2N0ouCgh0YXNrX2tleRIiCiAxYjE1ZWYy + MzkxNWIyNzU1ZTg5YTBlYzNiMjZhMTNkMkoxCgd0YXNrX2lkEiYKJDVlMjFiMTk0LTMxOTYtNDQw + YS04N2UwLTFhMjhiZGY1MTBlM3oCGAGFAQABAAASpAcKEOZUZG2c1vI5V6bNLpPk3ygSCIKZQpuE + HMQfKgxDcmV3IENyZWF0ZWQwATlwnAC4XecjGEGQMQq4XecjGEobCg5jcmV3YWlfdmVyc2lvbhIJ + CgcwLjEwMC4xShoKDnB5dGhvbl92ZXJzaW9uEggKBjMuMTIuOEouCghjcmV3X2tleRIiCiBlNTgw + NzAxZDUyZWI2NWFmZjI0ZWVmZTc4Yzc0NjI4Y0oxCgdjcmV3X2lkEiYKJGM2ZGQ0OTYwLTU3ZTMt + NGQ5Mi1iZTQzLTg3OTQ0N2NmZjJjNEocCgxjcmV3X3Byb2Nlc3MSDAoKc2VxdWVudGlhbEoRCgtj + cmV3X21lbW9yeRICEABKGgoUY3Jld19udW1iZXJfb2ZfdGFza3MSAhgBShsKFWNyZXdfbnVtYmVy + X29mX2FnZW50cxICGAFK0QIKC2NyZXdfYWdlbnRzEsECCr4CW3sia2V5IjogImFkMTUzMTYxYzVj + NWE4NTZhYTBkMDZiMjQ5YzRjNjRhIiwgImlkIjogImFkOTk4OWUxLTQ2OWEtNGJkMS04NGY0LWVl + ZTY2YWEwYjI5NyIsICJyb2xlIjogImJhc2VfYWdlbnQiLCAidmVyYm9zZT8iOiBmYWxzZSwgIm1h + eF9pdGVyIjogMjUsICJtYXhfcnBtIjogbnVsbCwgImZ1bmN0aW9uX2NhbGxpbmdfbGxtIjogIiIs + ICJsbG0iOiAiZ3B0LTRvLW1pbmkiLCAiZGVsZWdhdGlvbl9lbmFibGVkPyI6IGZhbHNlLCAiYWxs + b3dfY29kZV9leGVjdXRpb24/IjogZmFsc2UsICJtYXhfcmV0cnlfbGltaXQiOiAyLCAidG9vbHNf + bmFtZXMiOiBbXX1dSv8BCgpjcmV3X3Rhc2tzEvABCu0BW3sia2V5IjogIjFiMTVlZjIzOTE1YjI3 + NTVlODlhMGVjM2IyNmExM2QyIiwgImlkIjogIjVlMjFiMTk0LTMxOTYtNDQwYS04N2UwLTFhMjhi + ZGY1MTBlMyIsICJhc3luY19leGVjdXRpb24/IjogZmFsc2UsICJodW1hbl9pbnB1dD8iOiBmYWxz + ZSwgImFnZW50X3JvbGUiOiAiYmFzZV9hZ2VudCIsICJhZ2VudF9rZXkiOiAiYWQxNTMxNjFjNWM1 + YTg1NmFhMGQwNmIyNDljNGM2NGEiLCAidG9vbHNfbmFtZXMiOiBbXX1degIYAYUBAAEAABKOAgoQ + vhlU4CgyTyrgPRf0wlb8eRIIqtS4lWPuJuYqDFRhc2sgQ3JlYXRlZDABOSA9Gbhd5yMYQWiuGbhd + 5yMYSi4KCGNyZXdfa2V5EiIKIGU1ODA3MDFkNTJlYjY1YWZmMjRlZWZlNzhjNzQ2MjhjSjEKB2Ny + ZXdfaWQSJgokYzZkZDQ5NjAtNTdlMy00ZDkyLWJlNDMtODc5NDQ3Y2ZmMmM0Si4KCHRhc2tfa2V5 + EiIKIDFiMTVlZjIzOTE1YjI3NTVlODlhMGVjM2IyNmExM2QySjEKB3Rhc2tfaWQSJgokNWUyMWIx + OTQtMzE5Ni00NDBhLTg3ZTAtMWEyOGJkZjUxMGUzegIYAYUBAAEAABKOAgoQr7izSc/LzkAmDVE4 + TCRtVxIIlEdWL3gr4vAqDFRhc2sgQ3JlYXRlZDABOajMq7hd5yMYQUCErLhd5yMYSi4KCGNyZXdf + a2V5EiIKIGU1ODA3MDFkNTJlYjY1YWZmMjRlZWZlNzhjNzQ2MjhjSjEKB2NyZXdfaWQSJgokYzZk + ZDQ5NjAtNTdlMy00ZDkyLWJlNDMtODc5NDQ3Y2ZmMmM0Si4KCHRhc2tfa2V5EiIKIDFiMTVlZjIz + OTE1YjI3NTVlODlhMGVjM2IyNmExM2QySjEKB3Rhc2tfaWQSJgokYmNhMmRkYmMtZmM4MC00ZTM4 + LWE2ZTAtNTU0MmM2OTIzYTE5egIYAYUBAAEAABJpChAW++bDmEo222QymLgbmnOnEggC9Fj1KYqp + iCoQVG9vbCBVc2FnZSBFcnJvcjABOQja5wRe5yMYQdjm+wRe5yMYShsKDmNyZXdhaV92ZXJzaW9u + EgkKBzAuMTAwLjF6AhgBhQEAAQAAEmkKEOeYSHtVxHT42vgh6qJWipASCG4YjIxTPsQrKhBUb29s + IFVzYWdlIEVycm9yMAE58JKtL17nIxhBeEy8L17nIxhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4x + MDAuMXoCGAGFAQABAAASaQoQd2xGQ0N0fRjEAZb3m591vhII9yEmZE84dukqEFRvb2wgVXNhZ2Ug + RXJyb3IwATkIXzBaXucjGEHgTEJaXucjGEobCg5jcmV3YWlfdmVyc2lvbhIJCgcwLjEwMC4xegIY + AYUBAAEAABJpChCuKrUoVTHcaqSma3csnzpOEgjdvJJFFn7JYioQVG9vbCBVc2FnZSBFcnJvcjAB + OVjIbJFe5yMYQTgIf5Fe5yMYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjF6AhgBhQEAAQAA + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '4389' + 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: + - Thu, 13 Feb 2025 23:11:15 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nYou + ONLY have access to the following tools, and should NEVER make up tools that + are not listed here:\n\nTool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error\n\nIMPORTANT: Use the following format in your + response:\n\n```\nThought: you should always think about what to do\nAction: + the action to take, only one name of [Say Hi], just the name, exactly as it''s + written.\nAction Input: the input to the action, just a simple JSON object, + enclosed in curly braces, using \" to wrap keys and values.\nObservation: the + result of the action\n```\n\nOnce all necessary information is gathered, return + the following format:\n\n```\nThought: I now know the final answer\nFinal Answer: + the final answer to the original input question\n```"}, {"role": "user", "content": + "\nCurrent Task: Just say hi\n\nThis is the expected criteria for your final + answer: hi\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:"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '5539' + content-type: + - application/json + cookie: + - _cfuvid=eFYG1.FIv9a4z_Uqb0svvrE60EPh73_2qTAnZyFX9lA-1739488272138-0.0.1.1-604800000; + __cf_bm=XgZ48Kh_Np19KQZFMcdhitEO1hYoQQZmGISmqGQyAew-1739488272-1.0.1.1-71ljflXRwwgMFHqNdbWAIPe5U0Svfer60TB92nqmufsvx_NnPNO.ShrjIwdWBpJ6cQIh6szfk6FrIoioemqHgg + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0ceQN5mVVSLXPfYhoXL7kYKYC7js\",\n \"object\": + \"chat.completion\",\n \"created\": 1739488274,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: you should always think + about what to do\\nAction: Say Hi\\nAction Input: {}\",\n \"refusal\": + null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n + \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 1193,\n \"completion_tokens\": + 22,\n \"total_tokens\": 1215,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-RAY: + - 91187f13fb279e74-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 13 Feb 2025 23:11:15 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '615' + 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: + - '149998695' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_732a192814669f7e2fce3f349a4b1b8d + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nYou + ONLY have access to the following tools, and should NEVER make up tools that + are not listed here:\n\nTool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error\n\nIMPORTANT: Use the following format in your + response:\n\n```\nThought: you should always think about what to do\nAction: + the action to take, only one name of [Say Hi], just the name, exactly as it''s + written.\nAction Input: the input to the action, just a simple JSON object, + enclosed in curly braces, using \" to wrap keys and values.\nObservation: the + result of the action\n```\n\nOnce all necessary information is gathered, return + the following format:\n\n```\nThought: I now know the final answer\nFinal Answer: + the final answer to the original input question\n```"}, {"role": "user", "content": + "\nCurrent Task: Just say hi\n\nThis is the expected criteria for your final + answer: hi\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:"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: you should always think about what to + do\nAction: Say Hi\nAction Input: {}\nObservation: \nI encountered an error + while trying to use the tool. This was the error: Simulated tool error.\n Tool + Say Hi accepts these inputs: Tool Name: Say Hi\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [Say Hi]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '6598' + content-type: + - application/json + cookie: + - _cfuvid=eFYG1.FIv9a4z_Uqb0svvrE60EPh73_2qTAnZyFX9lA-1739488272138-0.0.1.1-604800000; + __cf_bm=XgZ48Kh_Np19KQZFMcdhitEO1hYoQQZmGISmqGQyAew-1739488272-1.0.1.1-71ljflXRwwgMFHqNdbWAIPe5U0Svfer60TB92nqmufsvx_NnPNO.ShrjIwdWBpJ6cQIh6szfk6FrIoioemqHgg + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0ceRVoFzoUPmiO0sOZVNpLbXD41f\",\n \"object\": + \"chat.completion\",\n \"created\": 1739488275,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I now know the final answer\\nFinal + Answer: hi\\n```\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 1426,\n \"completion_tokens\": 17,\n \"total_tokens\": 1443,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 1024,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_bd83329f63\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 91187f1b3b1e9e74-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 13 Feb 2025 23:11:16 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: + - '618' + 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: + - '149998444' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_b12d08242d920f524028f18e6eb2ef1a + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_tools_emits_error_events.yaml b/tests/utilities/cassettes/test_tools_emits_error_events.yaml new file mode 100644 index 000000000..86d461ee4 --- /dev/null +++ b/tests/utilities/cassettes/test_tools_emits_error_events.yaml @@ -0,0 +1,7984 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1348' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FH6vhCaz7tzH23PyNXSb1fZV93F\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398416,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: I need to utilize the error + tool to generate an error as directed.\\nAction: error_tool\\nAction Input: + {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n \"finish_reason\": + \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 266,\n \"completion_tokens\": + 25,\n \"total_tokens\": 291,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fed4858f4645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:37 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + path=/; expires=Wed, 12-Feb-25 22:43:37 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-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 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '624' + 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: + - '149999685' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_4fc2f9553d6100ada24f6c1033a686b1 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + CvgKCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkSzwoKEgoQY3Jld2FpLnRl + bGVtZXRyeRK8BwoQ0frWr/ChdZU9MoZ6AdNRqxIIKmAD9BKAugUqDENyZXcgQ3JlYXRlZDABOXC/ + l+WklSMYQZCbquWklSMYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjFKGgoOcHl0aG9uX3Zl + cnNpb24SCAoGMy4xMi44Si4KCGNyZXdfa2V5EiIKIDNjZDc4MDc0MDI1NDYwM2JmZGJlYmEyNzBk + NTAyNDJkSjEKB2NyZXdfaWQSJgokM2M4MjQ0MGQtMzE5Yy00ZDcyLTlhMTktYjZlNjNmOGYyNzYx + ShwKDGNyZXdfcHJvY2VzcxIMCgpzZXF1ZW50aWFsShEKC2NyZXdfbWVtb3J5EgIQAEoaChRjcmV3 + X251bWJlcl9vZl90YXNrcxICGAFKGwoVY3Jld19udW1iZXJfb2ZfYWdlbnRzEgIYAUrdAgoLY3Jl + d19hZ2VudHMSzQIKygJbeyJrZXkiOiAiMDYwNmVhZDkwNmQ2YTlmZjUwY2ZmYmFiNjFlYzY4MGYi + LCAiaWQiOiAiNDU4MjVhZTEtOWU4YS00OTkyLTk2OTctOTE1M2JlNGVlZjk1IiwgInJvbGUiOiAi + YmFzZV9hZ2VudCIsICJ2ZXJib3NlPyI6IGZhbHNlLCAibWF4X2l0ZXIiOiAyNSwgIm1heF9ycG0i + OiBudWxsLCAiZnVuY3Rpb25fY2FsbGluZ19sbG0iOiAiIiwgImxsbSI6ICJncHQtNG8tbWluaSIs + ICJkZWxlZ2F0aW9uX2VuYWJsZWQ/IjogZmFsc2UsICJhbGxvd19jb2RlX2V4ZWN1dGlvbj8iOiBm + YWxzZSwgIm1heF9yZXRyeV9saW1pdCI6IDIsICJ0b29sc19uYW1lcyI6IFsiZXJyb3JfdG9vbCJd + fV1KiwIKCmNyZXdfdGFza3MS/AEK+QFbeyJrZXkiOiAiMjExN2I4ZTQwYWFhNmQ0YmJjMzQzYzBm + YTNmMGY0ZWYiLCAiaWQiOiAiNzdmOWZiNmUtNzVjMi00OWU4LWEyYjgtNWEyNmRlOTc2MmY1Iiwg + ImFzeW5jX2V4ZWN1dGlvbj8iOiBmYWxzZSwgImh1bWFuX2lucHV0PyI6IGZhbHNlLCAiYWdlbnRf + cm9sZSI6ICJiYXNlX2FnZW50IiwgImFnZW50X2tleSI6ICIwNjA2ZWFkOTA2ZDZhOWZmNTBjZmZi + YWI2MWVjNjgwZiIsICJ0b29sc19uYW1lcyI6IFsiZXJyb3JfdG9vbCJdfV16AhgBhQEAAQAAEo4C + ChAKRXvphnN/TmqFeUM8brxHEghtO58FP/DT1SoMVGFzayBDcmVhdGVkMAE5uEC/5aSVIxhBcMm/ + 5aSVIxhKLgoIY3Jld19rZXkSIgogM2NkNzgwNzQwMjU0NjAzYmZkYmViYTI3MGQ1MDI0MmRKMQoH + Y3Jld19pZBImCiQzYzgyNDQwZC0zMTljLTRkNzItOWExOS1iNmU2M2Y4ZjI3NjFKLgoIdGFza19r + ZXkSIgogMjExN2I4ZTQwYWFhNmQ0YmJjMzQzYzBmYTNmMGY0ZWZKMQoHdGFza19pZBImCiQ3N2Y5 + ZmI2ZS03NWMyLTQ5ZTgtYTJiOC01YTI2ZGU5NzYyZjV6AhgBhQEAAQAAEmkKECvgI35sRcxQDrk8 + gNM9M1wSCHmBQopqGM6UKhBUb29sIFVzYWdlIEVycm9yMAE5uJioF6WVIxhB4GG3F6WVIxhKGwoO + Y3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAA= + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '1403' + 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: + - Wed, 12 Feb 2025 22:13:41 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '2444' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FH70i7MYqeEn4bb5IQxH3pmzxnj\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398417,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: I need to take action using + the error tool to meet the task's criteria.\\nAction: error_tool\\nAction Input: + {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n \"finish_reason\": + \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 502,\n \"completion_tokens\": + 27,\n \"total_tokens\": 529,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fed4cdd86645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:44 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '7116' + 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: + - '149999426' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_2bc340232d6fb9255e97a6e05119c18f + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}], "model": "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '3545' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHEEw92JyGEE5pcrvIBjr0C9VUk\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398424,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: I need to execute the error + tool again to ensure it generates the required error.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 740,\n \"completion_tokens\": 27,\n \"total_tokens\": 767,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fed79fad8645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:45 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '767' + 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: + - '149999165' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_e5de7e64710f0139ad740736930777f2 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + CpMCCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkS6gEKEgoQY3Jld2FpLnRl + bGVtZXRyeRJpChD7sR7GXzcnWDnWcYsd9rAxEgjB+zF+fMu9xSoQVG9vbCBVc2FnZSBFcnJvcjAB + OVgr1cWmlSMYQejL4MWmlSMYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjF6AhgBhQEAAQAA + EmkKEIzFH2t5TuHKtJ+ziyrezcMSCAv/vNVNpHHwKhBUb29sIFVzYWdlIEVycm9yMAE5uPwP/6aV + IxhBiJgh/6aVIxhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAA= + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '278' + 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: + - Wed, 12 Feb 2025 22:13:46 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '4656' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHF4fZaoKiUPnwUZmdtXAhPXGzD\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398425,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: I will attempt to use the error + tool once more to fulfill the requirement of generating an error.\\nAction: + error_tool\\nAction Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 978,\n \"completion_tokens\": 30,\n \"total_tokens\": 1008,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 910fed7ff9aa645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13: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: + - '662' + 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: + - '149998901' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_77579e629590837f003910294168ba2c + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '5783' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHGjz4BdqRTAKwfYDupovPwVoRo\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398426,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: I need to invoke the error tool + once again to achieve the objective of generating an error.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 1219,\n \"completion_tokens\": 29,\n \"total_tokens\": 1248,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fed84bee5645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:47 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '627' + 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: + - '149998632' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_4deeb2eb5df65512ec0428c821af99c6 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '6904' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHHtYVbuNldm9RCDPK3dtKJXOgO\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398427,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: I will execute the error tool + again to fulfill the requirement of generating an error.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 1459,\n \"completion_tokens\": 27,\n \"total_tokens\": 1486,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 1024,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 910fed899be7645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:47 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: + - '584' + 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: + - '149998366' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_06613cc521757580c84db5256c3fc05d + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}], "model": "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '8020' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHIEJeAeCEkWfKojR46aFlkJnOo\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398428,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: It is crucial that I use the + error tool to achieve the desired outcome of generating an error.\\nAction: + error_tool\\nAction Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 1697,\n \"completion_tokens\": 30,\n \"total_tokens\": 1727,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 1280,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fed8de87d645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:48 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '844' + 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: + - '149998101' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_94a2c81d3af909500724519a00717e92 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}], "model": "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '9144' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHJSPLrsA1L0MfQ3fHqHSA1annU\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398429,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: I will attempt to use the error + tool again to generate the required error.\\nAction: error_tool\\nAction Input: + {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n \"finish_reason\": + \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 1938,\n \"completion_tokens\": + 26,\n \"total_tokens\": 1964,\n \"prompt_tokens_details\": {\n \"cached_tokens\": + 1536,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 910fed944801645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:49 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: + - '689' + 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: + - '149997835' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_99633b5796b17c28813c048110427d71 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + CtQECiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkSqwQKEgoQY3Jld2FpLnRl + bGVtZXRyeRJpChBRVrcidDPYJQRCwfWhGD+YEgjFo7G9exrVnCoQVG9vbCBVc2FnZSBFcnJvcjAB + OZBxNiynlSMYQfD1RyynlSMYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjF6AhgBhQEAAQAA + EmkKEI47MTyU4xCLYWlfvyvg0joSCOSckNNSHpNVKhBUb29sIFVzYWdlIEVycm9yMAE50HQPVqeV + IxhBcDAdVqeVIxhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAASaQoQV2TU + QZp89k5go2LDP1WMFhIIihuxvZSBmiQqEFRvb2wgVXNhZ2UgRXJyb3IwATmw4cGDp5UjGEGYc9SD + p5UjGEobCg5jcmV3YWlfdmVyc2lvbhIJCgcwLjEwMC4xegIYAYUBAAEAABJpChB2FWguwfKVn4ZG + +abEGGtMEgjs0NjquXFSgioQVG9vbCBVc2FnZSBFcnJvcjABOfh8xMCnlSMYQYCb18CnlSMYShsK + DmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjF6AhgBhQEAAQAAEmkKEBaiySO2umQI8gIMyOJKef8S + COtYvYU9YJzHKhBUb29sIFVzYWdlIEVycm9yMAE5OIM68KeVIxhBYBZS8KeVIxhKGwoOY3Jld2Fp + X3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAA= + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '599' + 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: + - Wed, 12 Feb 2025 22:13:51 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '10248' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHJ5pQeJip8Vuc4sIgHfFEusZ5E\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398429,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: I need to invoke the error tool + yet again to satisfy the requirement of producing an error.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 2175,\n \"completion_tokens\": 29,\n \"total_tokens\": 2204,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 1792,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 910fed994d45645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:51 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: + - '1847' + 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: + - '149997573' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_6995dcc7bff630b9f8bb5b7efecda874 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '11369' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHLBvHm3RveIHT5nFIeDTW1GG3k\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398431,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: I need to execute the error + tool again to achieve the goal of producing an error.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 2415,\n \"completion_tokens\": 28,\n \"total_tokens\": 2443,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 2048,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910feda57bd5645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:52 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '594' + 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: + - '149997307' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 1ms + x-request-id: + - req_73d9af8616cc03b01c1769b853a87d12 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}], "model": "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '12480' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHMOtwqTEM5Ig1RuQCEP2kxDewo\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398432,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I must use the error tool + again to generate an error as required by the task.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 2654,\n \"completion_tokens\": 30,\n \"total_tokens\": 2684,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 2304,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fedaa0957645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:53 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '690' + 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: + - '149997042' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 1ms + x-request-id: + - req_981126d0d9130bc6664cfb6bc58efd73 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '13592' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHNeUzJLjdQvArhWBpi7iRMcVeZ\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398433,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I am required to use the + error tool one more time to ensure that it produces the expected error outcome.\\nAction: + error_tool\\nAction Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 2895,\n \"completion_tokens\": 34,\n \"total_tokens\": 2929,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 2560,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fedb0081c645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:54 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '876' + 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: + - '149996779' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 1ms + x-request-id: + - req_030fba022dc80d57a5dcb287e9a29d3b + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '14731' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHOKcbMZHSxhPSZE9cEbssUrfeb\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398434,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I need to use the error + tool again to fulfill the requirement of generating an error result.\\nAction: + error_tool\\nAction Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 3140,\n \"completion_tokens\": 31,\n \"total_tokens\": 3171,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 2816,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fedb66f76645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:55 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '715' + 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: + - '149996509' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 1ms + x-request-id: + - req_a92d80beb56e73a75dc68b3838ae7257 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '15858' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHPIh40ysFBxcbYO7XfbwOxxprE\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398435,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I must use the error tool + again in order to fulfill the task requirement of generating an error.\\nAction: + error_tool\\nAction Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 3382,\n \"completion_tokens\": 32,\n \"total_tokens\": 3414,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 2944,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fedbbed8a645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:55 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '744' + 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: + - '149996240' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 1ms + x-request-id: + - req_6f1b61ec87e14a048a4ef70c4530f91f + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + Cr8FCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkSlgUKEgoQY3Jld2FpLnRl + bGVtZXRyeRJpChDTSM9Cs5d2sGmD/LtcZjRtEgjUyLL/PcPI2CoQVG9vbCBVc2FnZSBFcnJvcjAB + Obik3WSolSMYQRig8GSolSMYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjF6AhgBhQEAAQAA + EmkKELrbz7lhN3OEjLlJViZ+DycSCKQe/bQ9nqoBKhBUb29sIFVzYWdlIEVycm9yMAE5SI1SkKiV + IxhB+LZpkKiVIxhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAASaQoQgmE9 + Wbue47OMffOO8FmjnRIIIh7ziBS93aIqEFRvb2wgVXNhZ2UgRXJyb3IwATmgjE7JqJUjGEFgWmbJ + qJUjGEobCg5jcmV3YWlfdmVyc2lvbhIJCgcwLjEwMC4xegIYAYUBAAEAABJpChBHCdWINZRypEjZ + W0qUEG7jEgh3PGQYXvnGpyoQVG9vbCBVc2FnZSBFcnJvcjABOXAj2AWplSMYQZhR6wWplSMYShsK + DmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjF6AhgBhQEAAQAAEmkKEB6vVnYi2AjNY+Azdm9UEOQS + CBSmm0s+H3vPKhBUb29sIFVzYWdlIEVycm9yMAE5yC6LNamVIxhBcCSdNamVIxhKGwoOY3Jld2Fp + X3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAASaQoQgGwbh1JdpLWke8EcMezg1xII3TeW1siv + 2Z0qEFRvb2wgVXNhZ2UgRXJyb3IwATngPBRyqZUjGEEYDyhyqZUjGEobCg5jcmV3YWlfdmVyc2lv + bhIJCgcwLjEwMC4xegIYAYUBAAEAAA== + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '706' + 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: + - Wed, 12 Feb 2025 22:13:56 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '16989' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHQIaKaXSVyoZSfmMUXzZU2FdTN\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398436,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I need to invoke the error + tool once again to ensure that it generates the required error.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 3625,\n \"completion_tokens\": 31,\n \"total_tokens\": 3656,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 3200,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fedc1bc6e645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:57 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '941' + 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: + - '149995972' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 1ms + x-request-id: + - req_d30a47f73f07f255d4f163209f64069e + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '18114' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHRMzUfYmkTrjp1Aq68ngGgqx8R\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398437,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: It is imperative that + I use the error tool once more to achieve the objective of generating an error.\\nAction: + error_tool\\nAction Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 3867,\n \"completion_tokens\": 33,\n \"total_tokens\": 3900,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 3456,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fedc83b86645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:58 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '1001' + 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: + - '149995706' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 1ms + x-request-id: + - req_1d1250bbb4668c11f16c2bcc2ed81cd7 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: It is imperative that I use the error + tool once more to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '19250' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHSPObUFeE3ms9giwTuNrelc4XC\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398438,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I will attempt to use + the error tool once again to meet the requirement of generating an error.\\nAction: + error_tool\\nAction Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 4111,\n \"completion_tokens\": 32,\n \"total_tokens\": 4143,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 3712,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fedcfbcc1645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:13:59 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '916' + 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: + - '149995435' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 1ms + x-request-id: + - req_f19b2dbbbc896921211bb47c381f8931 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: It is imperative that I use the error + tool once more to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will attempt to use the error tool + once again to meet the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '20380' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHTjrfFlHx3oqvNsiFT4LwJ1YoE\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398439,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I need to invoke the error + tool again to generate the required error.\\nAction: error_tool\\nAction Input: + {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n \"finish_reason\": + \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 4354,\n \"completion_tokens\": + 27,\n \"total_tokens\": 4381,\n \"prompt_tokens_details\": {\n \"cached_tokens\": + 3968,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fedd65c29645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:14:00 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '679' + 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: + - '149995167' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 1ms + x-request-id: + - req_d2674fde0c7fb93df248854b661e987a + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: It is imperative that I use the error + tool once more to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will attempt to use the error tool + once again to meet the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool again + to generate the required error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}], "model": "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '21484' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHUhJJXPb2qT9vj11m8a69bGHtG\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398440,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I need to use the error + tool one last time to fulfill the requirement of generating an error.\\nAction: + error_tool\\nAction Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 4592,\n \"completion_tokens\": 32,\n \"total_tokens\": 4624,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 4224,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910feddb5a33645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:14:01 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '922' + 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: + - '149994906' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 2ms + x-request-id: + - req_1a84525050669cc645198bb98792e4bf + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + CtQECiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkSqwQKEgoQY3Jld2FpLnRl + bGVtZXRyeRJpChAKBbGTtAvlRxHDSNFY9ezjEggllIhhDvqeISoQVG9vbCBVc2FnZSBFcnJvcjAB + OZAyDbCplSMYQQBVILCplSMYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjF6AhgBhQEAAQAA + EmkKEMB6X+K6/Wj48Jy8zUW/XLgSCCMwX0eJr7/5KhBUb29sIFVzYWdlIEVycm9yMAE5uM6r96mV + IxhBaCK896mVIxhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAASaQoQGdw6 + Baw+XVW52/Q2Cln+1hII6iJwodf5HyQqEFRvb2wgVXNhZ2UgRXJyb3IwATnIKjg2qpUjGEGwqk02 + qpUjGEobCg5jcmV3YWlfdmVyc2lvbhIJCgcwLjEwMC4xegIYAYUBAAEAABJpChDEPiaA7zRCTPn+ + MlcRw8wkEgiejl1vq5WoiioQVG9vbCBVc2FnZSBFcnJvcjABOSBr92WqlSMYQQhuDGaqlSMYShsK + DmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjF6AhgBhQEAAQAAEmkKEFlwF2/WR2U5pkcL/hsbbPoS + CHZWpR/iTVPMKhBUb29sIFVzYWdlIEVycm9yMAE5SNkyo6qVIxhBmCRHo6qVIxhKGwoOY3Jld2Fp + X3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAA= + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '599' + 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: + - Wed, 12 Feb 2025 22:14:01 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: It is imperative that I use the error + tool once more to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will attempt to use the error tool + once again to meet the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool again + to generate the required error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I need to use the error tool one last time to fulfill the requirement of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}], "model": "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '22612' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHVH7MvRoFT7B7e7IpkzueKwy9j\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398441,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I will attempt to use + the error tool again to generate the required error outcome.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 4835,\n \"completion_tokens\": 29,\n \"total_tokens\": 4864,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 4480,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fede1c96d645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:14:02 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '846' + 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: + - '149994638' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 2ms + x-request-id: + - req_327bfa4c759b13ab552379caf0187607 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + CqcBCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkSfwoSChBjcmV3YWkudGVs + ZW1ldHJ5EmkKEAhGZqveighMFSniJFHCB3sSCMUr2V0Yhf4pKhBUb29sIFVzYWdlIEVycm9yMAE5 + EOlK26qVIxhBIMhW26qVIxhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAA= + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '170' + 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: + - Wed, 12 Feb 2025 22:14:06 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: It is imperative that I use the error + tool once more to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will attempt to use the error tool + once again to meet the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool again + to generate the required error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I need to use the error tool one last time to fulfill the requirement of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I will attempt to use the error tool again to generate the required error outcome.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '23729' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHeaj8KEtbcNzmziMlzqLVCSgIE\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398450,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I need to utilize the + error tool once more to ensure an error is generated as required.\\nAction: + error_tool\\nAction Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 5075,\n \"completion_tokens\": 31,\n \"total_tokens\": 5106,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 4736,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fede7bfea645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:14:10 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '8545' + 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: + - '149994373' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 2ms + x-request-id: + - req_88b44516547a11a57f01a140004ecc9d + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + CqcBCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkSfwoSChBjcmV3YWkudGVs + ZW1ldHJ5EmkKEO0uhb4qh6dmtSMJyGzR2WASCBOzRYDB/NrSKhBUb29sIFVzYWdlIEVycm9yMAE5 + wJ//5ayVIxhBMMIS5qyVIxhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAA= + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '170' + 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: + - Wed, 12 Feb 2025 22:14:11 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: It is imperative that I use the error + tool once more to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will attempt to use the error tool + once again to meet the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool again + to generate the required error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I need to use the error tool one last time to fulfill the requirement of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I will attempt to use the error tool again to generate the required error outcome.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to utilize the error tool once + more to ensure an error is generated as required.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '24851' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHfMTYklUHK8nx6Q0IwtIiisPjJ\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398451,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I will invoke the error + tool yet again to fulfill the objective of generating an error.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 5317,\n \"completion_tokens\": 30,\n \"total_tokens\": 5347,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 4992,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fee1e7ce9645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:14:11 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '726' + 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: + - '149994107' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 2ms + x-request-id: + - req_65c6000bda31086a102d26bf09b22ce2 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: It is imperative that I use the error + tool once more to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will attempt to use the error tool + once again to meet the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool again + to generate the required error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I need to use the error tool one last time to fulfill the requirement of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I will attempt to use the error tool again to generate the required error outcome.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to utilize the error tool once + more to ensure an error is generated as required.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will invoke the error tool yet again + to fulfill the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '25973' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHgLR0KLc6GxWG8GzBuwoXtw1R0\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398452,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I must use the error tool + once more to ensure that it produces the necessary error result.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 5558,\n \"completion_tokens\": 31,\n \"total_tokens\": 5589,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 5120,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fee23eac8645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:14:12 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '892' + 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: + - '149993840' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 2ms + x-request-id: + - req_1448bb4a556fe74c082bfc8a11b6303b + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: It is imperative that I use the error + tool once more to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will attempt to use the error tool + once again to meet the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool again + to generate the required error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I need to use the error tool one last time to fulfill the requirement of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I will attempt to use the error tool again to generate the required error outcome.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to utilize the error tool once + more to ensure an error is generated as required.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will invoke the error tool yet again + to fulfill the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool once more to + ensure that it produces the necessary error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}], "model": + "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '27098' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHhKgkjrj8tcHYyE71DkOjdKfSv\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398453,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I need to execute the + error tool again to generate the required error.\\nAction: error_tool\\nAction + Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 5800,\n \"completion_tokens\": 27,\n \"total_tokens\": 5827,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 5376,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fee2a19ea645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:14:13 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '677' + 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: + - '149993574' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 2ms + x-request-id: + - req_88caa8151dd23fc2bda4fd3bfbae01d9 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: It is imperative that I use the error + tool once more to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will attempt to use the error tool + once again to meet the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool again + to generate the required error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I need to use the error tool one last time to fulfill the requirement of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I will attempt to use the error tool again to generate the required error outcome.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to utilize the error tool once + more to ensure an error is generated as required.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will invoke the error tool yet again + to fulfill the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool once more to + ensure that it produces the necessary error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to execute the error tool again + to generate the required error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}], "model": "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '28203' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHhCKtham1XIcrJqd78PO3EN7OI\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398453,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I will use the error tool + once more to achieve the result of generating an error as required.\\nAction: + error_tool\\nAction Input: {}\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 6038,\n \"completion_tokens\": 32,\n \"total_tokens\": 6070,\n \"prompt_tokens_details\": + {\n \"cached_tokens\": 5632,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fee2ede8c645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:14:14 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '771' + 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: + - '149993311' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 2ms + x-request-id: + - req_a35693c7ae4568930b98e99dc8107c67 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + an assistant that tests error handling\nYour personal goal is: Try to use the + error tool\nYou ONLY have access to the following tools, and should NEVER make + up tools that are not listed here:\n\nTool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error\n\nIMPORTANT: Use the + following format in your response:\n\n```\nThought: you should always think + about what to do\nAction: the action to take, only one name of [error_tool], + just the name, exactly as it''s written.\nAction Input: the input to the action, + just a simple JSON object, enclosed in curly braces, using \" to wrap keys and + values.\nObservation: the result of the action\n```\n\nOnce all necessary information + is gathered, return the following format:\n\n```\nThought: I now know the final + answer\nFinal Answer: the final answer to the original input question\n```"}, + {"role": "user", "content": "\nCurrent Task: Use the error tool\n\nThis is the + expected criteria for your final answer: This should error\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:"}, {"role": "assistant", "content": "Thought: + I need to utilize the error tool to generate an error as directed.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to take action using the error tool + to meet the task''s criteria.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I need to execute the error tool again to ensure it generates the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will attempt to use the error tool once + more to fulfill the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool once again + to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I will execute the error tool again to fulfill + the requirement of generating an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + It is crucial that I use the error tool to achieve the desired outcome of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "Thought: + I will attempt to use the error tool again to generate the required error.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to invoke the error tool yet again + to satisfy the requirement of producing an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "Thought: I need to execute the error tool again to + achieve the goal of producing an error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I must use the error tool again to generate an error as required by the task.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I am required to use the error tool one + more time to ensure that it produces the expected error outcome.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to use the error tool again to + fulfill the requirement of generating an error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool again in order + to fulfill the task requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool once + again to ensure that it generates the required error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: It is imperative that I use the error + tool once more to achieve the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will attempt to use the error tool + once again to meet the requirement of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to invoke the error tool again + to generate the required error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I need to use the error tool one last time to fulfill the requirement of generating + an error.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I will attempt to use the error tool again to generate the required error outcome.\nAction: + error_tool\nAction Input: {}\nObservation: \nI encountered an error while trying + to use the tool. This was the error: Simulated tool error.\n Tool error_tool + accepts these inputs: Tool Name: error_tool\nTool Arguments: {}\nTool Description: + This tool always raises an error.\nMoving on then. I MUST either use a tool + (use one at time) OR give my best final answer not both at the same time. When + responding, I must use the following format:\n\n```\nThought: you should always + think about what to do\nAction: the action to take, should be one of [error_tool]\nAction + Input: the input to the action, dictionary enclosed in curly braces\nObservation: + the result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to utilize the error tool once + more to ensure an error is generated as required.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I will invoke the error tool yet again + to fulfill the objective of generating an error.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I must use the error tool once more to + ensure that it produces the necessary error result.\nAction: error_tool\nAction + Input: {}\nObservation: \nI encountered an error while trying to use the tool. + This was the error: Simulated tool error.\n Tool error_tool accepts these inputs: + Tool Name: error_tool\nTool Arguments: {}\nTool Description: This tool always + raises an error.\nMoving on then. I MUST either use a tool (use one at time) + OR give my best final answer not both at the same time. When responding, I must + use the following format:\n\n```\nThought: you should always think about what + to do\nAction: the action to take, should be one of [error_tool]\nAction Input: + the input to the action, dictionary enclosed in curly braces\nObservation: the + result of the action\n```\nThis Thought/Action/Action Input/Result can repeat + N times. Once I know the final answer, I must return the following format:\n\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\n```"}, {"role": + "assistant", "content": "```\nThought: I need to execute the error tool again + to generate the required error.\nAction: error_tool\nAction Input: {}\nObservation: + \nI encountered an error while trying to use the tool. This was the error: Simulated + tool error.\n Tool error_tool accepts these inputs: Tool Name: error_tool\nTool + Arguments: {}\nTool Description: This tool always raises an error.\nMoving on + then. I MUST either use a tool (use one at time) OR give my best final answer + not both at the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I will use the error tool once more to achieve the result of generating an error + as required.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```"}, {"role": "assistant", "content": "```\nThought: + I will use the error tool once more to achieve the result of generating an error + as required.\nAction: error_tool\nAction Input: {}\nObservation: \nI encountered + an error while trying to use the tool. This was the error: Simulated tool error.\n + Tool error_tool accepts these inputs: Tool Name: error_tool\nTool Arguments: + {}\nTool Description: This tool always raises an error.\nMoving on then. I MUST + either use a tool (use one at time) OR give my best final answer not both at + the same time. When responding, I must use the following format:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, should + be one of [error_tool]\nAction Input: the input to the action, dictionary enclosed + in curly braces\nObservation: the result of the action\n```\nThis Thought/Action/Action + Input/Result can repeat N times. Once I know the final answer, I must return + the following format:\n\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\n```\nNow it''s time you MUST give your absolute + best final answer. You''ll ignore all previous instructions, stop using any + tools, and just return your absolute BEST Final answer."}], "model": "gpt-4o-mini", + "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '30633' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHiH5ItD56EXGX4Gfxfwpt3sHTz\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398454,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I now know the final answer\\nFinal + Answer: This task has successfully demonstrated the usage of the error tool + by consistently raising simulated errors upon invocation. The process has effectively + met the requirement of generating errors as expected throughout the iterations. + Ultimately, the error handling mechanism has been validated.\\n```\",\n \"refusal\": + null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n + \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 6557,\n \"completion_tokens\": + 60,\n \"total_tokens\": 6617,\n \"prompt_tokens_details\": {\n \"cached_tokens\": + 5888,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fee348ccd645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:14:15 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '1307' + 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: + - '149992733' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 2ms + x-request-id: + - req_aec2f30fb0c92a93aa9bddd27c067c12 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + CukDCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkSwAMKEgoQY3Jld2FpLnRl + bGVtZXRyeRJpChA7b+yjDRMEafS+rJzxMR2REgjXqtrENdZR+CoQVG9vbCBVc2FnZSBFcnJvcjAB + OYi4chmtlSMYQYjJhBmtlSMYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjF6AhgBhQEAAQAA + EmkKEGqDv4ux3Md/wlB1LE5DrWESCIh+R2EiPMrsKhBUb29sIFVzYWdlIEVycm9yMAE5kDT+VK2V + IxhBICgRVa2VIxhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMXoCGAGFAQABAAASaQoQCjHw + l8wIMOh+n0R6fA14kxIIv5OBBhpNmmwqEFRvb2wgVXNhZ2UgRXJyb3IwATnAyE2CrZUjGEFIlFmC + rZUjGEobCg5jcmV3YWlfdmVyc2lvbhIJCgcwLjEwMC4xegIYAYUBAAEAABJpChCE9A42c+0uZsg+ + oJNAoATjEgg+O6gpajP9UioQVG9vbCBVc2FnZSBFcnJvcjABORDNi7itlSMYQYhTnLitlSMYShsK + DmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjF6AhgBhQEAAQAA + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '492' + 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: + - Wed, 12 Feb 2025 22:14:16 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Assess the quality of the task + completed based on the description, expected output, and actual results.\n\nTask + Description:\nUse the error tool\n\nExpected Output:\nThis should error\n\nActual + Output:\nThis task has successfully demonstrated the usage of the error tool + by consistently raising simulated errors upon invocation. The process has effectively + met the requirement of generating errors as expected throughout the iterations. + Ultimately, the error handling mechanism has been validated.\n```\n\nPlease + provide:\n- Bullet points suggestions to improve future similar tasks\n- A score + from 0 to 10 evaluating on completion, quality, and overall performance- Entities + extracted from the task output, if any, their type, description, and relationships"}], + "model": "gpt-4o-mini", "tool_choice": {"type": "function", "function": {"name": + "TaskEvaluation"}}, "tools": [{"type": "function", "function": {"name": "TaskEvaluation", + "description": "Correctly extracted `TaskEvaluation` with all the required parameters + with correct types", "parameters": {"$defs": {"Entity": {"properties": {"name": + {"description": "The name of the entity.", "title": "Name", "type": "string"}, + "type": {"description": "The type of the entity.", "title": "Type", "type": + "string"}, "description": {"description": "Description of the entity.", "title": + "Description", "type": "string"}, "relationships": {"description": "Relationships + of the entity.", "items": {"type": "string"}, "title": "Relationships", "type": + "array"}}, "required": ["name", "type", "description", "relationships"], "title": + "Entity", "type": "object"}}, "properties": {"suggestions": {"description": + "Suggestions to improve future similar tasks.", "items": {"type": "string"}, + "title": "Suggestions", "type": "array"}, "quality": {"description": "A score + from 0 to 10 evaluating on completion, quality, and overall performance, all + taking into account the task description, expected output, and the result of + the task.", "title": "Quality", "type": "number"}, "entities": {"description": + "Entities extracted from the task output.", "items": {"$ref": "#/$defs/Entity"}, + "title": "Entities", "type": "array"}}, "required": ["entities", "quality", + "suggestions"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '2281' + content-type: + - application/json + cookie: + - __cf_bm=NjDQE2T9zcxydfwNgOc.SrJBMJcVHlHBYFY3df_H.Jc-1739398417-1.0.1.1-5Kg1Fk4iJD17yky.x.u91SYwct5VtRSNjjovuKJ15amw9q4ZoMGY3ryEYiLmcaH0e2NaABkfj_CJhbQIJuF8Jw; + _cfuvid=GefCcEtb_Gem93E4a9Hvt3Xyof1YQZVJAXBb9I6pEUs-1739398417375-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-B0FHlZrGJAK15O3NFva2aEeqaMItJ\",\n \"object\": + \"chat.completion\",\n \"created\": 1739398457,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n + \ \"id\": \"call_NEctVd0EbiVH38MTfnrXwzrx\",\n \"type\": + \"function\",\n \"function\": {\n \"name\": \"TaskEvaluation\",\n + \ \"arguments\": \"{\\\"suggestions\\\":[\\\"Clearly define what + type of errors are expected to be produced (e.g., syntax errors, runtime errors)\\\",\\\"Include + examples of the expected output format for the errors\\\",\\\"Specify the conditions + under which the error tool should be triggered\\\",\\\"Add instructions on how + to handle or log the errors generated\\\",\\\"Outline the expected behavior + of the system after the errors are raised to validate the error handling mechanism\\\"],\\\"quality\\\":6,\\\"entities\\\":[{\\\"name\\\":\\\"error + tool\\\",\\\"type\\\":\\\"Tool\\\",\\\"description\\\":\\\"A tool used to simulate + and raise errors during task execution.\\\",\\\"relationships\\\":[\\\"used + in error handling\\\",\\\"helps in validating error scenarios\\\"]},{\\\"name\\\":\\\"errors\\\",\\\"type\\\":\\\"Outcome\\\",\\\"description\\\":\\\"Simulated + errors produced by the error tool during its invocation.\\\",\\\"relationships\\\":[\\\"generated + by the error tool\\\"]},{\\\"name\\\":\\\"error handling mechanism\\\",\\\"type\\\":\\\"System\\\",\\\"description\\\":\\\"The + component of the system responsible for managing errors and ensuring proper + feedback during execution.\\\",\\\"relationships\\\":[\\\"validated by the output + of the error tool\\\"]}]}\"\n }\n }\n ],\n \"refusal\": + null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n + \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 321,\n \"completion_tokens\": + 198,\n \"total_tokens\": 519,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 910fee479a35645f-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 12 Feb 2025 22:14:20 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '3366' + 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: + - '149999796' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_dd4090f2ef7bb898e293b19bd1f05e06 + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/cassettes/test_tools_emits_finished_events.yaml b/tests/utilities/cassettes/test_tools_emits_finished_events.yaml new file mode 100644 index 000000000..548ac2b0a --- /dev/null +++ b/tests/utilities/cassettes/test_tools_emits_finished_events.yaml @@ -0,0 +1,512 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nYou + ONLY have access to the following tools, and should NEVER make up tools that + are not listed here:\n\nTool Name: say_hi\nTool Arguments: {}\nTool Description: + Say hi\n\nIMPORTANT: Use the following format in your response:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, only one + name of [say_hi], just the name, exactly as it''s written.\nAction Input: the + input to the action, just a simple JSON object, enclosed in curly braces, using + \" to wrap keys and values.\nObservation: the result of the action\n```\n\nOnce + all necessary information is gathered, return the following format:\n\n```\nThought: + I now know the final answer\nFinal Answer: the final answer to the original + input question\n```"}, {"role": "user", "content": "\nCurrent Task: Just say + hi\n\nThis is the expect criteria for your final answer: hi\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:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1275' + content-type: + - application/json + cookie: + - _cfuvid=efIHP1NUsh1dFewGJBu4YoBu6hhGa8vjOOKQglYQGno-1739214901306-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AzUA6kJQfpUvB4CGot4gSfAIR0foh\",\n \"object\": + \"chat.completion\",\n \"created\": 1739217314,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"you should always think about what to + do \\nAction: say_hi \\nAction Input: {} \",\n \"refusal\": null\n + \ },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }\n + \ ],\n \"usage\": {\n \"prompt_tokens\": 257,\n \"completion_tokens\": + 19,\n \"total_tokens\": 276,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 90fea7d78e1fceb9-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 10 Feb 2025 19:55:15 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=fmlg1wjOwuOwZhUUOEtL1tQYluAPumn7AHLF8s0EU2Y-1739217315-1.0.1.1-PQDvxn8TOhzaznlHjwVsqPZUzbAyJWFkvzCubfNJydTu2_AyA1cJ8hkM0khsEE4UY_xp8iPe2gSGmH1ydrDa0Q; + path=/; expires=Mon, 10-Feb-25 20:25:15 GMT; 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 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '526' + 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: + - '149999703' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_f6358ff0cc7a2b8d2e167ab00a40f2a4 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "system", "content": "You are base_agent. You are + a helpful assistant that just says hi\nYour personal goal is: Just say hi\nYou + ONLY have access to the following tools, and should NEVER make up tools that + are not listed here:\n\nTool Name: say_hi\nTool Arguments: {}\nTool Description: + Say hi\n\nIMPORTANT: Use the following format in your response:\n\n```\nThought: + you should always think about what to do\nAction: the action to take, only one + name of [say_hi], just the name, exactly as it''s written.\nAction Input: the + input to the action, just a simple JSON object, enclosed in curly braces, using + \" to wrap keys and values.\nObservation: the result of the action\n```\n\nOnce + all necessary information is gathered, return the following format:\n\n```\nThought: + I now know the final answer\nFinal Answer: the final answer to the original + input question\n```"}, {"role": "user", "content": "\nCurrent Task: Just say + hi\n\nThis is the expect criteria for your final answer: hi\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:"}, {"role": "assistant", "content": "you + should always think about what to do \nAction: say_hi \nAction Input: {} \nObservation: + hi"}], "model": "gpt-4o-mini", "stop": ["\nObservation:"]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1410' + content-type: + - application/json + cookie: + - _cfuvid=efIHP1NUsh1dFewGJBu4YoBu6hhGa8vjOOKQglYQGno-1739214901306-0.0.1.1-604800000; + __cf_bm=fmlg1wjOwuOwZhUUOEtL1tQYluAPumn7AHLF8s0EU2Y-1739217315-1.0.1.1-PQDvxn8TOhzaznlHjwVsqPZUzbAyJWFkvzCubfNJydTu2_AyA1cJ8hkM0khsEE4UY_xp8iPe2gSGmH1ydrDa0Q + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AzUA7QdlQy1WZZijxNWUv25sZycg0\",\n \"object\": + \"chat.completion\",\n \"created\": 1739217315,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"```\\nThought: I now know the final answer\\nFinal + Answer: hi\\n```\",\n \"refusal\": null\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 283,\n \"completion_tokens\": 17,\n \"total_tokens\": 300,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 90fea7dc5ba6ceb9-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 10 Feb 2025 19:55:15 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '388' + 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: + - '149999680' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_7d7c68b90b3a9c3ac6092fe17ac1185a + http_version: HTTP/1.1 + status_code: 200 +- request: + body: !!binary | + CoMzCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkS2jIKEgoQY3Jld2FpLnRl + bGVtZXRyeRKOAgoQ2EINIGZRoXD589od63oHmBIIMfUgEWudUbIqDFRhc2sgQ3JlYXRlZDABOcjI + 7lbu8CIYQZB471bu8CIYSi4KCGNyZXdfa2V5EiIKIGU1ODA3MDFkNTJlYjY1YWZmMjRlZWZlNzhj + NzQ2MjhjSjEKB2NyZXdfaWQSJgokNTE4ODdiOTktY2FlMy00Yjc4LWJjMGEtMDY4MmVmNWEzNGQ0 + Si4KCHRhc2tfa2V5EiIKIDFiMTVlZjIzOTE1YjI3NTVlODlhMGVjM2IyNmExM2QySjEKB3Rhc2tf + aWQSJgokMzlmMDlmMWUtOTJmOC00ZGJiLTgzNDAtNjU2ZmVkMDk3ZjM0egIYAYUBAAEAABKkBwoQ + RzhWoF6ewSTS/qUc9yeFRhIIM3SNZCwjz5AqDENyZXcgQ3JlYXRlZDABOQjrGlru8CIYQdgbKVru + 8CIYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjBKGgoOcHl0aG9uX3ZlcnNpb24SCAoGMy4x + Mi44Si4KCGNyZXdfa2V5EiIKIGU1ODA3MDFkNTJlYjY1YWZmMjRlZWZlNzhjNzQ2MjhjSjEKB2Ny + ZXdfaWQSJgokYzk4ODFkY2YtMmM0MS00ZjRlLTgzMjctNjJjYjFhYjJkOTg4ShwKDGNyZXdfcHJv + Y2VzcxIMCgpzZXF1ZW50aWFsShEKC2NyZXdfbWVtb3J5EgIQAEoaChRjcmV3X251bWJlcl9vZl90 + YXNrcxICGAFKGwoVY3Jld19udW1iZXJfb2ZfYWdlbnRzEgIYAUrRAgoLY3Jld19hZ2VudHMSwQIK + vgJbeyJrZXkiOiAiYWQxNTMxNjFjNWM1YTg1NmFhMGQwNmIyNDljNGM2NGEiLCAiaWQiOiAiNTU2 + NzJiMDgtOTU4ZC00MjljLWE3ZTctY2ZlN2U4Y2MwOGZkIiwgInJvbGUiOiAiYmFzZV9hZ2VudCIs + ICJ2ZXJib3NlPyI6IGZhbHNlLCAibWF4X2l0ZXIiOiAyMCwgIm1heF9ycG0iOiBudWxsLCAiZnVu + Y3Rpb25fY2FsbGluZ19sbG0iOiAiIiwgImxsbSI6ICJncHQtNG8tbWluaSIsICJkZWxlZ2F0aW9u + X2VuYWJsZWQ/IjogZmFsc2UsICJhbGxvd19jb2RlX2V4ZWN1dGlvbj8iOiBmYWxzZSwgIm1heF9y + ZXRyeV9saW1pdCI6IDIsICJ0b29sc19uYW1lcyI6IFtdfV1K/wEKCmNyZXdfdGFza3MS8AEK7QFb + eyJrZXkiOiAiMWIxNWVmMjM5MTViMjc1NWU4OWEwZWMzYjI2YTEzZDIiLCAiaWQiOiAiMzlmMDlm + MWUtOTJmOC00ZGJiLTgzNDAtNjU2ZmVkMDk3ZjM0IiwgImFzeW5jX2V4ZWN1dGlvbj8iOiBmYWxz + ZSwgImh1bWFuX2lucHV0PyI6IGZhbHNlLCAiYWdlbnRfcm9sZSI6ICJiYXNlX2FnZW50IiwgImFn + ZW50X2tleSI6ICJhZDE1MzE2MWM1YzVhODU2YWEwZDA2YjI0OWM0YzY0YSIsICJ0b29sc19uYW1l + cyI6IFtdfV16AhgBhQEAAQAAEo4CChB8AxWkb2Uwpdc8RpyCRqw5EggJAxbgNu81XyoMVGFzayBD + cmVhdGVkMAE5+HQ8Wu7wIhhB+PE8Wu7wIhhKLgoIY3Jld19rZXkSIgogZTU4MDcwMWQ1MmViNjVh + ZmYyNGVlZmU3OGM3NDYyOGNKMQoHY3Jld19pZBImCiRjOTg4MWRjZi0yYzQxLTRmNGUtODMyNy02 + MmNiMWFiMmQ5ODhKLgoIdGFza19rZXkSIgogMWIxNWVmMjM5MTViMjc1NWU4OWEwZWMzYjI2YTEz + ZDJKMQoHdGFza19pZBImCiQzOWYwOWYxZS05MmY4LTRkYmItODM0MC02NTZmZWQwOTdmMzR6AhgB + hQEAAQAAEqQHChCcXvdbsgYC+gzCMrXs3LN/EgijKwJLCRIiHioMQ3JldyBDcmVhdGVkMAE5iJqz + vu7wIhhBqKC/vu7wIhhKGwoOY3Jld2FpX3ZlcnNpb24SCQoHMC4xMDAuMEoaCg5weXRob25fdmVy + c2lvbhIICgYzLjEyLjhKLgoIY3Jld19rZXkSIgogZTU4MDcwMWQ1MmViNjVhZmYyNGVlZmU3OGM3 + NDYyOGNKMQoHY3Jld19pZBImCiQ2Zjk1ZWI3Yy0wOWM5LTQxOTYtYWFiYi1kOWIxNmMxMzZjODdK + HAoMY3Jld19wcm9jZXNzEgwKCnNlcXVlbnRpYWxKEQoLY3Jld19tZW1vcnkSAhAAShoKFGNyZXdf + bnVtYmVyX29mX3Rhc2tzEgIYAUobChVjcmV3X251bWJlcl9vZl9hZ2VudHMSAhgBStECCgtjcmV3 + X2FnZW50cxLBAgq+Alt7ImtleSI6ICJhZDE1MzE2MWM1YzVhODU2YWEwZDA2YjI0OWM0YzY0YSIs + ICJpZCI6ICI1NTY3MmIwOC05NThkLTQyOWMtYTdlNy1jZmU3ZThjYzA4ZmQiLCAicm9sZSI6ICJi + YXNlX2FnZW50IiwgInZlcmJvc2U/IjogZmFsc2UsICJtYXhfaXRlciI6IDIwLCAibWF4X3JwbSI6 + IG51bGwsICJmdW5jdGlvbl9jYWxsaW5nX2xsbSI6ICIiLCAibGxtIjogImdwdC00by1taW5pIiwg + ImRlbGVnYXRpb25fZW5hYmxlZD8iOiBmYWxzZSwgImFsbG93X2NvZGVfZXhlY3V0aW9uPyI6IGZh + bHNlLCAibWF4X3JldHJ5X2xpbWl0IjogMiwgInRvb2xzX25hbWVzIjogW119XUr/AQoKY3Jld190 + YXNrcxLwAQrtAVt7ImtleSI6ICIxYjE1ZWYyMzkxNWIyNzU1ZTg5YTBlYzNiMjZhMTNkMiIsICJp + ZCI6ICIzOWYwOWYxZS05MmY4LTRkYmItODM0MC02NTZmZWQwOTdmMzQiLCAiYXN5bmNfZXhlY3V0 + aW9uPyI6IGZhbHNlLCAiaHVtYW5faW5wdXQ/IjogZmFsc2UsICJhZ2VudF9yb2xlIjogImJhc2Vf + YWdlbnQiLCAiYWdlbnRfa2V5IjogImFkMTUzMTYxYzVjNWE4NTZhYTBkMDZiMjQ5YzRjNjRhIiwg + InRvb2xzX25hbWVzIjogW119XXoCGAGFAQABAAASjgIKEExDo5nPLyHb2H8DfYjPoX4SCLEYs+24 + 8EenKgxUYXNrIENyZWF0ZWQwATmI4NG+7vAiGEFYZdK+7vAiGEouCghjcmV3X2tleRIiCiBlNTgw + NzAxZDUyZWI2NWFmZjI0ZWVmZTc4Yzc0NjI4Y0oxCgdjcmV3X2lkEiYKJDZmOTVlYjdjLTA5Yzkt + NDE5Ni1hYWJiLWQ5YjE2YzEzNmM4N0ouCgh0YXNrX2tleRIiCiAxYjE1ZWYyMzkxNWIyNzU1ZTg5 + YTBlYzNiMjZhMTNkMkoxCgd0YXNrX2lkEiYKJDM5ZjA5ZjFlLTkyZjgtNGRiYi04MzQwLTY1NmZl + ZDA5N2YzNHoCGAGFAQABAAASpAcKEBBQzR2bcR/7woQ+VkaJ4kQSCD1LFx3SNPPPKgxDcmV3IENy + ZWF0ZWQwATlotsW/7vAiGEEgA9C/7vAiGEobCg5jcmV3YWlfdmVyc2lvbhIJCgcwLjEwMC4wShoK + DnB5dGhvbl92ZXJzaW9uEggKBjMuMTIuOEouCghjcmV3X2tleRIiCiBlNTgwNzAxZDUyZWI2NWFm + ZjI0ZWVmZTc4Yzc0NjI4Y0oxCgdjcmV3X2lkEiYKJDJiMWI2MGYzLTNlZTMtNGNjYi05MDM2LTdk + MzE4OTJiYjVkZkocCgxjcmV3X3Byb2Nlc3MSDAoKc2VxdWVudGlhbEoRCgtjcmV3X21lbW9yeRIC + EABKGgoUY3Jld19udW1iZXJfb2ZfdGFza3MSAhgBShsKFWNyZXdfbnVtYmVyX29mX2FnZW50cxIC + GAFK0QIKC2NyZXdfYWdlbnRzEsECCr4CW3sia2V5IjogImFkMTUzMTYxYzVjNWE4NTZhYTBkMDZi + MjQ5YzRjNjRhIiwgImlkIjogIjU1NjcyYjA4LTk1OGQtNDI5Yy1hN2U3LWNmZTdlOGNjMDhmZCIs + ICJyb2xlIjogImJhc2VfYWdlbnQiLCAidmVyYm9zZT8iOiBmYWxzZSwgIm1heF9pdGVyIjogMjAs + ICJtYXhfcnBtIjogbnVsbCwgImZ1bmN0aW9uX2NhbGxpbmdfbGxtIjogIiIsICJsbG0iOiAiZ3B0 + LTRvLW1pbmkiLCAiZGVsZWdhdGlvbl9lbmFibGVkPyI6IGZhbHNlLCAiYWxsb3dfY29kZV9leGVj + dXRpb24/IjogZmFsc2UsICJtYXhfcmV0cnlfbGltaXQiOiAyLCAidG9vbHNfbmFtZXMiOiBbXX1d + Sv8BCgpjcmV3X3Rhc2tzEvABCu0BW3sia2V5IjogIjFiMTVlZjIzOTE1YjI3NTVlODlhMGVjM2Iy + NmExM2QyIiwgImlkIjogIjM5ZjA5ZjFlLTkyZjgtNGRiYi04MzQwLTY1NmZlZDA5N2YzNCIsICJh + c3luY19leGVjdXRpb24/IjogZmFsc2UsICJodW1hbl9pbnB1dD8iOiBmYWxzZSwgImFnZW50X3Jv + bGUiOiAiYmFzZV9hZ2VudCIsICJhZ2VudF9rZXkiOiAiYWQxNTMxNjFjNWM1YTg1NmFhMGQwNmIy + NDljNGM2NGEiLCAidG9vbHNfbmFtZXMiOiBbXX1degIYAYUBAAEAABKOAgoQmT07KMiFRgzOOPQf + I4bJPhIIqzN+pCYM6IUqDFRhc2sgQ3JlYXRlZDABOYjr3r/u8CIYQehY37/u8CIYSi4KCGNyZXdf + a2V5EiIKIGU1ODA3MDFkNTJlYjY1YWZmMjRlZWZlNzhjNzQ2MjhjSjEKB2NyZXdfaWQSJgokMmIx + YjYwZjMtM2VlMy00Y2NiLTkwMzYtN2QzMTg5MmJiNWRmSi4KCHRhc2tfa2V5EiIKIDFiMTVlZjIz + OTE1YjI3NTVlODlhMGVjM2IyNmExM2QySjEKB3Rhc2tfaWQSJgokMzlmMDlmMWUtOTJmOC00ZGJi + LTgzNDAtNjU2ZmVkMDk3ZjM0egIYAYUBAAEAABKkBwoQE53vZNAWshkoNK1bqTvovRII83djkBUL + EbcqDENyZXcgQ3JlYXRlZDABORBBzsDu8CIYQbAU2MDu8CIYShsKDmNyZXdhaV92ZXJzaW9uEgkK + BzAuMTAwLjBKGgoOcHl0aG9uX3ZlcnNpb24SCAoGMy4xMi44Si4KCGNyZXdfa2V5EiIKIGU1ODA3 + MDFkNTJlYjY1YWZmMjRlZWZlNzhjNzQ2MjhjSjEKB2NyZXdfaWQSJgokNTQ0MWY0MWYtOTVjMC00 + YzdkLTkxM2QtNDUxODcwY2YyZjYzShwKDGNyZXdfcHJvY2VzcxIMCgpzZXF1ZW50aWFsShEKC2Ny + ZXdfbWVtb3J5EgIQAEoaChRjcmV3X251bWJlcl9vZl90YXNrcxICGAFKGwoVY3Jld19udW1iZXJf + b2ZfYWdlbnRzEgIYAUrRAgoLY3Jld19hZ2VudHMSwQIKvgJbeyJrZXkiOiAiYWQxNTMxNjFjNWM1 + YTg1NmFhMGQwNmIyNDljNGM2NGEiLCAiaWQiOiAiNTU2NzJiMDgtOTU4ZC00MjljLWE3ZTctY2Zl + N2U4Y2MwOGZkIiwgInJvbGUiOiAiYmFzZV9hZ2VudCIsICJ2ZXJib3NlPyI6IGZhbHNlLCAibWF4 + X2l0ZXIiOiAyMCwgIm1heF9ycG0iOiBudWxsLCAiZnVuY3Rpb25fY2FsbGluZ19sbG0iOiAiIiwg + ImxsbSI6ICJncHQtNG8tbWluaSIsICJkZWxlZ2F0aW9uX2VuYWJsZWQ/IjogZmFsc2UsICJhbGxv + d19jb2RlX2V4ZWN1dGlvbj8iOiBmYWxzZSwgIm1heF9yZXRyeV9saW1pdCI6IDIsICJ0b29sc19u + YW1lcyI6IFtdfV1K/wEKCmNyZXdfdGFza3MS8AEK7QFbeyJrZXkiOiAiMWIxNWVmMjM5MTViMjc1 + NWU4OWEwZWMzYjI2YTEzZDIiLCAiaWQiOiAiMzlmMDlmMWUtOTJmOC00ZGJiLTgzNDAtNjU2ZmVk + MDk3ZjM0IiwgImFzeW5jX2V4ZWN1dGlvbj8iOiBmYWxzZSwgImh1bWFuX2lucHV0PyI6IGZhbHNl + LCAiYWdlbnRfcm9sZSI6ICJiYXNlX2FnZW50IiwgImFnZW50X2tleSI6ICJhZDE1MzE2MWM1YzVh + ODU2YWEwZDA2YjI0OWM0YzY0YSIsICJ0b29sc19uYW1lcyI6IFtdfV16AhgBhQEAAQAAEo4CChBV + JNEz3VIdOlQM9VT3bctVEgisogN707a2AioMVGFzayBDcmVhdGVkMAE5kGbnwO7wIhhBaMDnwO7w + IhhKLgoIY3Jld19rZXkSIgogZTU4MDcwMWQ1MmViNjVhZmYyNGVlZmU3OGM3NDYyOGNKMQoHY3Jl + d19pZBImCiQ1NDQxZjQxZi05NWMwLTRjN2QtOTEzZC00NTE4NzBjZjJmNjNKLgoIdGFza19rZXkS + IgogMWIxNWVmMjM5MTViMjc1NWU4OWEwZWMzYjI2YTEzZDJKMQoHdGFza19pZBImCiQzOWYwOWYx + ZS05MmY4LTRkYmItODM0MC02NTZmZWQwOTdmMzR6AhgBhQEAAQAAErQHChDA7zaLCfy56rd5t3oS + rDPZEgjYoSW3mq6WJyoMQ3JldyBDcmVhdGVkMAE5cP/5we7wIhhBIH0Dwu7wIhhKGwoOY3Jld2Fp + X3ZlcnNpb24SCQoHMC4xMDAuMEoaCg5weXRob25fdmVyc2lvbhIICgYzLjEyLjhKLgoIY3Jld19r + ZXkSIgogZTU4MDcwMWQ1MmViNjVhZmYyNGVlZmU3OGM3NDYyOGNKMQoHY3Jld19pZBImCiRmNjcz + MTc1ZS04Y2Q1LTQ1ZWUtYTZiOS0xYWFjMTliODQxZWJKHAoMY3Jld19wcm9jZXNzEgwKCnNlcXVl + bnRpYWxKEQoLY3Jld19tZW1vcnkSAhAAShoKFGNyZXdfbnVtYmVyX29mX3Rhc2tzEgIYAUobChVj + cmV3X251bWJlcl9vZl9hZ2VudHMSAhgBStkCCgtjcmV3X2FnZW50cxLJAgrGAlt7ImtleSI6ICJh + ZDE1MzE2MWM1YzVhODU2YWEwZDA2YjI0OWM0YzY0YSIsICJpZCI6ICJmMGUwMGIzZi0wZWNmLTQ2 + OGQtYjdjMC0yZmJhN2I5OTc5YjMiLCAicm9sZSI6ICJiYXNlX2FnZW50IiwgInZlcmJvc2U/Ijog + ZmFsc2UsICJtYXhfaXRlciI6IDIwLCAibWF4X3JwbSI6IG51bGwsICJmdW5jdGlvbl9jYWxsaW5n + X2xsbSI6ICIiLCAibGxtIjogImdwdC00by1taW5pIiwgImRlbGVnYXRpb25fZW5hYmxlZD8iOiBm + YWxzZSwgImFsbG93X2NvZGVfZXhlY3V0aW9uPyI6IGZhbHNlLCAibWF4X3JldHJ5X2xpbWl0Ijog + MiwgInRvb2xzX25hbWVzIjogWyJzYXlfaGkiXX1dSocCCgpjcmV3X3Rhc2tzEvgBCvUBW3sia2V5 + IjogIjFiMTVlZjIzOTE1YjI3NTVlODlhMGVjM2IyNmExM2QyIiwgImlkIjogImFhMGFmMmE2LTdm + MTktNDZmNi1iMjMxLTg1M2JjYzYxYzhiZiIsICJhc3luY19leGVjdXRpb24/IjogZmFsc2UsICJo + dW1hbl9pbnB1dD8iOiBmYWxzZSwgImFnZW50X3JvbGUiOiAiYmFzZV9hZ2VudCIsICJhZ2VudF9r + ZXkiOiAiYWQxNTMxNjFjNWM1YTg1NmFhMGQwNmIyNDljNGM2NGEiLCAidG9vbHNfbmFtZXMiOiBb + InNheV9oaSJdfV16AhgBhQEAAQAAEo4CChBH8NUZY1Cv8sM2lfQLaEogEgiFlW7Wp7QpdyoMVGFz + ayBDcmVhdGVkMAE5MNkPwu7wIhhBUCcQwu7wIhhKLgoIY3Jld19rZXkSIgogZTU4MDcwMWQ1MmVi + NjVhZmYyNGVlZmU3OGM3NDYyOGNKMQoHY3Jld19pZBImCiRmNjczMTc1ZS04Y2Q1LTQ1ZWUtYTZi + OS0xYWFjMTliODQxZWJKLgoIdGFza19rZXkSIgogMWIxNWVmMjM5MTViMjc1NWU4OWEwZWMzYjI2 + YTEzZDJKMQoHdGFza19pZBImCiRhYTBhZjJhNi03ZjE5LTQ2ZjYtYjIzMS04NTNiY2M2MWM4YmZ6 + AhgBhQEAAQAAEooBChCJg/wSACw+HIDy4vvYISP/EgjoC/oI/1V0cCoKVG9vbCBVc2FnZTABOWA0 + ifTu8CIYQTD0lPTu8CIYShsKDmNyZXdhaV92ZXJzaW9uEgkKBzAuMTAwLjBKFQoJdG9vbF9uYW1l + EggKBnNheV9oaUoOCghhdHRlbXB0cxICGAF6AhgBhQEAAQAA + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '6534' + 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: + - Mon, 10 Feb 2025 19:55:17 GMT + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Assess the quality of the task + completed based on the description, expected output, and actual results.\n\nTask + Description:\nJust say hi\n\nExpected Output:\nhi\n\nActual Output:\nhi\n```\n\nPlease + provide:\n- Bullet points suggestions to improve future similar tasks\n- A score + from 0 to 10 evaluating on completion, quality, and overall performance- Entities + extracted from the task output, if any, their type, description, and relationships"}], + "model": "gpt-4o-mini", "tool_choice": {"type": "function", "function": {"name": + "TaskEvaluation"}}, "tools": [{"type": "function", "function": {"name": "TaskEvaluation", + "description": "Correctly extracted `TaskEvaluation` with all the required parameters + with correct types", "parameters": {"$defs": {"Entity": {"properties": {"name": + {"description": "The name of the entity.", "title": "Name", "type": "string"}, + "type": {"description": "The type of the entity.", "title": "Type", "type": + "string"}, "description": {"description": "Description of the entity.", "title": + "Description", "type": "string"}, "relationships": {"description": "Relationships + of the entity.", "items": {"type": "string"}, "title": "Relationships", "type": + "array"}}, "required": ["name", "type", "description", "relationships"], "title": + "Entity", "type": "object"}}, "properties": {"suggestions": {"description": + "Suggestions to improve future similar tasks.", "items": {"type": "string"}, + "title": "Suggestions", "type": "array"}, "quality": {"description": "A score + from 0 to 10 evaluating on completion, quality, and overall performance, all + taking into account the task description, expected output, and the result of + the task.", "title": "Quality", "type": "number"}, "entities": {"description": + "Entities extracted from the task output.", "items": {"$ref": "#/$defs/Entity"}, + "title": "Entities", "type": "array"}}, "required": ["entities", "quality", + "suggestions"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1967' + content-type: + - application/json + cookie: + - _cfuvid=efIHP1NUsh1dFewGJBu4YoBu6hhGa8vjOOKQglYQGno-1739214901306-0.0.1.1-604800000; + __cf_bm=fmlg1wjOwuOwZhUUOEtL1tQYluAPumn7AHLF8s0EU2Y-1739217315-1.0.1.1-PQDvxn8TOhzaznlHjwVsqPZUzbAyJWFkvzCubfNJydTu2_AyA1cJ8hkM0khsEE4UY_xp8iPe2gSGmH1ydrDa0Q + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.61.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.61.0 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.12.8 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-AzUA8oE0A2d99i1Khpu0CI7fSgRtZ\",\n \"object\": + \"chat.completion\",\n \"created\": 1739217316,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n + \ \"id\": \"call_bk3duHRErK1qCyvWJ1uVmmGl\",\n \"type\": + \"function\",\n \"function\": {\n \"name\": \"TaskEvaluation\",\n + \ \"arguments\": \"{\\\"suggestions\\\":[\\\"Provide more context + or details for similar tasks to enhance clarity.\\\",\\\"Specify desired tone + or style for the output.\\\",\\\"Consider adding more variety in tasks to keep + engagement high.\\\"],\\\"quality\\\":10,\\\"entities\\\":[{\\\"name\\\":\\\"hi\\\",\\\"type\\\":\\\"greeting\\\",\\\"description\\\":\\\"A + casual way to say hello or acknowledge someone's presence.\\\",\\\"relationships\\\":[\\\"used + as a greeting\\\",\\\"expresses friendliness\\\"]}]}\"\n }\n }\n + \ ],\n \"refusal\": null\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 275,\n \"completion_tokens\": 80,\n \"total_tokens\": 355,\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 \"service_tier\": + \"default\",\n \"system_fingerprint\": \"fp_72ed7ab54c\"\n}\n" + headers: + CF-RAY: + - 90fea7dfef41ceb9-SJC + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 10 Feb 2025 19:55:17 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '1535' + 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: + - '149999874' + x-ratelimit-reset-requests: + - 2ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_55d8eb91b4318245556b73d3f4c1e7c4 + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/utilities/test_events.py b/tests/utilities/test_events.py new file mode 100644 index 000000000..68bda7bec --- /dev/null +++ b/tests/utilities/test_events.py @@ -0,0 +1,497 @@ +import json +from datetime import datetime +from unittest.mock import MagicMock, patch + +import pytest +from pydantic import Field + +from crewai.agent import Agent +from crewai.agents.crew_agent_executor import CrewAgentExecutor +from crewai.crew import Crew +from crewai.flow.flow import Flow, listen, start +from crewai.task import Task +from crewai.tools.base_tool import BaseTool +from crewai.tools.tool_usage import ToolUsage +from crewai.utilities.events.agent_events import ( + AgentExecutionCompletedEvent, + AgentExecutionErrorEvent, + AgentExecutionStartedEvent, +) +from crewai.utilities.events.crew_events import ( + CrewKickoffCompletedEvent, + CrewKickoffFailedEvent, + CrewKickoffStartedEvent, +) +from crewai.utilities.events.crewai_event_bus import crewai_event_bus +from crewai.utilities.events.event_types import ToolUsageFinishedEvent +from crewai.utilities.events.flow_events import ( + FlowCreatedEvent, + FlowFinishedEvent, + FlowStartedEvent, + MethodExecutionFailedEvent, + MethodExecutionStartedEvent, +) +from crewai.utilities.events.task_events import ( + TaskCompletedEvent, + TaskFailedEvent, + TaskStartedEvent, +) +from crewai.utilities.events.tool_usage_events import ( + ToolUsageErrorEvent, +) + +base_agent = Agent( + role="base_agent", + llm="gpt-4o-mini", + goal="Just say hi", + backstory="You are a helpful assistant that just says hi", +) + +base_task = Task( + description="Just say hi", + expected_output="hi", + agent=base_agent, +) + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_crew_emits_start_kickoff_event(): + received_events = [] + + with crewai_event_bus.scoped_handlers(): + + @crewai_event_bus.on(CrewKickoffStartedEvent) + def handle_crew_start(source, event): + received_events.append(event) + + crew = Crew(agents=[base_agent], tasks=[base_task], name="TestCrew") + + crew.kickoff() + + assert len(received_events) == 1 + assert received_events[0].crew_name == "TestCrew" + assert isinstance(received_events[0].timestamp, datetime) + assert received_events[0].type == "crew_kickoff_started" + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_crew_emits_end_kickoff_event(): + received_events = [] + + @crewai_event_bus.on(CrewKickoffCompletedEvent) + def handle_crew_end(source, event): + received_events.append(event) + + crew = Crew(agents=[base_agent], tasks=[base_task], name="TestCrew") + + crew.kickoff() + + assert len(received_events) == 1 + assert received_events[0].crew_name == "TestCrew" + assert isinstance(received_events[0].timestamp, datetime) + assert received_events[0].type == "crew_kickoff_completed" + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_crew_emits_kickoff_failed_event(): + received_events = [] + + with crewai_event_bus.scoped_handlers(): + + @crewai_event_bus.on(CrewKickoffFailedEvent) + def handle_crew_failed(source, event): + received_events.append(event) + + crew = Crew(agents=[base_agent], tasks=[base_task], name="TestCrew") + + with patch.object(Crew, "_execute_tasks") as mock_execute: + error_message = "Simulated crew kickoff failure" + mock_execute.side_effect = Exception(error_message) + + with pytest.raises(Exception): + crew.kickoff() + + assert len(received_events) == 1 + assert received_events[0].error == error_message + assert isinstance(received_events[0].timestamp, datetime) + assert received_events[0].type == "crew_kickoff_failed" + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_crew_emits_start_task_event(): + received_events = [] + + @crewai_event_bus.on(TaskStartedEvent) + def handle_task_start(source, event): + received_events.append(event) + + crew = Crew(agents=[base_agent], tasks=[base_task], name="TestCrew") + + crew.kickoff() + + assert len(received_events) == 1 + assert isinstance(received_events[0].timestamp, datetime) + assert received_events[0].type == "task_started" + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_crew_emits_end_task_event(): + received_events = [] + + @crewai_event_bus.on(TaskCompletedEvent) + def handle_task_end(source, event): + received_events.append(event) + + crew = Crew(agents=[base_agent], tasks=[base_task], name="TestCrew") + + crew.kickoff() + + assert len(received_events) == 1 + assert isinstance(received_events[0].timestamp, datetime) + assert received_events[0].type == "task_completed" + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_task_emits_failed_event_on_execution_error(): + received_events = [] + received_sources = [] + + @crewai_event_bus.on(TaskFailedEvent) + def handle_task_failed(source, event): + received_events.append(event) + received_sources.append(source) + + with patch.object( + Task, + "_execute_core", + ) as mock_execute: + error_message = "Simulated task failure" + mock_execute.side_effect = Exception(error_message) + agent = Agent( + role="base_agent", + goal="Just say hi", + backstory="You are a helpful assistant that just says hi", + ) + task = Task( + description="Just say hi", + expected_output="hi", + agent=agent, + ) + + with pytest.raises(Exception): + agent.execute_task(task=task) + + assert len(received_events) == 1 + assert received_sources[0] == task + assert received_events[0].error == error_message + assert isinstance(received_events[0].timestamp, datetime) + assert received_events[0].type == "task_failed" + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_agent_emits_execution_started_and_completed_events(): + received_events = [] + + @crewai_event_bus.on(AgentExecutionStartedEvent) + def handle_agent_start(source, event): + received_events.append(event) + + @crewai_event_bus.on(AgentExecutionCompletedEvent) + def handle_agent_completed(source, event): + received_events.append(event) + + crew = Crew(agents=[base_agent], tasks=[base_task], name="TestCrew") + crew.kickoff() + assert len(received_events) == 2 + assert received_events[0].agent == base_agent + assert received_events[0].task == base_task + assert received_events[0].tools == [] + assert isinstance(received_events[0].task_prompt, str) + assert ( + received_events[0].task_prompt + == "Just say hi\n\nThis is the expected criteria for your final answer: hi\nyou MUST return the actual complete content as the final answer, not a summary." + ) + assert isinstance(received_events[0].timestamp, datetime) + assert received_events[0].type == "agent_execution_started" + assert isinstance(received_events[1].timestamp, datetime) + assert received_events[1].type == "agent_execution_completed" + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_agent_emits_execution_error_event(): + received_events = [] + + @crewai_event_bus.on(AgentExecutionErrorEvent) + def handle_agent_start(source, event): + received_events.append(event) + + error_message = "Error happening while sending prompt to model." + base_agent.max_retry_limit = 0 + with patch.object( + CrewAgentExecutor, "invoke", wraps=base_agent.agent_executor.invoke + ) as invoke_mock: + invoke_mock.side_effect = Exception(error_message) + + with pytest.raises(Exception) as e: + base_agent.execute_task( + task=base_task, + ) + + assert len(received_events) == 1 + assert received_events[0].agent == base_agent + assert received_events[0].task == base_task + assert received_events[0].error == error_message + assert isinstance(received_events[0].timestamp, datetime) + assert received_events[0].type == "agent_execution_error" + + +class SayHiTool(BaseTool): + name: str = Field(default="say_hi", description="The name of the tool") + description: str = Field( + default="Say hi", description="The description of the tool" + ) + + def _run(self) -> str: + return "hi" + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_tools_emits_finished_events(): + received_events = [] + + @crewai_event_bus.on(ToolUsageFinishedEvent) + def handle_tool_end(source, event): + received_events.append(event) + + agent = Agent( + role="base_agent", + goal="Just say hi", + backstory="You are a helpful assistant that just says hi", + tools=[SayHiTool()], + ) + + task = Task( + description="Just say hi", + expected_output="hi", + agent=agent, + ) + crew = Crew(agents=[agent], tasks=[task], name="TestCrew") + crew.kickoff() + assert len(received_events) == 1 + assert received_events[0].agent_key == agent.key + assert received_events[0].agent_role == agent.role + assert received_events[0].tool_name == SayHiTool().name + assert received_events[0].tool_args == {} + assert received_events[0].type == "tool_usage_finished" + assert isinstance(received_events[0].timestamp, datetime) + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_tools_emits_error_events(): + received_events = [] + + @crewai_event_bus.on(ToolUsageErrorEvent) + def handle_tool_end(source, event): + received_events.append(event) + + class ErrorTool(BaseTool): + name: str = Field( + default="error_tool", description="A tool that raises an error" + ) + description: str = Field( + default="This tool always raises an error", + description="The description of the tool", + ) + + def _run(self) -> str: + raise Exception("Simulated tool error") + + agent = Agent( + role="base_agent", + goal="Try to use the error tool", + backstory="You are an assistant that tests error handling", + tools=[ErrorTool()], + ) + + task = Task( + description="Use the error tool", + expected_output="This should error", + agent=agent, + ) + + crew = Crew(agents=[agent], tasks=[task], name="TestCrew") + crew.kickoff() + + assert len(received_events) == 75 + assert received_events[0].agent_key == agent.key + assert received_events[0].agent_role == agent.role + assert received_events[0].tool_name == "error_tool" + assert received_events[0].tool_args == {} + assert str(received_events[0].error) == "Simulated tool error" + assert received_events[0].type == "tool_usage_error" + assert isinstance(received_events[0].timestamp, datetime) + + +def test_flow_emits_start_event(): + received_events = [] + + with crewai_event_bus.scoped_handlers(): + + @crewai_event_bus.on(FlowStartedEvent) + def handle_flow_start(source, event): + received_events.append(event) + + class TestFlow(Flow[dict]): + @start() + def begin(self): + return "started" + + flow = TestFlow() + flow.kickoff() + + assert len(received_events) == 1 + assert received_events[0].flow_name == "TestFlow" + assert received_events[0].type == "flow_started" + + +def test_flow_emits_finish_event(): + received_events = [] + + with crewai_event_bus.scoped_handlers(): + + @crewai_event_bus.on(FlowFinishedEvent) + def handle_flow_finish(source, event): + received_events.append(event) + + class TestFlow(Flow[dict]): + @start() + def begin(self): + return "completed" + + flow = TestFlow() + result = flow.kickoff() + + assert len(received_events) == 1 + assert received_events[0].flow_name == "TestFlow" + assert received_events[0].type == "flow_finished" + assert received_events[0].result == "completed" + assert result == "completed" + + +def test_flow_emits_method_execution_started_event(): + received_events = [] + + with crewai_event_bus.scoped_handlers(): + + @crewai_event_bus.on(MethodExecutionStartedEvent) + def handle_method_start(source, event): + print("event in method name", event.method_name) + received_events.append(event) + + class TestFlow(Flow[dict]): + @start() + def begin(self): + return "started" + + @listen("begin") + def second_method(self): + return "executed" + + flow = TestFlow() + flow.kickoff() + + assert len(received_events) == 2 + + assert received_events[0].method_name == "begin" + assert received_events[0].flow_name == "TestFlow" + assert received_events[0].type == "method_execution_started" + + assert received_events[1].method_name == "second_method" + assert received_events[1].flow_name == "TestFlow" + assert received_events[1].type == "method_execution_started" + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_register_handler_adds_new_handler(): + received_events = [] + + def custom_handler(source, event): + received_events.append(event) + + with crewai_event_bus.scoped_handlers(): + crewai_event_bus.register_handler(CrewKickoffStartedEvent, custom_handler) + + crew = Crew(agents=[base_agent], tasks=[base_task], name="TestCrew") + crew.kickoff() + + assert len(received_events) == 1 + assert isinstance(received_events[0].timestamp, datetime) + assert received_events[0].type == "crew_kickoff_started" + + +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_multiple_handlers_for_same_event(): + received_events_1 = [] + received_events_2 = [] + + def handler_1(source, event): + received_events_1.append(event) + + def handler_2(source, event): + received_events_2.append(event) + + with crewai_event_bus.scoped_handlers(): + crewai_event_bus.register_handler(CrewKickoffStartedEvent, handler_1) + crewai_event_bus.register_handler(CrewKickoffStartedEvent, handler_2) + + crew = Crew(agents=[base_agent], tasks=[base_task], name="TestCrew") + crew.kickoff() + + assert len(received_events_1) == 1 + assert len(received_events_2) == 1 + assert received_events_1[0].type == "crew_kickoff_started" + assert received_events_2[0].type == "crew_kickoff_started" + + +def test_flow_emits_created_event(): + received_events = [] + + @crewai_event_bus.on(FlowCreatedEvent) + def handle_flow_created(source, event): + received_events.append(event) + + class TestFlow(Flow[dict]): + @start() + def begin(self): + return "started" + + flow = TestFlow() + flow.kickoff() + + assert len(received_events) == 1 + assert received_events[0].flow_name == "TestFlow" + assert received_events[0].type == "flow_created" + + +def test_flow_emits_method_execution_failed_event(): + received_events = [] + error = Exception("Simulated method failure") + + @crewai_event_bus.on(MethodExecutionFailedEvent) + def handle_method_failed(source, event): + received_events.append(event) + + class TestFlow(Flow[dict]): + @start() + def begin(self): + raise error + + flow = TestFlow() + with pytest.raises(Exception): + flow.kickoff() + + assert len(received_events) == 1 + assert received_events[0].method_name == "begin" + assert received_events[0].flow_name == "TestFlow" + assert received_events[0].type == "method_execution_failed" + assert received_events[0].error == error