Skip to content

MSTeams: streaming reply drops during long tool chains (30s+) #59731

@cwatts-sage

Description

@cwatts-sage

Summary

Streaming 1:1 replies (added in PR #51808) work great for short conversational exchanges, but the final reply is dropped when an agent performs a long tool chain (3+ sequential tool calls spanning 30+ seconds).

Environment

  • OpenClaw v2026.4.1
  • Microsoft Teams plugin (bundled)
  • Single-tenant bot registration
  • DM (1:1) conversation

Steps to Reproduce

  1. User sends a message that triggers multiple sequential tool calls
  2. Agent begins streaming reply — initial text appears in Teams
  3. Agent executes 4 sequential exec tool calls with 10-20 second delays each (~60 seconds total)
  4. Agent completes tool chain and writes final reply text

Expected Behavior

  • Streaming card should continue updating during tool execution (e.g., showing status updates)
  • Final reply text should appear in Teams after all tool calls complete

Actual Behavior

  • Streaming card shows initial pre-tool text correctly
  • Card freezes during tool execution — no updates visible
  • Final reply after tool chain (~60 seconds later) is silently dropped
  • User only sees the partial initial text

Analysis

The Bot Framework TurnContext proxy still expires after ~30 seconds even with streaming enabled. Short replies work because the streaming card finishes before the proxy timeout. Long tool chains exceed this window.

Possible approaches:

  1. Heartbeat updates during tool execution — Send periodic updateActivity calls to the streaming card during tool calls to keep the TurnContext alive (e.g., "Running command 2/4...")
  2. Proactive fallback — Detect when a turn exceeds a threshold and automatically switch to proactive message delivery (using stored conversation references) for the final reply
  3. Tool-aware streaming — Emit streaming card updates at tool boundaries (tool start/complete events) to maintain the connection

Workaround

We currently use a hybrid approach:

  • Turn-context (streaming) for simple replies with no tools or quick tools (< 15 seconds)
  • Proactive message tool sends for replies after long tool chains (30+ seconds)

This works but requires agent-side awareness of delivery rules, which is fragile and adds complexity to the system prompt.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions