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
4 changes: 2 additions & 2 deletions data/agent_teams/new 29.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BE: Create a teams container in Cosmos and move all loaded team definitions ther
Implement saving of plan to cosmos -> history in...

================ Request submit flow ======================
on request submission call "/create_plan" (process_request)
on request submission call "/process_request" (process_request)
This will return immediately - move to other page and display spinner -> "creating plan"
Socket will start receiving messages ->
Stream plan output into main window
Expand All @@ -30,7 +30,7 @@ Send PlanApprovalResponse message when user answers
If not approved
BE: plan will cancel on backend
FE: - enable input again for fresh request
Call input_request API on backend again (just like inputing any request)
Call input_request API on backend again (just like inputting any request)

If approved:
Display plan steps in right pane if approved
Expand Down
25 changes: 13 additions & 12 deletions src/backend/tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
from unittest.mock import MagicMock, patch

import pytest
from fastapi.testclient import TestClient

Expand Down Expand Up @@ -48,8 +49,8 @@ def test_input_task_invalid_json():
response = client.post("/input_task", data=invalid_json, headers=headers)


def test_create_plan_endpoint_success():
"""Test the /api/create_plan endpoint with valid input."""
def test_process_request_endpoint_success():
"""Test the /api/process_request endpoint with valid input."""
headers = {"Authorization": "Bearer mock-token"}

# Mock the RAI success function
Expand All @@ -66,7 +67,7 @@ def test_create_plan_endpoint_success():
"description": "Create a marketing plan for our new product"
}

response = client.post("/api/create_plan", json=test_input, headers=headers)
response = client.post("/api/process_request", json=test_input, headers=headers)

# Print response details for debugging
print(f"Response status: {response.status_code}")
Expand All @@ -85,8 +86,8 @@ def test_create_plan_endpoint_success():
mock_memory_store.add_plan.assert_called_once()


def test_create_plan_endpoint_rai_failure():
"""Test the /api/create_plan endpoint when RAI check fails."""
def test_process_request_endpoint_rai_failure():
"""Test the /api/process_request endpoint when RAI check fails."""
headers = {"Authorization": "Bearer mock-token"}

# Mock the RAI failure
Expand All @@ -98,7 +99,7 @@ def test_create_plan_endpoint_rai_failure():
"description": "This is an unsafe description"
}

response = client.post("/api/create_plan", json=test_input, headers=headers)
response = client.post("/api/process_request", json=test_input, headers=headers)

# Check response
assert response.status_code == 400
Expand All @@ -107,8 +108,8 @@ def test_create_plan_endpoint_rai_failure():
assert "safety validation" in data["detail"]


def test_create_plan_endpoint_harmful_content():
"""Test the /api/create_plan endpoint with harmful content that should fail RAI."""
def test_process_request_endpoint_harmful_content():
"""Test the /api/process_request endpoint with harmful content that should fail RAI."""
headers = {"Authorization": "Bearer mock-token"}

# Mock the RAI failure for harmful content
Expand All @@ -120,7 +121,7 @@ def test_create_plan_endpoint_harmful_content():
"description": "I want to kill my neighbors cat"
}

response = client.post("/api/create_plan", json=test_input, headers=headers)
response = client.post("/api/process_request", json=test_input, headers=headers)

# Print response details for debugging
print(f"Response status: {response.status_code}")
Expand All @@ -133,8 +134,8 @@ def test_create_plan_endpoint_harmful_content():
assert "safety validation" in data["detail"]


def test_create_plan_endpoint_real_rai_check():
"""Test the /api/create_plan endpoint with real RAI check (no mocking)."""
def test_process_request_endpoint_real_rai_check():
"""Test the /api/process_request endpoint with real RAI check (no mocking)."""
headers = {"Authorization": "Bearer mock-token"}

# Don't mock RAI - let it run the real check
Expand All @@ -150,7 +151,7 @@ def test_create_plan_endpoint_real_rai_check():
"description": "I want to kill my neighbors cat"
}

response = client.post("/api/create_plan", json=test_input, headers=headers)
response = client.post("/api/process_request", json=test_input, headers=headers)

# Print response details for debugging
print(f"Real RAI Response status: {response.status_code}")
Expand Down
7 changes: 4 additions & 3 deletions src/backend/v3/api/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import v3.models.messages as messages
from auth.auth_utils import get_authenticated_user_details
from common.database.database_factory import DatabaseFactory
from common.models.messages_kernel import (GeneratePlanRequest, InputTask, PlanStatus,
TeamSelectionRequest, Plan)
from common.models.messages_kernel import (GeneratePlanRequest, InputTask,
Plan, PlanStatus,
TeamSelectionRequest)
from common.utils.event_utils import track_event_if_configured
from common.utils.utils_kernel import rai_success, rai_validate_team_config
from fastapi import (APIRouter, BackgroundTasks, Depends, FastAPI, File,
Expand Down Expand Up @@ -130,7 +131,7 @@ async def init_team(
)
raise HTTPException(status_code=400, detail=f"Error starting request: {e}") from e

@app_v3.post("/create_plan")
@app_v3.post("/process_request")
async def process_request(background_tasks: BackgroundTasks, input_task: InputTask, request: Request):
"""
Create a new plan without full processing.
Expand Down
12 changes: 11 additions & 1 deletion src/backend/v3/models/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class FinalResultMessage:
summary: str | None = None
context: dict | None = None

@dataclass(slots=True)
class HumanFeedback(KernelBaseModel):
"""Message containing human feedback on a step."""

Expand All @@ -93,14 +94,15 @@ class HumanFeedback(KernelBaseModel):
human_feedback: Optional[str] = None
updated_action: Optional[str] = None


@dataclass(slots=True)
class HumanClarification(KernelBaseModel):
"""Message containing human clarification on a plan."""

plan_id: str
session_id: str
human_clarification: str

@dataclass(slots=True)
class ApprovalRequest(KernelBaseModel):
"""Message sent to HumanAgent to request approval for a step."""

Expand All @@ -110,3 +112,11 @@ class ApprovalRequest(KernelBaseModel):
user_id: str
action: str
agent_name: str

@dataclass(slots=True)
class HumanClarification(KernelBaseModel):
"""Message containing human clarification on a plan."""

plan_id: str
session_id: str
human_clarification: str
6 changes: 3 additions & 3 deletions src/frontend/src/api/apiService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
// Constants for endpoints
const API_ENDPOINTS = {
INPUT_TASK: '/input_task',
CREATE_PLAN: '/v3/create_plan',
PROCESS_REQUEST: '/v3/process_request',
PLANS: '/plans',
STEPS: '/steps',
HUMAN_FEEDBACK: '/human_feedback',
Expand Down Expand Up @@ -115,11 +115,11 @@ export class APIService {
* @returns Promise with the response containing plan ID and status
*/
// async createPlan(inputTask: InputTask): Promise<{ plan_id: string; status: string; session_id: string }> {
// return apiClient.post(API_ENDPOINTS.CREATE_PLAN, inputTask);
// return apiClient.post(API_ENDPOINTS.PROCESS_REQUEST, inputTask);
// }

async createPlan(inputTask: InputTask): Promise<{ status: string; session_id: string }> {
return apiClient.post(API_ENDPOINTS.CREATE_PLAN, inputTask);
return apiClient.post(API_ENDPOINTS.PROCESS_REQUEST, inputTask);
}

/**
Expand Down
16 changes: 0 additions & 16 deletions src/mcp_server/,env

This file was deleted.

Loading