web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Copilot Studio Agent –...
Copilot Studio
Suggested Answer

Copilot Studio Agent – ContextTokenLimitExceeded, Flow Timeout, Large Data Handling issue

(1) ShareShare
ReportReport
Posted on by 38

I am working on a Copilot Studio agent published to Microsoft Teams. The agent uses knowledge sources and invokes a Power Automate flow after user confirmation.

 

I am facing a few challenges and would appreciate any guidance.

 

1. ContextTokenLimitExceeded

 

The agent was working fine earlier, but after adding more instructions, business rules, and knowledge sources, it occasionally throws a ContextTokenLimitExceeded error, even for simple user questions.

 

Interestingly, the same agent works correctly when accessed from Copilot, but the issue occurs when using it from Microsoft Teams.

 

Has anyone experienced this issue? Are there any best practices for managing instructions, knowledge sources, or context size to avoid this error?

 

2. Flow Timeout Despite Successful Execution

 

The agent invokes a Power Automate flow that performs backend processing and returns the result to the user.

 

In some scenarios, the processing takes around 2–5 minutes. The flow itself completes successfully and generates the expected result, but the agent throws a timeout/runtime exception before the response is returned to the user.

 

From the run history, I can see that:

 

- Processing completed successfully.

- The result was generated successfully.

- The failure occurs while returning the response back to the agent.

 

My questions are:

 

- Is there a response waiting limit between Copilot Studio agents and Power Automate flows?

- What is the recommended approach for handling long-running operations that may take several minutes to complete?

 

3. Handling Large Data Returned from Flow

 

Another challenge is handling large volumes of data returned from a flow.

 

For example, if a flow retrieves a large SharePoint list or data source containing 2,000+ rows, the agent seems unable to process or consume the entire dataset effectively.

 

My questions are:

 

- Are there any documented limits on how much data can be returned from a flow back to a Copilot Studio agent?

- What is the recommended pattern for handling large datasets?

- Should the data be stored elsewhere and retrieved in smaller chunks?

- How are others handling scenarios where thousands of records need to be processed or summarized by the agent?

 

Any recommendations, architecture patterns, limitations, lessons learned, or best practices would be greatly appreciated.

  • Suggested answer
    Valantis Profile Picture
    7,545 Super User 2026 Season 2 on at
     
    On ContextTokenLimitExceeded in Teams but not Copilot, this is documented.
    MS docs describe exactly this scenario, response behavior differs between a fresh conversation and a longer running one, specifically naming Teams as the example, since Teams keeps prior messages in context while a fresh test panel or Copilot session starts clean.https://learn.microsoft.com/en-us/microsoft-copilot-studio/advanced-generative-actions
     
    Also confirmed, the standard harness doesn't enforce a token limit across the multiple model calls inside one turn, planning, knowledge retrieval, tool summarization, so total usage per turn can exceed a single model call's context window with no warning until it actually breaks.https://learn.microsoft.com/en-us/microsoft-copilot-studio/prompt-model-settings
     
    100 second synchronous limit between an agent and a flow's Respond to Copilot action. For your 2 to 5 minute process, the documented pattern is respond immediately with an acknowledgment, let the flow keep running after that point, up to 30 days, then use Execute Agent with the saved Conversation ID to call the agent back with the final result once processing finishes.https://learn.microsoft.com/en-my/microsoft-copilot-studio/advanced-flow
     
    On large data from a flow, hard limit, 64 KB per individual action or connector response. 2,000+ SharePoint rows will exceed that.
    Documented pattern is pagination or summarization inside the flow before returning to the agent, don't return the raw dataset, filter or summarize it first, or store it and have the agent request specific slices.https://learn.microsoft.com/en-us/microsoft-copilot-studio/agent-flow-express-mode
     
     
      Best regards,

    Valantis  
    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/ 💼 LinkedIn   ▶️ YouTube
  • Suggested answer
    11manish Profile Picture
    4,802 Super User 2026 Season 2 on at
    The recommended boundary should be:
     
    Copilot Studio = understand, orchestrate, and communicate.

    Power Automate/API/Dataverse/backend = retrieve, validate, process, calculate, and transform.
     
    For your specific three problems:
    • ContextTokenLimitExceeded → reduce agent context and move deterministic business logic outside the agent.
    • 2–5 minute flow → use asynchronous agent-flow response, especially since Teams supports the callback model.
    • 2,000+ SharePoint records → never send the entire dataset to the agent; filter, aggregate, process or paginate externally and return only what the conversation needs.
    This will give you a much more stable, scalable and production-ready Copilot Studio architecture, rather than simply making the current implementation work around its limits.
  • Suggested answer
    M Bilal Khan Profile Picture
    376 on at

    Hi @N962908,

    I would treat these as three separate problems rather than one overall “large data” issue.

    1. ContextTokenLimitExceeded in Teams

    The fact that the agent works from Copilot Studio/Copilot but fails in Teams is important. There has also been a recent Microsoft Q&A report of ContextTokenLimitExceeded getting stuck in a Teams conversation while the same agent continued to work in the Copilot Studio test pane.

    I would first test with a new Teams conversation/session, rather than assuming the agent itself is broken.

    From the agent side, I would also reduce unnecessary context:

    • Keep global instructions concise and move detailed business logic into topics/tools where possible.
    • Avoid adding large documents or overlapping knowledge sources just because they are available.
    • Give knowledge sources clear descriptions so the orchestration layer can select the relevant source.
    • Test the same prompt with some knowledge sources temporarily disabled to identify whether one source is contributing excessive context.
    • Compare a fresh Teams session with the Copilot Studio test pane.

    Microsoft's current orchestration guidance specifically recommends keeping instructions, inputs/outputs, tools and knowledge sources well designed rather than putting all logic into one large instruction set.

    So I wouldn't immediately conclude that “more knowledge sources = token limit.” The Teams-specific reproduction is worth isolating separately.

    2. The 2–5 minute flow timeout is expected for a synchronous response

    This part has a much clearer answer.

    For an agent flow/tool using Respond to the agent, Microsoft currently documents a 100-second action limit for the response. The flow itself can continue running much longer, but the agent should not wait synchronously for a 2–5 minute operation to finish.

    That explains the behavior you're seeing:

    Flow completes successfully → result is generated → agent has already timed out waiting for the response.

    For a long-running operation, the better pattern is asynchronous response.

    In the Respond to the agent action, open Settings → Asynchronous response and enable it. Microsoft documents that asynchronous agent flows can continue beyond the normal two-minute limit and return a callback response when the flow finishes. This is explicitly supported in Microsoft Teams, which is particularly relevant to this scenario.

    Architecturally, I would use:

    User
      ↓
    Copilot Studio agent
      ↓
    Start flow
      ↓
    Immediate acknowledgement
      "I've started processing this. I'll return the result when it's ready."
      ↓
    Power Automate continues processing
      ↓
    Callback / asynchronous response
      ↓
    Agent → Teams
      ↓
    Final result
    

    If the result genuinely takes several minutes, I would not try to make the agent synchronously wait for it.

    3. Don't return 2,000+ SharePoint rows to the agent

    This is probably the biggest architectural issue.

    The agent doesn't need the entire dataset in its context just because the flow can retrieve it.

    Instead of:

    SharePoint
       ↓
    Get 2,000 rows
       ↓
    Return all rows to Copilot
       ↓
    LLM processes everything
    

    I would use:

    User question
       ↓
    Determine required filters/criteria
       ↓
    SharePoint query
       ↓
    Filter / Select / Top
       ↓
    Return only relevant records
       ↓
    Agent summarizes
    

    For example, if the user asks:

    "Which projects are over budget?"

    don't return all 2,000 projects. Have the flow calculate/filter the relevant records and return something like:

    {
      "count": 17,
      "projects": [
        {
          "project": "PC0001",
          "status": "Over Budget",
          "variance": 12500000
        }
      ]
    }
    

    There is also a documented 500 KB response limit for Copilot Studio connector responses. Microsoft specifically recommends filtering connector responses when the returned payload exceeds that limit.

    So the important limit isn't simply “2,000 rows.” It depends heavily on the number of columns and the size of each record.

    For large-data scenarios, I would consider:

    • $filter to reduce rows
    • $select to reduce columns
    • $top/pagination where appropriate
    • aggregation in the flow instead of returning raw records
    • returning a summary plus only the records relevant to the question
    • storing the full result externally and returning a reference/result ID when appropriate

    Interestingly, Microsoft now also has SharePoint list knowledge support designed for analytical reasoning over lists, including preview support up to 120,000 rows, although quality/latency can degrade at large scale. That can be a better fit for some read/analysis scenarios than pulling thousands of rows through a Power Automate response.

    One other point: I wouldn't automatically enable Express mode for a data-heavy flow. Microsoft's guidance specifically says Express mode is intended for logic-heavy flows and is not recommended when the flow moves large amounts of data, such as thousands of rows/large tables.

    So my general pattern would be:

    Small/fast operation

    Agent → Flow → Filter/query → Small response → Agent
    

    Long-running operation

    Agent → Async Flow → Immediate acknowledgement
                        ↓
                  Background processing
                        ↓
                   Callback/result
    

    Large dataset

    Agent
     ↓
    Interpret question
     ↓
    Filtered/aggregated query
     ↓
    Small structured response
     ↓
    Agent generates final answer
    

    The main thing I would avoid is using the flow as a mechanism to dump an entire SharePoint list into the agent's context. Let the data source do the filtering/aggregation first, and let Copilot Studio reason over the smallest useful result.

  • Suggested answer
    Mohsin Ali Profile Picture
    1,075 on at
    Hello @N962908 - I would treat them as three identical issues, please refer below details to further diagnose the issue. 
    • For ContextTokenLimitExceeded, test with a fresh Teams conversation and review the agent instructions and knowledge sources. Since it works elsewhere, this can help isolate whether Teams conversation context is contributing to the issue.

    • For the 2–5 minute Power Automate flow, avoid a synchronous response pattern. The agent can time out even if the flow eventually completes, so use an asynchronous design for long-running processing.

    • For 2,000+ SharePoint rows, avoid returning the full dataset to Copilot Studio. Filter, select only required columns, or summarize the data in Power Automate before returning the response.

    These changes should help isolate the token issue while also addressing the timeout and large payload problems.

     


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Copilot Studio

#1
Mohsin Ali Profile Picture

Mohsin Ali 360

#2
Valantis Profile Picture

Valantis 253 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 184 Super User 2026 Season 2

Last 30 days Overall leaderboard