Skip to content

Commit 75cb5ce

Browse files
authored
fix(python-sdk): fix intermediate state not emitting until next async fn (CopilotKit#1063)
1 parent 1728e79 commit 75cb5ce

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

sdk-python/copilotkit/langchain.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import uuid
66
import json
77
from typing import List, Optional, Any, Union, Dict, Callable
8+
import asyncio
89

910
from langchain_core.messages import (
1011
HumanMessage,
@@ -114,6 +115,7 @@ async def copilotkit_exit(config: RunnableConfig):
114115
{},
115116
config=config,
116117
)
118+
await asyncio.sleep(0.01)
117119

118120
return True
119121

@@ -127,6 +129,7 @@ async def copilotkit_emit_state(config: RunnableConfig, state: Any):
127129
state,
128130
config=config,
129131
)
132+
await asyncio.sleep(0.01)
130133

131134
return True
132135

@@ -143,6 +146,7 @@ async def copilotkit_emit_message(config: RunnableConfig, message: str):
143146
},
144147
config=config,
145148
)
149+
await asyncio.sleep(0.01)
146150

147151
return True
148152

@@ -161,5 +165,6 @@ async def copilotkit_emit_tool_call(config: RunnableConfig, *, name: str, args:
161165
},
162166
config=config,
163167
)
168+
await asyncio.sleep(0.01)
164169

165170
return True

0 commit comments

Comments
 (0)