|
7 | 7 | # Load reference docs at import time so they're always in the system prompt. |
8 | 8 | # No voluntary read_file() calls needed — the LLM gets everything upfront. |
9 | 9 | _ref_dir = Path(__file__).parent.parent / "reference" |
10 | | -_framework_guide = (_ref_dir / "framework_guide.md").read_text(encoding="utf-8") |
11 | | -_file_templates = (_ref_dir / "file_templates.md").read_text(encoding="utf-8") |
12 | | -_anti_patterns = (_ref_dir / "anti_patterns.md").read_text(encoding="utf-8") |
| 10 | +_framework_guide = (_ref_dir / "framework_guide.md").read_text() |
| 11 | +_file_templates = (_ref_dir / "file_templates.md").read_text() |
| 12 | +_anti_patterns = (_ref_dir / "anti_patterns.md").read_text() |
| 13 | +_gcu_guide_path = _ref_dir / "gcu_guide.md" |
| 14 | +_gcu_guide = _gcu_guide_path.read_text() if _gcu_guide_path.exists() else "" |
| 15 | + |
| 16 | + |
| 17 | +def _is_gcu_enabled() -> bool: |
| 18 | + try: |
| 19 | + from framework.config import get_gcu_enabled |
| 20 | + |
| 21 | + return get_gcu_enabled() |
| 22 | + except Exception: |
| 23 | + return False |
| 24 | + |
| 25 | + |
| 26 | +def _build_appendices() -> str: |
| 27 | + parts = ( |
| 28 | + "\n\n# Appendix: Framework Reference\n\n" |
| 29 | + + _framework_guide |
| 30 | + + "\n\n# Appendix: File Templates\n\n" |
| 31 | + + _file_templates |
| 32 | + + "\n\n# Appendix: Anti-Patterns\n\n" |
| 33 | + + _anti_patterns |
| 34 | + ) |
| 35 | + if _is_gcu_enabled() and _gcu_guide: |
| 36 | + parts += "\n\n# Appendix: GCU Browser Automation Guide\n\n" + _gcu_guide |
| 37 | + return parts |
| 38 | + |
13 | 39 |
|
14 | 40 | # Shared appendices — appended to every coding node's system prompt. |
15 | | -_appendices = ( |
16 | | - "\n\n# Appendix: Framework Reference\n\n" |
17 | | - + _framework_guide |
18 | | - + "\n\n# Appendix: File Templates\n\n" |
19 | | - + _file_templates |
20 | | - + "\n\n# Appendix: Anti-Patterns\n\n" |
21 | | - + _anti_patterns |
22 | | -) |
| 41 | +_appendices = _build_appendices() |
23 | 42 |
|
24 | 43 | # Tools available to both coder (worker) and queen. |
25 | 44 | _SHARED_TOOLS = [ |
|
391 | 410 | **Node rules**: |
392 | 411 | - **2-4 nodes MAX.** Never exceed 4. Merge thin nodes aggressively. |
393 | 412 | - A node with 0 tools is NOT a real node — merge it. |
394 | | -- node_type always "event_loop" |
| 413 | +- node_type "event_loop" for all regular graph nodes. Use "gcu" ONLY for |
| 414 | + browser automation subagents (see GCU appendix). GCU nodes MUST be in a |
| 415 | + parent node's sub_agents list, NEVER connected via edges, and NEVER used |
| 416 | + as entry/terminal nodes. |
395 | 417 | - max_node_visits default is 0 (unbounded) — correct for forever-alive. \ |
396 | 418 | Only set >0 in one-shot agents with bounded feedback loops. |
397 | 419 | - Feedback inputs: nullable_output_keys |
|
539 | 561 | this session. If a worker is already loaded, it is automatically unloaded \ |
540 | 562 | first. Call after building and validating an agent to make it available \ |
541 | 563 | immediately. |
| 564 | +
|
| 565 | +## Credentials |
| 566 | +- list_credentials(credential_id?) — List all authorized credentials in the \ |
| 567 | +local store. Returns IDs, aliases, status, and identity metadata (never \ |
| 568 | +secrets). Optionally filter by credential_id. |
542 | 569 | """ |
543 | 570 |
|
544 | 571 | _queen_behavior = """ |
|
589 | 616 | - For tasks matching the worker's goal, call start_worker(task). |
590 | 617 | - For everything else, do it directly. |
591 | 618 |
|
| 619 | +## When the user clicks Run (external event notification) |
| 620 | +When you receive an event that the user clicked Run: |
| 621 | +- If the worker started successfully, briefly acknowledge it — do NOT \ |
| 622 | +repeat the full status. The user can see the graph is running. |
| 623 | +- If the worker failed to start (credential or structural error), \ |
| 624 | +explain the problem clearly and help fix it. For credential errors, \ |
| 625 | +guide the user to set up the missing credentials. For structural \ |
| 626 | +issues, offer to fix the agent graph directly. |
| 627 | +
|
592 | 628 | ## When worker is running: |
593 | | -- If the user asks about progress, call get_worker_status(). |
| 629 | +- If the user asks about progress, call get_worker_status() ONCE and \ |
| 630 | +report the result. Do NOT poll in a loop. |
| 631 | +- NEVER call get_worker_status() repeatedly without user input in between. \ |
| 632 | +The worker will surface results through client-facing nodes. You do not \ |
| 633 | +need to monitor it. One check per user request is enough. |
594 | 634 | - If the user has a concern or instruction for the worker, call \ |
595 | 635 | inject_worker_message(content) to relay it. |
596 | 636 | - You can still do coding tasks directly while the worker runs. |
597 | 637 | - If an escalation ticket arrives from the judge, assess severity: |
598 | 638 | - Low/transient: acknowledge silently, do not disturb the user. |
599 | 639 | - High/critical: notify the user with a brief analysis and suggested action. |
| 640 | +- After starting the worker or checking its status, WAIT for the user's \ |
| 641 | +next message. Do not take autonomous actions unless the user asks. |
600 | 642 |
|
601 | 643 | ## When worker asks user a question: |
602 | 644 | - The system will route the user's response directly to the worker. \ |
|
778 | 820 | "notify_operator", |
779 | 821 | # Agent loading |
780 | 822 | "load_built_agent", |
| 823 | + # Credentials |
| 824 | + "list_credentials", |
781 | 825 | ], |
782 | 826 | system_prompt=( |
783 | 827 | "You are the Queen — the user's primary interface. You are a coding agent " |
|
803 | 847 | "notify_operator", |
804 | 848 | # Agent loading |
805 | 849 | "load_built_agent", |
| 850 | + # Credentials |
| 851 | + "list_credentials", |
806 | 852 | ] |
807 | 853 |
|
808 | 854 | __all__ = [ |
|
0 commit comments