AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

RemoteGraph Returns Invoke Output As List Of Dict Instead Of List Of BaseMessage - Mandatory When Combined With CompiledSubAgent

RemoteGraph's invoke/ainvoke returns message dictionaries instead of BaseMessage instances, causing CompiledSubAgent to produce empty ToolMessage content when used as a subagent. This breaks the parent agent's ability to read subagent results.

highConfidence 95%LangChain/LangGraphAffected Vlanggraph==1.2.11Affected Vlangchain==1.4.0Affected Vdeepagents==0.7.13

Origin Analysis

RemoteGraph serializes state over HTTP and deserializes messages as plain dictionaries without converting them back to LangChain BaseMessage objects, while CompiledSubAgent expects BaseMessage instances to extract the last non-empty AIMessage text.
Use RemoteGraph as a runnable for CompiledSubAgent in deepagents; invoke the supervisor agent; observe that the ToolMessage corresponding to the subagent task is empty because the returned state contains dict messages instead of BaseMessage objects.

Fixing Code Block

Edge Case Audit

This hotfix mutates the output state by converting dicts to BaseMessage objects, which may break if downstream code expects the original dict format (e.g., when serializing for logging or passing to other tools). Ensure all consumers of RemoteGraph output can handle BaseMessage objects. Additionally, the conversion relies on the 'type' or 'role' key; if message dicts use a different schema, conversion may fail or produce unexpected message types. Apply this patch only if you control the RemoteGraph usage; consider upstream fix in langgraph to avoid monkey patching. Test with multi-threaded or async scenarios to ensure thread safety.

Ecosystem Topology