Test agent call with provide_run_summary (#513)
This commit is contained in:
		
							parent
							
								
									9318c8cae3
								
							
						
					
					
						commit
						a17f915f61
					
				|  | @ -625,9 +625,9 @@ You have been provided with these additional arguments, that you can access usin | ||||||
|         self.memory.replay(self.logger, detailed=detailed) |         self.memory.replay(self.logger, detailed=detailed) | ||||||
| 
 | 
 | ||||||
|     def __call__(self, task: str, **kwargs): |     def __call__(self, task: str, **kwargs): | ||||||
|         """ |         """Adds additional prompting for the managed agent, runs it, and wraps the output. | ||||||
|         This method is called only by a manager agent. | 
 | ||||||
|         Adds additional prompting for the managed agent, runs it, and wraps the output. |         This method is called only by a managed agent. | ||||||
|         """ |         """ | ||||||
|         full_task = populate_template( |         full_task = populate_template( | ||||||
|             self.prompt_templates["managed_agent"]["task"], |             self.prompt_templates["managed_agent"]["task"], | ||||||
|  |  | ||||||
|  | @ -772,6 +772,26 @@ class TestMultiStepAgent: | ||||||
|                     assert "text" in content |                     assert "text" in content | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | class TestCodeAgent: | ||||||
|  |     @pytest.mark.parametrize("provide_run_summary", [False, True]) | ||||||
|  |     def test_call_with_provide_run_summary(self, provide_run_summary): | ||||||
|  |         agent = CodeAgent(tools=[], model=MagicMock(), provide_run_summary=provide_run_summary) | ||||||
|  |         assert agent.provide_run_summary is provide_run_summary | ||||||
|  |         agent.managed_agent_prompt = "Task: {task}" | ||||||
|  |         agent.name = "test_agent" | ||||||
|  |         agent.run = MagicMock(return_value="Test output") | ||||||
|  |         agent.write_memory_to_messages = MagicMock(return_value=[{"content": "Test summary"}]) | ||||||
|  | 
 | ||||||
|  |         result = agent("Test request") | ||||||
|  |         expected_summary = "Here is the final answer from your managed agent 'test_agent':\nTest output" | ||||||
|  |         if provide_run_summary: | ||||||
|  |             expected_summary += ( | ||||||
|  |                 "\n\nFor more detail, find below a summary of this agent's work:\n" | ||||||
|  |                 "<summary_of_work>\n\nTest summary\n---\n</summary_of_work>" | ||||||
|  |             ) | ||||||
|  |         assert result == expected_summary | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| @pytest.fixture | @pytest.fixture | ||||||
| def prompt_templates(): | def prompt_templates(): | ||||||
|     return { |     return { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue