Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion backend/app/usecase/session_usecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ async def _run_session_analysis(
iter_repo, UUID(iteration_id), IterationStatus.IMPLEMENTING
)
for proposal in proposals:
prop = result["proposals"][proposal.proposal_index]
rich_plan_json = json.dumps(
{
"title": prop.get("title", ""),
"concept": prop.get("concept", ""),
"plan": prop.get("plan", []),
"files": prop.get("files", []),
},
ensure_ascii=False,
)
asyncio.create_task(
_run_session_implementation(
session_id=session_id,
Expand All @@ -357,7 +367,7 @@ async def _run_session_analysis(
branch=branch,
proposal_index=proposal.proposal_index,
proposal_id=str(proposal.id),
plan_json=str(proposal.plan),
plan_json=rich_plan_json,
selected_proposal_index=selected_proposal_index,
device_type=device_type,
instruction=instruction,
Expand Down
15 changes: 7 additions & 8 deletions backend/app/workflow/session_implementation_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ async def create_k8s_job(state: SessionImplementationState) -> dict:

# Write proposal plan to S3 for the worker to read (includes device_type)
plan_key = s3.plan_key(state["session_id"], state["iteration_index"], state["proposal_index"])
plan_with_device = _json.dumps(
{
"plan": state["proposal_plan"],
"device_type": state.get("device_type", "desktop"),
"instruction": state.get("instruction", ""),
},
ensure_ascii=False,
)
raw_plan = state["proposal_plan"]
plan_obj = _json.loads(raw_plan) if isinstance(raw_plan, str) else raw_plan
if not isinstance(plan_obj, dict):
plan_obj = {"plan": plan_obj}
plan_obj["device_type"] = state.get("device_type", "desktop")
plan_obj["instruction"] = state.get("instruction", "")
plan_with_device = _json.dumps(plan_obj, ensure_ascii=False)
Comment on lines +21 to +27

Copilot AI Mar 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_k8s_job now unconditionally json.loads() a string proposal_plan. If proposal_plan is ever a non-JSON string (e.g., legacy plain-text plans / already-formatted prompts), this will raise JSONDecodeError and fail the whole job creation path. To keep backward compatibility and avoid hard failures, wrap the loads in try/except JSONDecodeError and fall back to treating raw_plan as the plan value (e.g., {"plan": raw_plan}).

Copilot uses AI. Check for mistakes.
s3.upload_text(plan_key, plan_with_device)

job_name = k8s.create_session_implementation_job(
Expand Down
701 changes: 701 additions & 0 deletions docker/prompts.py

Large diffs are not rendered by default.

Loading