Skip to content
Open
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
369 changes: 349 additions & 20 deletions cortex_on/agents/orchestrator_agent.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cortex_on/agents/web_surfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
TIMEOUT = 9999999999999999999999999999999999999999999

class WebSurfer:
def __init__(self, api_url: str = "http://localhost:8000/api/v1/web/stream"):
def __init__(self, api_url: str = "http://agentic_browser:8000/api/v1/web/stream"):
self.api_url = api_url
self.name = "Web Surfer Agent"
self.description = "An agent that is a websurfer and a webscraper that can access any web-page to extract information or perform actions."
Expand Down
15 changes: 14 additions & 1 deletion cortex_on/instructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# Local application imports
from agents.code_agent import coder_agent
from agents.orchestrator_agent import orchestrator_agent, orchestrator_deps
from agents.orchestrator_agent import orchestrator_agent, orchestrator_deps, UserCancellationError
from agents.planner_agent import planner_agent
from agents.web_surfer import WebSurfer
from utils.ant_client import get_client
Expand Down Expand Up @@ -101,6 +101,19 @@ async def run(self, task: str, websocket: WebSocket) -> List[Dict[str, Any]]:
logfire.info("Task completed successfully")
return [json.loads(json.dumps(asdict(i), cls=DateTimeEncoder)) for i in self.orchestrator_response]

except UserCancellationError:
# User-initiated cancellation - show friendly message
friendly_msg = "Task cancelled by user. No changes were made."
logfire.info(friendly_msg)

if stream_output:
stream_output.output = friendly_msg
stream_output.status_code = 200 # Use 200 to indicate successful cancellation
stream_output.steps.append("Task cancelled successfully")
await self._safe_websocket_send(stream_output)

return [json.loads(json.dumps(asdict(i), cls=DateTimeEncoder)) for i in self.orchestrator_response]

except Exception as e:
error_msg = f"Critical orchestration error: {str(e)}\n{traceback.format_exc()}"
logfire.error(error_msg)
Expand Down
1 change: 1 addition & 0 deletions cortex_on/utils/stream_response_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ class StreamResponse:
status_code: int
output: str
live_url: Optional[str] = None
metadata: Optional[dict] = None
9 changes: 6 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ services:
env_file:
- .env
restart: always
network_mode: host
ports:
- "8081:8081"

agentic_browser:
build:
Expand All @@ -21,7 +22,8 @@ services:
env_file:
- .env
restart: always
network_mode: host
ports:
- "8000:8000"

frontend:
build:
Expand All @@ -36,4 +38,5 @@ services:
- cortex_on
- agentic_browser
restart: always
network_mode: host
ports:
- "3000:3000"
Loading