Update analyst statuses based on accumulated report state. Logic: - Store new report content from the current chunk if present - Check accumulated report_sections (not just current chunk) for status - Analysts with reports = completed - First analyst without report = in_progress
(message_buffer, chunk, wall_time_tracker=None)
| 837 | |
| 838 | |
| 839 | def update_analyst_statuses(message_buffer, chunk, wall_time_tracker=None): |
| 840 | """Update analyst statuses based on accumulated report state. |
| 841 | |
| 842 | Logic: |
| 843 | - Store new report content from the current chunk if present |
| 844 | - Check accumulated report_sections (not just current chunk) for status |
| 845 | - Analysts with reports = completed |
| 846 | - First analyst without report = in_progress |
| 847 | - Remaining analysts without reports = pending |
| 848 | - When all analysts done, set Bull Researcher to in_progress |
| 849 | """ |
| 850 | selected = message_buffer.selected_analysts |
| 851 | found_active = False |
| 852 | |
| 853 | if wall_time_tracker is not None: |
| 854 | sync_analyst_tracker_from_chunk(wall_time_tracker, chunk) |
| 855 | |
| 856 | for analyst_key in ANALYST_ORDER: |
| 857 | if analyst_key not in selected: |
| 858 | continue |
| 859 | |
| 860 | agent_name = ANALYST_AGENT_NAMES[analyst_key] |
| 861 | report_key = ANALYST_REPORT_MAP[analyst_key] |
| 862 | |
| 863 | # Capture new report content from current chunk |
| 864 | if chunk.get(report_key): |
| 865 | message_buffer.update_report_section(report_key, chunk[report_key]) |
| 866 | |
| 867 | # Determine status from accumulated sections, not just current chunk |
| 868 | has_report = bool(message_buffer.report_sections.get(report_key)) |
| 869 | |
| 870 | if has_report: |
| 871 | message_buffer.update_agent_status(agent_name, "completed") |
| 872 | elif not found_active: |
| 873 | message_buffer.update_agent_status(agent_name, "in_progress") |
| 874 | found_active = True |
| 875 | else: |
| 876 | message_buffer.update_agent_status(agent_name, "pending") |
| 877 | |
| 878 | # When all analysts complete, transition research team to in_progress |
| 879 | if ( |
| 880 | not found_active |
| 881 | and selected |
| 882 | and message_buffer.agent_status.get("Bull Researcher") == "pending" |
| 883 | ): |
| 884 | message_buffer.update_agent_status("Bull Researcher", "in_progress") |
| 885 | |
| 886 | def extract_content_string(content): |
| 887 | """Extract string content from various message formats. |
no test coverage detected