Summarize a raw plan execution result into a compact, structured form. Uses the plan generator model (cheap, e.g. gpt-5) to produce a summary that captures key outputs, findings, files created, and any information subsequent tasks might need. This mirrors the autocom
(
self, raw_result: str, task_description: str
)
| 804 | pass |
| 805 | |
| 806 | def _summarize_execution_result( |
| 807 | self, raw_result: str, task_description: str |
| 808 | ) -> str: |
| 809 | """Summarize a raw plan execution result into a compact, structured form. |
| 810 | |
| 811 | Uses the plan generator model (cheap, e.g. gpt-5) to produce a |
| 812 | summary that captures key outputs, findings, files created, and |
| 813 | any information subsequent tasks might need. This mirrors the |
| 814 | autocompact/agent-summary pattern from mature agentic harnesses: |
| 815 | a separate cheap LLM call summarizes output at an execution boundary, |
| 816 | so only compact context crosses into the orchestrator's awareness. |
| 817 | |
| 818 | If the raw result is already short enough (<= 500 chars), it is |
| 819 | returned directly without an LLM call to save cost. |
| 820 | |
| 821 | Args: |
| 822 | raw_result: Full text output from PlanExecutor.execute(). |
| 823 | task_description: Description of the task (for summarization context). |
| 824 | |
| 825 | Returns: |
| 826 | Compact summary string (typically 200-500 words). |
| 827 | """ |
| 828 | # Short results don't need summarization |
| 829 | if len(raw_result) <= 500: |
| 830 | return raw_result |
| 831 | |
| 832 | # Cap the input to avoid blowing the summarizer's context |
| 833 | input_text = raw_result[:10000] |
| 834 | if len(raw_result) > 10000: |
| 835 | input_text += ( |
| 836 | f"\n\n... [truncated: {len(raw_result) - 10000:,} chars omitted]" |
| 837 | ) |
| 838 | |
| 839 | messages = [ |
| 840 | { |
| 841 | "role": "system", |
| 842 | "content": ( |
| 843 | "You are a concise summarizer for task execution results. " |
| 844 | "Given the task description and its execution output, produce " |
| 845 | "a structured summary that captures:\n" |
| 846 | "1. Key outputs and findings\n" |
| 847 | "2. Files created or modified (with paths if available)\n" |
| 848 | "3. Important decisions or data produced\n" |
| 849 | "4. Any information that subsequent tasks might need\n\n" |
| 850 | "Be concise but comprehensive. Max 500 words. " |
| 851 | "Use bullet points for clarity." |
| 852 | ), |
| 853 | }, |
| 854 | { |
| 855 | "role": "user", |
| 856 | "content": ( |
| 857 | f"Task: {task_description}\n\n" f"Execution output:\n{input_text}" |
| 858 | ), |
| 859 | }, |
| 860 | ] |
| 861 | |
| 862 | try: |
| 863 | response = self.llm_client.completion( |
no test coverage detected