Ask an agent questions from the terminal (preview)

[This article is prerelease documentation and is subject to change.]

Use the msagent test ask command to ask a published Copilot Studio agent questions from the terminal and check its live behavior. This optional task sends a question to an agent in the public cloud:

msagent test ask --project 'C:\AgentProjects\VisitorGuide' `
  --agent-name 'Visitor Guide' --deployment-name develop `
  --query 'What should I bring for my first visit?' --plain

Prerequisites

  • An installed CLI and authorization to use this preview.
  • A published public-cloud Copilot Studio agent and the exact intended deployment.
  • A work account with environment access and agent invocation access.

Note

Queries can execute tools and workflows, consume credits, and change real data. Cancellation doesn't undo actions and remote work can continue. Check remote effects before retrying a failed or interrupted query.

Sign in and ask your agent a question

  1. Sign in with authentication login and check your authentication status:

    msagent auth login --account 'tester@contoso.com' --tenant '<tenant-id>' --cloud prod
    msagent auth status
    
  2. Use test ask, explicitly selecting the registered agent and deployment:

    msagent test ask --project 'C:\AgentProjects\VisitorGuide' `
      --agent-name 'Visitor Guide' --deployment-name develop `
      --query 'Where should a visitor check in?' --plain
    

    If you have no local project, the fully explicit test ask route is:

    msagent test ask --schema-name '<published-agent-schema>' `
      --environment-id '<target-environment-id>' --tenant '<tenant-id>' `
      --deployment-name '<approved-target-label>' --query 'Hello' --plain
    

Ask a follow-up question or start a new conversation

To ask a follow-up question, copy the conversation ID returned by your previous query and include it with --conversation-id. Use the same agent and deployment:

msagent test ask --project 'C:\AgentProjects\VisitorGuide' `
  --agent-name 'Visitor Guide' --deployment-name develop `
  --conversation-id '<returned-conversation-id>' `
  --query 'What should I bring?' --plain

To start a new conversation, leave out --conversation-id. The CLI starts a separate conversation each time unless you provide an ID.

Choose the output format that suits your workflow:

  • Use --plain to display just the final response.
  • Use --json for structured output that you can capture in a script. It includes activities and the final status.

Use only one of these output options at a time. Neither option changes sign-in requirements. If you use --non-interactive, the command stops if it needs you to sign in interactively.

Use the CLI in a script

Add --non-interactive to run a query without interactive sign-in prompts. Sign in first using msagent auth login. If the query needs further sign-in interaction, it stops so you can sign in again.

Use --json to capture structured output:

msagent test ask --project 'C:\AgentProjects\VisitorGuide' `
  --agent-name 'Visitor Guide' --deployment-name develop `
  --query 'Where should a visitor check in?' `
  --non-interactive --json

This uses your existing signed-in session; it doesn't set up service-principal authentication or unattended sign-in.