Test that tools="none" disables all tools except DoneTool for the sub-agent.
()
| 270 | |
| 271 | |
| 272 | def test_task_tool_none_tools(): |
| 273 | """ |
| 274 | Test that tools="none" disables all tools except DoneTool for the sub-agent. |
| 275 | """ |
| 276 | # Create a main agent that delegates with no tools |
| 277 | main_config = ChatAgentConfig( |
| 278 | llm=MockLMConfig( |
| 279 | default_response=TaskTool( |
| 280 | agent_name="Calculator", |
| 281 | system_message=f""" |
| 282 | You are an assistant with no tools. Just respond directly |
| 283 | to the prompt and use `{DoneTool.name()}` to return your answer. |
| 284 | """, |
| 285 | prompt="What is 2 + 2? Just tell me the answer.", |
| 286 | model="gpt-4o-mini", |
| 287 | tools=["NONE"], # Disable all tools except DoneTool |
| 288 | max_iterations=20, |
| 289 | ).model_dump_json() |
| 290 | ), |
| 291 | name="MainAgent", |
| 292 | ) |
| 293 | main_agent = ChatAgent(main_config) |
| 294 | |
| 295 | # Enable TaskTool and other tools for the main agent |
| 296 | # (sub-agent won't have access to these) |
| 297 | main_agent.enable_message( |
| 298 | [TaskTool, MultiplierTool, NebrowskiTool], use=True, handle=True |
| 299 | ) |
| 300 | |
| 301 | # Create task |
| 302 | task = Task( |
| 303 | main_agent, |
| 304 | name="NoToolsTask", |
| 305 | interactive=False, |
| 306 | config=TaskConfig( |
| 307 | done_sequences=["T,A"], # LLM (Tool), Agent(Handled) -> done |
| 308 | ), |
| 309 | ) |
| 310 | |
| 311 | # Run the task |
| 312 | result = task.run(msg="Test no tools") |
| 313 | |
| 314 | # Verify that the task completed (sub-agent can still use DoneTool) |
| 315 | assert result is not None, "Task should return a result" |
nothing calls this directly
no test coverage detected
searching dependent graphs…