test_case_id: convert_malformed_pdf_as_success
description: "Tests that the tool successfully converts a malformed PDF file."
tags: ["all","agent","tools","general_agent_tools"]
skip_intermediate_events: true

setup_artifacts:
  - filename: "corrupted.pdf"
    content_base64: "JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UeXBlIC9QYWdlcy9LaWRzIFsyIDAgUiBdL0NvdW50IDE+PgplbmRvYmoKMiAwIG9iago8PC9UeXBlIC9QYWdlL1BhcmVudCAxIDAgUiAvUmVzb3VyY2VzPDwvRm9udDw8L0YxIDQgMCBSID4+Pj4vTWVkaWFCb3ggWzAgMCA2MTIgNzkyXS9Db250ZW50cyAzIDAgUiA+PgplbmRvYmoKMyAwIG9iago8PC9MZW5ndGggNTc+PgpzdHJlYW0KQkIKL0YxIDEyIFRmCjEgMCBUZCAoVGhpcyBpcyBhIHRlc3QgUERGLiApIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKNCAtMCBvYmoKPDwvVHlwZSAvRm9udC9TdWJ0eXBlIC9UeXBlMS9CYXNlRm9udCAvSGVsdmV0aWNhPj4KZW5kb2JqCnhyZWYKMCA1CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAxNSAwMDAwMCBuIAowMDAwMDAwMDYyIDAwMDAwIG4gCjAwMDAwMDAxNzAgMDAwMDAgbiAKMDAwMDAwMDI1MyAwMDAwMCBuIAp0cmFpbGVyCjw8L1Jvb3QgMSAwIFIgL1NpemUgNT4+CnN0YXJ0eHJlZgozMDkKJSVFT0YKCg==CORRUPTEDDATA" # A simple base64 encoded PDF with extra data
    mime_type: "application/pdf"

gateway_input:
  user_prompt: "Please convert the file corrupted.pdf to markdown."
  target_agent_name: "TestAgent"
  user_identity: "test_user@example.com"
  external_context:
    a2a_session_id: "session_convert_corrupted_pdf"

llm_interactions:
  - static_response:
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_convert_corrupted"
                type: "function"
                function:
                  name: "convert_file_to_markdown"
                  arguments: '{"input_filename": "corrupted.pdf"}'
    expected_request:
      tools_present:
        - "convert_file_to_markdown"

  - static_response:
      choices:
        - message:
            role: "assistant"
            content: "I have converted the file `corrupted.pdf` to `corrupted.pdf.md`."
    expected_request:
      expected_tool_responses_in_llm_messages:
        - tool_call_id_matches_prior_request_index: 0
          response_json_matches:
            status: "success"

expected_gateway_output:
  - type: final_response
    task_state: "completed"
    content_parts:
      - type: text
        text_contains: "I have converted the file `corrupted.pdf` to `corrupted.pdf.md`."

expected_artifacts:
  - filename: "corrupted_converted.md"
    mime_type: "text/markdown"
    content_contains: "T\nh\ni\ns\n\ni\ns\n\na\n\nt\ne\ns\nt\n\nP\nD\nF\n.\n\n"
