Passing files to an Agent Flow: Error ‘Input parameters are invalid for your model’

If you created a Copilot agent and enabled File upload (in the Copilot agent settings), there’s a reason: you expect your users to provide documents in the chat window. Therefore, you’re more than likely going to send files from your Copilot agent to an Agent flow to do complex things!

In the case of using an AI Prompt, you may experience the error “Input parameters are invalid for your model“. Let’s dive in to see what’s going on?!

Agent flow input

When your Agent flow needs to perform different actions from a document uploaded by the user in the chat window, you’ll create an input of type File.

Create the Agent flow including an AI Prompt action

Although your Agent flow will still be a tool per say, the maker experience will be different if not configured in a Topic. Here, we want to provide instructions to the Copilot agent to use the flow according to our scenario.

  1. When an agent calls the flow (trigger)
  2. Run a prompt (your prompt with an input file) –> UserFilePDF input = File content contentBytes (from the dynamic content)

After creating your awesome Agent flow, make sure it’s added to the Copilot agent, give your agent some instructions, and let’s do a test.

Uh-Oh 😥 In Copilot Studio we’ve got an Internal Error… But if we look at the Agent flow run, we’ll see:

  • Invalid input: Input parameters are invalid for your model
  • Unable to identify the mimetype input

This happens when the information expected by the Agent flow are not fully received. The flow run will show the contentBytes is missing:

And you might also notice that this is not the name of my document… My file is SampleDoc.pdf, not sample-document.pdf.

If you add a Compose action just after the trigger, and use the File content contentBytes as an input (like it’s in the Run a prompt action), then run your flow, you’ll see that the result of the Compose action is EMPTY! 🤨

Let’s fix this

Open your Copilot agent and navigate to the Tools tab.

My Agent flow doesn’t have any other inputs than the file one (first screenshot above), so the Inputs section in Copilot Studio is empty.

Click on the + Add input button, and look at what shows up! This is the information the Agent flow needs.

If we click on contentBytes, we can now configure the input. From the Fill using dropdown, select Custom value. Then enter the Value:

First(System.Activity.Attachments).Content

Repeat for the name input with:

First(System.Activity.Attachments).Name

Make sure to Save your tool, and possibly do a hard refresh (Ctrl + F5 on Win / Command + Shift + R on Mac).

Testing it ✅

And now it does look a lot better! 😉

⚠️ Note: It is possible that sometimes you “think” that it does work without specifying the contentBytes & name, and “surprisingly” sometimes it doesn’t (even asking you “Please provide the file details including the file name and content bytes.“). This might be due to caching/syncing issues. Try a hard refresh, or removing/re-adding the Agent flow.

Thanks for reading! 🙂

Leave a Reply

Discover more from Veronique's Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading