test_case_id: web_request_content_type_json
description: "Test that web_request tool correctly handles application/json content type."
tags: ["all", "agent", "tools", "web_tools"]
skip_intermediate_events: true

gateway_input:
  target_agent_name: "TestAgent"
  user_identity: "test_user@example.com"
  gateway_request_id: "request-130"
  external_context:
    a2a_session_id: "session-463"
  prompt:
    parts:
      - text: "Please fetch the JSON data from {{STATIC_FILE_SERVER_URL}}/sample.json"

llm_interactions:
  - static_response:
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_130"
                type: "function"
                function:
                  name: "web_request"
                  arguments: '{"url": "{{STATIC_FILE_SERVER_URL}}/sample.json"}'
    expected_request:
      messages:
        - role: "user"
          content: "Please fetch the JSON data from {{STATIC_FILE_SERVER_URL}}/sample.json"
      tools_present:
        - "web_request"
  - static_response:
      choices:
        - message:
            role: "assistant"
            content: "I have successfully fetched the content."
    expected_request:
      messages:
        - role: "user"
          content: "Please fetch the JSON data from {{STATIC_FILE_SERVER_URL}}/sample.json"
        - role: "tool"
          content_matches_regex: '.*"status": "success", "message": "Successfully fetched content from {{STATIC_FILE_SERVER_URL}}/sample.json \(status: 200\). Saved as artifact.*'
          tool_call_id: "call_130"

expected_gateway_output:
  - type: final_response
    kind: task
    id: '*'
    contextId: "session-463"
    status:
      state: "completed"
      message:
        kind: message
        messageId: '*'
        role: agent
        parts:
          - type: text
            text_contains:

              - "I have successfully fetched the content."
expected_artifacts:
  - filename_matches_regex: "^web_content_.*\\.json(?<!\\.metadata\\.json)$"
    metadata_contains:
      original_content_type: "application/json"
      processed_content_type: "application/json"
  - filename_matches_regex: "^web_content_.*\\.json\\.metadata\\.json$"
    mime_type: "application/json"
