# tests/integration/scenarios_declarative/test_data/image_tools/describe_image/test_describe_image_empty_artifact.yaml
test_case_id: "describe_image_empty_artifact"
description: "Tests how the tool handles an artifact that is empty (0 bytes) and gets a malformed API response."
tags: ["all","agent","tools","image_tools"]
skip_intermediate_events: true

setup_artifacts:
  - filename: "empty_image.png"
    mime_type: "image/png"
    content_base64: "" # Empty content

gateway_input:
  user_prompt: "Describe the empty_image.png file."
  user_identity: "test_user@example.com"
  target_agent_name: "TestAgent"
  tool_names: ["describe_image"]

llm_interactions:
  # First LLM call: Agent decides to use the tool
  - static_response:
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_describe_image_empty_1"
                type: "function"
                function:
                  name: "describe_image"
                  arguments: '{"image_filename": "empty_image.png"}'
    expected_request:
      tools_present: ["describe_image"]

  # Second LLM call (to vision API): Primed to return a malformed response
  - static_response:
      id: "chatcmpl-empty-error"
      object: "chat.completion"
      model: "gpt-4-vision-preview"
      choices: [] # No choices, which will trigger the tool's error handling

  # Third LLM call: Agent processes the tool's error
  - static_response:
      choices:
        - message:
            role: "assistant"
            content: "I tried to describe the image, but the API response was invalid."
    expected_request:
      expected_tool_responses_in_llm_messages:
        - tool_call_id_matches_prior_request_index: 0
          response_json_matches:
            status: "error"
            message: "API response does not contain valid choices."

expected_gateway_output:
  - type: "final_response"
    task_state: "completed"
    content_parts:
      - type: "text"
        text_contains: "API response was invalid"
