Skip to content

Commit 78495c1

Browse files
committed
Add agent message endpoint and update AgentMessageResponse model
Introduces a new /agent_message POST endpoint to receive agent messages in the backend API. Updates the AgentMessageResponse model to make several fields optional for improved flexibility. Also removes an unnecessary blank line in PlanPage.tsx.
1 parent 2b9c1be commit 78495c1

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/backend/v3/api/router.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,21 @@ async def user_clarification(
489489
status_code=404, detail="No active plan found for clarification"
490490
)
491491

492+
@app_v3.post("/agent_message")
493+
async def agent_message_user(
494+
agent_message: messages.AgentMessageResponse, request: Request
495+
):
496+
"""Endpoint to receive agent messages."""
497+
authenticated_user = get_authenticated_user_details(request_headers=request.headers)
498+
user_id = authenticated_user["user_principal_id"]
499+
if not user_id:
500+
raise HTTPException(
501+
status_code=401, detail="Missing or invalid user information"
502+
)
503+
# Set the approval in the orchestration config
504+
505+
506+
492507

493508
@app_v3.post("/upload_team_config")
494509
async def upload_team_config(

src/backend/v3/models/messages.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ class AgentMessageResponse:
128128
"""Message sent to HumanAgent to request approval for a step."""
129129
plan_id: str
130130
m_plan_id: Optional[str] = None
131-
user_id: str
131+
user_id: Optional[str]
132132
agent: str
133133
agent_type: AgentMessageType
134-
timestamp: int
134+
timestamp: Optional[str]
135135
content: str
136-
raw_data: str
137-
steps: List[Any] = Field(default_factory=list)
138-
next_steps: List[Any] = Field(default_factory=list)
136+
raw_data: Optional[str]
137+
steps: List[Any] = Field(default_factory=list)
138+
next_steps: List[Any] = Field(default_factory=list)
139139

140140
class WebsocketMessageType(str, Enum):
141141
"""Types of WebSocket messages."""

src/frontend/src/pages/PlanPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ const PlanPage: React.FC = () => {
437437
useEffect(() => {
438438
const initializePlanLoading = async () => {
439439
if (!planId) {
440-
441440
setErrorLoading(true);
442441
return;
443442
}

0 commit comments

Comments
 (0)