Skip to content

Fix A2A streaming chunk parsing and context_id persistence in OpenStudio MCP Demo UI#64

Closed
Copilot wants to merge 1 commit intoopenstudio_mcpfrom
copilot/sub-pr-63
Closed

Fix A2A streaming chunk parsing and context_id persistence in OpenStudio MCP Demo UI#64
Copilot wants to merge 1 commit intoopenstudio_mcpfrom
copilot/sub-pr-63

Conversation

Copy link

Copilot AI commented Mar 2, 2026

The OpenStudio MCP demo UI was only checking chunk.get("content") on streaming responses, missing the actual A2A JSON-RPC envelope structure and never persisting context_id, causing empty responses and broken multi-turn conversations.

Changes

  • Chunk parsing — replaced naive content field access with full A2A JSON-RPC result parsing, branching on result.kind:
    • artifact-update → extracts text from artifact.parts
    • status-update → extracts text from status.message.parts
  • context_id persistence — captures result.contextId on each chunk and stores it in st.session_state["context_id"] for follow-up turns
  • Fallbacks — retains handling for delta.text, message.text, content, and data chunk shapes for robustness
if isinstance(chunk, dict) and "result" in chunk:
    result = chunk.get("result", {})
    context_id = result.get("contextId")
    if context_id:
        st.session_state["context_id"] = context_id

    kind = result.get("kind")
    if kind == "artifact-update":
        parts = result.get("artifact", {}).get("parts", [])
        ...
    elif kind == "status-update":
        parts = result.get("status", {}).get("message", {}).get("parts", [])
        ...

Mirrors the pattern already established in examples/eplus_mcp_demo/ui.py.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI mentioned this pull request Mar 2, 2026
Copilot AI changed the title [WIP] Update MCP demo implementation based on review feedback Fix A2A streaming chunk parsing and context_id persistence in OpenStudio MCP Demo UI Mar 2, 2026
@weilixu weilixu closed this Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants