Spaces:
Paused
feat: Filter tools based on mode for Socratic teaching
Browse filesProblem: Socratic mode should guide learning through questions, not give
direct answers. Tools like segmentation and report generation defeat the
purpose by providing complete answers.
Solution: Filter tools based on agent mode
- Assistant mode: All 8 tools available
- Socratic mode: Only 5 teaching-appropriate tools
Socratic Tools (5):
β Grounding - "Show me where you see that"
β VQA - Ask targeted questions about specific features
β Classification - Show probabilities to guide thinking
β Generation - Create practice cases
β DICOM Processor - Utility only
Excluded from Socratic (3):
β Segmentation - Draws answers automatically
β Report Generation - Gives complete diagnosis
β Web Browser - Not relevant to case analysis
This ensures Socratic mode truly guides discovery vs giving answers.
π€ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- medrax/agent/agent.py +17 -2
|
@@ -59,8 +59,23 @@ class Agent:
|
|
| 59 |
self.system_prompt = system_prompt
|
| 60 |
self.mode = mode
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
# Create the parallel tool execution node
|
| 63 |
-
self.tool_node = ToolNode(
|
| 64 |
|
| 65 |
# Define the agent workflow with parallel tool execution
|
| 66 |
workflow = StateGraph(AgentState)
|
|
@@ -71,7 +86,7 @@ class Agent:
|
|
| 71 |
workflow.set_entry_point("agent")
|
| 72 |
|
| 73 |
self.workflow = workflow.compile(checkpointer=checkpointer)
|
| 74 |
-
self.model = model.bind_tools(
|
| 75 |
|
| 76 |
def process_request(self, state: AgentState) -> Dict[str, List[AnyMessage]]:
|
| 77 |
"""
|
|
|
|
| 59 |
self.system_prompt = system_prompt
|
| 60 |
self.mode = mode
|
| 61 |
|
| 62 |
+
# Filter tools based on mode
|
| 63 |
+
# Socratic mode: Only use tools that help guide learning, not give answers
|
| 64 |
+
if mode == "socratic":
|
| 65 |
+
socratic_tool_names = {
|
| 66 |
+
"xray_phrase_grounding", # Show locations to guide observation
|
| 67 |
+
"chest_xray_vqa", # Ask specific questions about findings
|
| 68 |
+
"torchxrayvision_classifier", # Show probabilities to guide thinking
|
| 69 |
+
"chest_xray_generator", # Generate practice cases
|
| 70 |
+
"dicom_processor", # Utility for file handling
|
| 71 |
+
}
|
| 72 |
+
filtered_tools = [t for t in tools if t.name in socratic_tool_names]
|
| 73 |
+
print(f"Socratic mode: Using {len(filtered_tools)} tools (filtered from {len(tools)})")
|
| 74 |
+
else:
|
| 75 |
+
filtered_tools = tools
|
| 76 |
+
|
| 77 |
# Create the parallel tool execution node
|
| 78 |
+
self.tool_node = ToolNode(filtered_tools)
|
| 79 |
|
| 80 |
# Define the agent workflow with parallel tool execution
|
| 81 |
workflow = StateGraph(AgentState)
|
|
|
|
| 86 |
workflow.set_entry_point("agent")
|
| 87 |
|
| 88 |
self.workflow = workflow.compile(checkpointer=checkpointer)
|
| 89 |
+
self.model = model.bind_tools(filtered_tools)
|
| 90 |
|
| 91 |
def process_request(self, state: AgentState) -> Dict[str, List[AnyMessage]]:
|
| 92 |
"""
|