Our branch commit 506a1e8e9 removed the unused 'import json' from
copilotkit/langgraph.py. Main PR #3784 subsequently added a dict-resume
path in copilotkit_interrupt that calls json.dumps(response) and re-added
the import.
The 3-way merge had no textual conflict (the lines around the import
didn't change on both sides), so git silently took our "delete" over
main's "unchanged." Result: json.dumps() called with json undefined.
Verified: sdk-python test suite now 74/74 passing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
## Summary
- `copilotkit_interrupt` now handles string and dict resume values from
LangGraph 1.x's `interrupt()`
- Previously crashed with `AttributeError: 'str' object has no attribute
'content'` or `KeyError: -1`
- Type-checks response: str returned directly, dict JSON-serialized,
list uses existing `[-1].content` path
## Test plan
- [x] Red-green test: string resume value returns without crash
- [x] Red-green test: dict resume value returns JSON string
- [x] Test: list resume value still works (existing behavior)
- [x] Full test suite passes (15/15)
Closes#3096
- Keep deletion of sdk-python/copilotkit/langgraph_agent.py (deprecated LangGraphAgent
removed in this PR; main's unrelated bug fixes are superseded by our removal)
- Resolve poetry.lock conflict by taking main's ag_ui_langgraph 0.0.33
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Apply the same parentMessageId orphan fix to crewai_flow_messages_to_copilotkit
where the elif chain meant tool-call messages never emitted the parent assistant
message. Also refine langgraph fix: use explicit None check instead of truthiness,
add inline comments explaining the invariant, remove unused pytest import,
replace fragile commit hash in docstring, and add test for list-type content.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reverts the `if content:` guard from c5ec0f8512 that skipped emitting
the assistant message when content was empty. OpenAI models commonly
send empty content for tool-call-only responses, but the assistant
message is structurally required as the anchor for tool call grouping
via parentMessageId. Without it, tool calls become orphaned and the
frontend can't reconstruct tool call rendering on thread reconnect.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When Anthropic models return multi-part content lists, only the first
element was used and the rest discarded. Now iterates all parts and
concatenates text blocks, preserving the full message content.
LangGraph 1.x can return string or dict resume values from interrupt(),
not just lists. The code now type-checks the response: strings are
returned directly, dicts are JSON-serialized, and lists use the
existing [-1].content path.
No longer needed now that LangGraphAgent is gone — the only caller was
the deprecated agent class. Also removed from langchain.py re-exports.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Ran confirmed LangGraphAGUIAgent is the only relevant path going forward.
Removes LangGraphAgent, _StreamingStateExtractor, CopilotKitConfig, and
langgraph_default_merge_state from sdk-python (the AG-UI base class
provides this now). Also removes the use_function_call=True code path
from copilotkit_messages_to_langchain (no callers, function_call format
is obsolete).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Python SDK: 18 new tests for LangGraphAGUIAgent (custom event handling,
emit filtering, state merging, copilotkit namespace)
- TypeScript SDK: 25 new tests for copilotkitCustomizeConfig and
convertActionsToDynamicStructuredTools
- TypeScript Runtime: 27 new tests for event-source helpers
(shouldEmitToolCall, getCurrentMessageId, getCurrentContent, etc.)
- TypeScript Runtime: expanded dispatch-event-filtering tests with
custom event dispatch (manually_emit_message/tool_call/state, exit)
and langGraphDefaultMergeState tests
- Dead code annotations: LangGraphAgent class and use_function_call=True
branch annotated with TODO(ran-review) for Ran to verify
https://claude.ai/code/session_01BPMn7zhadhapfyyD8kYeAH
Avoid emitting spurious empty assistant messages for tool-call-only
AIMessages (common with OpenAI models where content is empty string).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
langchain_messages_to_copilotkit previously skipped creating the assistant
message when an AIMessage had tool_calls, causing missing context in chat
history on reconnect. Also adds ActionExecutionMessage type guard in
copilotkit_messages_to_langchain to prevent KeyError on non-tool messages
with parentMessageId.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>