Skip to content

Commit 481bc6e

Browse files
added message compaction to remove info about tools, etc. after generating plan and config
1 parent 0e6d109 commit 481bc6e

2 files changed

Lines changed: 248 additions & 109 deletions

File tree

backend/routers/create.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,15 @@ async def event_stream():
168168
yield _sse_event("session", {"session_id": session.session_id})
169169

170170
agent_iter = agent.chat(session, user_message).__aiter__()
171+
next_coro = None
171172
while True:
173+
if next_coro is None:
174+
next_coro = asyncio.ensure_future(agent_iter.__anext__())
172175
try:
173176
event = await asyncio.wait_for(
174-
agent_iter.__anext__(), timeout=_KEEPALIVE_INTERVAL
177+
asyncio.shield(next_coro), timeout=_KEEPALIVE_INTERVAL
175178
)
179+
next_coro = None
176180
yield _sse_event(event["event"], event["data"])
177181
except asyncio.TimeoutError:
178182
yield ": keepalive\n\n"

0 commit comments

Comments
 (0)