Skip to content

Commit 1710d56

Browse files
committed
fix (tasks): resolving plan generation (WIP)
1 parent 3e67ea5 commit 1710d56

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

.github/workflows/deploy-dev.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ jobs:
3434
cd src/server
3535
3636
# Stop and remove the old containers.
37-
docker-compose down
37+
docker compose down
3838
3939
# Build new images if the Dockerfile has changed, and start the new containers in the background.
40-
docker-compose up --build -d
40+
docker compose up --build -d
4141
4242
# Optional: This cleans up any old, unused Docker images to save disk space.
4343
docker image prune -af

src/server/main/agents/routes.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from workers.planner.db import get_all_mcp_descriptions
1313
from workers.tasks import calculate_next_run
1414
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
15+
from json_extractor import JsonExtractor
1516

1617
router = APIRouter(
1718
prefix="/agents",
@@ -258,24 +259,19 @@ async def generate_plan(
258259
user_prompt = f"Please create a plan for the following goal: {request.prompt}"
259260
messages = [{'role': 'user', 'content': user_prompt}]
260261

261-
final_response_str = ""
262262
for chunk in agent.run(messages=messages):
263263
if isinstance(chunk, list) and chunk:
264264
last_message = chunk[-1]
265265
if last_message.get("role") == "assistant" and isinstance(last_message.get("content"), str):
266266
content = last_message["content"]
267267

268-
269-
# Extract JSON from markdown code block if present
270-
match = re.search(r'```json\n(.*?)\n```', content, re.DOTALL)
271-
final_response_str = match.group(1) if match else content
272-
268+
plan_data = JsonExtractor.extract_valid_json(content)
269+
273270
print(f"[INFO] Received chunk from planner agent: {content}")
274-
print(f"[INFO] Final response from planner agent: {final_response_str}")
275-
if not final_response_str:
271+
print(f"[INFO] Final response from planner agent: {plan_data}")
272+
if not plan_data:
276273
raise HTTPException(status_code=500, detail="Planner agent returned an empty response.")
277274

278-
plan_data = json.loads(final_response_str)
279275
return {"description": plan_data.get("description"), "plan": plan_data.get("plan", [])}
280276
except Exception as e:
281277
import traceback

src/server/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ notion-client
4040
fastmcp
4141

4242
# --- Charting (for gslides MCP) ---
43-
matplotlib
43+
matplotlib
44+
45+
jsonextractor

0 commit comments

Comments
 (0)