fix: align agent-builder with longer pack timeouts
All checks were successful
build / build (push) Successful in 27s
All checks were successful
build / build (push) Successful in 27s
This commit is contained in:
14
agent.py
14
agent.py
@@ -17,8 +17,10 @@ because it needs three things forwarded from the caller:
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import re
|
||||
from contextlib import suppress
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
@@ -65,6 +67,7 @@ class AgentBuilder(A2AAgent[BuilderConfig, NoAuth]):
|
||||
"should do. Returns the live URL when ready."
|
||||
),
|
||||
tags=["builder", "scaffold", "deepagents", "meta"],
|
||||
stream=True,
|
||||
)
|
||||
async def build(
|
||||
self,
|
||||
@@ -127,6 +130,13 @@ class AgentBuilder(A2AAgent[BuilderConfig, NoAuth]):
|
||||
final_state: dict[str, Any] = {}
|
||||
deployed_url: str | None = None
|
||||
last_reply: str = ""
|
||||
|
||||
async def _heartbeat() -> None:
|
||||
while True:
|
||||
await asyncio.sleep(20)
|
||||
await ctx.emit_progress(f"agent-builder still working on {name!r}")
|
||||
|
||||
heartbeat_task = asyncio.create_task(_heartbeat())
|
||||
try:
|
||||
async for event in graph.astream_events(
|
||||
{"messages": [{"role": "user", "content": user_msg}]},
|
||||
@@ -156,6 +166,10 @@ class AgentBuilder(A2AAgent[BuilderConfig, NoAuth]):
|
||||
final_state = out
|
||||
except Exception as exc: # noqa: BLE001
|
||||
return {"error": f"build graph failed: {type(exc).__name__}: {exc}"}
|
||||
finally:
|
||||
heartbeat_task.cancel()
|
||||
with suppress(asyncio.CancelledError):
|
||||
await heartbeat_task
|
||||
|
||||
for msg in final_state.get("messages") or []:
|
||||
content = msg.get("content") if isinstance(msg, dict) else getattr(msg, "content", None)
|
||||
|
||||
Reference in New Issue
Block a user