Adds additional prompting for the managed agent, runs it, and wraps the output. This method is called only by a managed agent.
(self, task: str, **kwargs)
| 866 | self.memory.replay(self.logger, detailed=detailed) |
| 867 | |
| 868 | def __call__(self, task: str, **kwargs): |
| 869 | """Adds additional prompting for the managed agent, runs it, and wraps the output. |
| 870 | This method is called only by a managed agent. |
| 871 | """ |
| 872 | full_task = populate_template( |
| 873 | self.prompt_templates["managed_agent"]["task"], |
| 874 | variables=dict(name=self.name, task=task), |
| 875 | ) |
| 876 | result = self.run(full_task, **kwargs) |
| 877 | if isinstance(result, RunResult): |
| 878 | report = result.output |
| 879 | else: |
| 880 | report = result |
| 881 | answer = populate_template( |
| 882 | self.prompt_templates["managed_agent"]["report"], variables=dict(name=self.name, final_answer=report) |
| 883 | ) |
| 884 | if self.provide_run_summary: |
| 885 | answer += "\n\nFor more detail, find below a summary of this agent's work:\n<summary_of_work>\n" |
| 886 | for message in self.write_memory_to_messages(summary_mode=True): |
| 887 | content = message.content |
| 888 | answer += "\n" + truncate_content(str(content)) + "\n---" |
| 889 | answer += "\n</summary_of_work>" |
| 890 | return answer |
| 891 | |
| 892 | def save(self, output_dir: str | Path, relative_path: str | None = None): |
| 893 | """ |
nothing calls this directly
no test coverage detected