test_case_id: edit_image_gemini_api_error
description: "Tests the tool's behavior when the Gemini API returns an error."
tags: ["all", "agent", "tools", "image_tools"]
skip_intermediate_events: true

setup_artifacts:
  - filename: "image_for_api_error.jpg"
    content_base64: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
    mime_type: "image/jpeg"

gateway_input:
  user_identity: "test_user@example.com"
  target_agent_name: "TestAgent"
  prompt: "Edit image_for_api_error.jpg"
  tool_names: ["edit_image_with_gemini"]
  external_context:
    a2a_session_id: "session_edit_image_gemini_api_error"

llm_interactions:
  - static_response:
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_gae1"
                type: "function"
                function:
                  name: "edit_image_with_gemini"
                  arguments: '{"image_filename": "image_for_api_error.jpg", "edit_prompt": "this will fail"}'
  - expected_request:
      messages:
        - role: "tool"
          content_contains: "Gemini API call failed"
          tool_call_id: "call_gae1"
    static_response:
      choices:
        - message:
            role: "assistant"
            content: "I encountered an error with the image editing service. Please try again later."

expected_gateway_output:
  - type: "final_response"
    kind: task
    id: '*'
    contextId: "session_edit_image_gemini_api_error"
    status:
      state: "completed"
      message:
        kind: message
        messageId: '*'
        role: agent
        parts:
          - type: "text"
            text_contains:
              - "I encountered an error with the image editing service. Please try again later."
