personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add triage muse agent and synchronous triage API endpoint

New `muse/triage.md` cogitate agent for quick-action chat bar requests
(navigate, todos, calendar, entities). Uses `instructions: {"now": true}`
only — no journal context, no facet injection from compose_instructions.

New `POST /app/chat/api/triage` endpoint spawns the triage agent, waits
for completion (60s timeout), and returns the response synchronously.
Triage responses are ephemeral — no chat records created.

+123
+80
apps/chat/routes.py
··· 513 513 514 514 except Exception as e: 515 515 return error_response(str(e), 500) 516 + 517 + 518 + @chat_bp.route("/api/triage", methods=["POST"]) 519 + def triage() -> Any: 520 + """Handle a quick triage request synchronously. 521 + 522 + Spawns the triage agent, waits for completion, and returns the text 523 + response. No chat record is created — triage responses are ephemeral. 524 + """ 525 + payload = request.get_json(force=True) 526 + message = payload.get("message", "").strip() 527 + app_name = payload.get("app", "") 528 + path = payload.get("path", "") 529 + facet = payload.get("facet", "") 530 + provider = payload.get("provider") 531 + 532 + if not message: 533 + return error_response("message is required", 400) 534 + if not provider: 535 + return error_response("provider is required", 400) 536 + 537 + api_key_error = _check_provider_api_key(provider) 538 + if api_key_error: 539 + return error_response(api_key_error, 503) 540 + 541 + # Build prompt with location context prepended 542 + context_lines = [] 543 + if app_name: 544 + context_lines.append(f"Current app: {app_name}") 545 + if path: 546 + context_lines.append(f"Current path: {path}") 547 + if facet: 548 + context_lines.append(f"Current facet: {facet}") 549 + 550 + if context_lines: 551 + full_prompt = "\n".join(context_lines) + "\n\n" + message 552 + else: 553 + full_prompt = message 554 + 555 + try: 556 + from convey.utils import spawn_agent 557 + 558 + config: dict[str, Any] = {} 559 + if facet: 560 + config["facet"] = facet 561 + 562 + agent_id = spawn_agent( 563 + prompt=full_prompt, 564 + name="triage", 565 + provider=provider, 566 + config=config, 567 + ) 568 + if agent_id is None: 569 + return error_response("Failed to connect to agent service", 503) 570 + 571 + # Wait synchronously for agent completion 572 + from think.cortex_client import read_agent_events, wait_for_agents 573 + 574 + completed, timed_out = wait_for_agents([agent_id], timeout=60) 575 + 576 + if agent_id in timed_out: 577 + return error_response("Triage request timed out", 504) 578 + 579 + end_state = completed.get(agent_id) 580 + if end_state == "error": 581 + return error_response("Triage agent encountered an error", 500) 582 + 583 + # Extract result text from finish event 584 + try: 585 + events = read_agent_events(agent_id) 586 + for event in reversed(events): 587 + if event.get("event") == "finish": 588 + return jsonify(response=event.get("result", "")) 589 + except FileNotFoundError: 590 + pass 591 + 592 + return error_response("No response from triage agent", 500) 593 + 594 + except Exception as e: 595 + return error_response(str(e), 500)
+43
muse/triage.md
··· 1 + { 2 + "type": "cogitate", 3 + "title": "Triage", 4 + "description": "Quick-action assistant for the chat bar — handles navigation, todos, calendar, and entity lookups", 5 + "instructions": {"now": true} 6 + } 7 + 8 + You are a quick-action assistant for the sol journal system chat bar. You handle simple actions and short lookups: navigate the app, manage todos, manage calendar events, and look up entities. 9 + 10 + Respond in one concise line for actions you complete. If a request needs journal search, transcript reading, deep analysis, or multi-step research, tell the user to ask in the Chat app instead. 11 + 12 + You are given context about the user's current app, URL path, and facet. Use this to inform your actions — for example, use the facet for todo and calendar commands. 13 + 14 + ## Available Commands 15 + 16 + ### Navigation 17 + - `sol call chat navigate [PATH] --facet FACET` — Navigate the browser to a path and/or switch facet. 18 + 19 + ### Todos 20 + - `sol call todos list [DAY] --facet FACET` — Show todos for a day. 21 + - `sol call todos add TEXT --day DAY --facet FACET [--nudge TIME]` — Add a todo. Nudge formats: HH:MM, now, tomorrow HH:MM, YYYYMMDDTHH:MM. 22 + - `sol call todos done LINE --day DAY --facet FACET` — Mark a todo as done. 23 + - `sol call todos cancel LINE --day DAY --facet FACET` — Cancel a todo. 24 + - `sol call todos upcoming --facet FACET [--limit N]` — Show upcoming todos. 25 + 26 + ### Calendar 27 + - `sol call calendar list [DAY] --facet FACET` — List events for a day. 28 + - `sol call calendar create TITLE --start HH:MM --day DAY --facet FACET [--end HH:MM] [--summary TEXT] [--participants NAMES]` — Create a calendar event. 29 + - `sol call calendar update LINE --day DAY --facet FACET [--title TEXT] [--start HH:MM] [--end HH:MM] [--summary TEXT] [--participants NAMES]` — Update an event. 30 + - `sol call calendar cancel LINE --day DAY --facet FACET` — Cancel an event. 31 + 32 + ### Entities 33 + - `sol call entities list [FACET]` — List entities for a facet. 34 + - `sol call entities observations ENTITY --facet FACET` — List observations for an entity. 35 + - `sol call entities observe ENTITY CONTENT --facet FACET` — Record an observation. 36 + 37 + ## Behavioral Rules 38 + 39 + - After completing an action, respond with one concise line confirming what you did. 40 + - For lookups (list todos, list events, list entities), present the results concisely. 41 + - If the user asks something that requires journal search, transcript reading, or deep analysis, respond: "That needs a deeper look — ask me in the Chat app." 42 + - Do not attempt to use any commands not listed above. You do not have access to journal search, transcript reading, or any other commands. 43 + - SOL_DAY and SOL_FACET environment variables are already set — tools will use them as defaults when --day/--facet are omitted. So you can often omit these flags.