fix(platform/copilot): address PR review comments

- Extract reason from decomposition_result in vague_goal path instead of hardcoding
- Change goal_type field to Literal["vague", "unachievable"] for stronger typing
- Add reason prop to SuggestedGoalCard and display it
- Pass reason to SuggestedGoalCard in CreateAgent
- Add enum constraint to goal_type in openapi.json schema
This commit is contained in:
Zamil Majdy
2026-02-18 21:17:25 +05:30
parent ba13606e3d
commit 826ab6ad2a
5 changed files with 11 additions and 4 deletions

View File

@@ -200,10 +200,13 @@ class CreateAgentTool(BaseTool):
if decomposition_result.get("type") == "vague_goal":
suggested = decomposition_result.get("suggested_goal", "")
reason = decomposition_result.get(
"reason", "The goal needs more specific details"
)
return SuggestedGoalResponse(
message="The goal is too vague to create a specific workflow.",
suggested_goal=suggested,
reason="The goal needs more specific details",
reason=reason,
original_goal=description,
goal_type="vague",
session_id=session_id,

View File

@@ -2,7 +2,7 @@
from datetime import datetime
from enum import Enum
from typing import Any
from typing import Any, Literal
from pydantic import BaseModel, Field
@@ -309,7 +309,7 @@ class SuggestedGoalResponse(ToolResponseBase):
original_goal: str = Field(
default="", description="The user's original goal for context"
)
goal_type: str = Field(
goal_type: Literal["vague", "unachievable"] = Field(
default="vague", description="Type: 'vague' or 'unachievable'"
)

View File

@@ -263,6 +263,7 @@ export function CreateAgentTool({ part }: Props) {
<SuggestedGoalCard
message={output.message}
suggestedGoal={output.suggested_goal}
reason={output.reason}
goalType={output.goal_type ?? "vague"}
onUseSuggestedGoal={handleUseSuggestedGoal}
/>

View File

@@ -7,6 +7,7 @@ import { ArrowRightIcon, LightbulbIcon } from "@phosphor-icons/react";
interface Props {
message: string;
suggestedGoal: string;
reason?: string;
goalType: string;
onUseSuggestedGoal: (goal: string) => void;
}
@@ -14,6 +15,7 @@ interface Props {
export function SuggestedGoalCard({
message,
suggestedGoal,
reason,
goalType,
onUseSuggestedGoal,
}: Props) {
@@ -33,7 +35,7 @@ export function SuggestedGoalCard({
: "Goal needs more detail"}
</Text>
<Text variant="small" className="text-slate-600">
{message}
{reason || message}
</Text>
</div>

View File

@@ -11709,6 +11709,7 @@
},
"goal_type": {
"type": "string",
"enum": ["vague", "unachievable"],
"title": "Goal Type",
"description": "Type: 'vague' or 'unachievable'",
"default": "vague"