-
-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Using model_name="gpt-4o", the orchestrator seems to have trouble parsing the llm response for the diagnoser agent. This causes issues at main.py::_update_differential_from_hypothesis, where structured data parsing fails and it falls back to wonky regex parsing.
The expected response is a tool call json with schema:
`
Define structured output tool for differential diagnosis
hypothesis_tool = {
"type": "function",
"function": {
"type": "function",
"name": "update_differential_diagnosis",
"description": "Update the differential diagnosis with structured probabilities and reasoning",
"parameters": {
"type": "object",
"properties": {
"summary": {
"type": "string",
"description": "One-sentence summary of primary diagnostic conclusion and confidence"
},
"differential_diagnoses": {
"type": "array",
"items": {
"type": "object",
"properties": {
"diagnosis": {"type": "string", "description": "The diagnosis name"},
"probability": {"type": "number", "minimum": 0, "maximum": 1, "description": "Probability as decimal (0.0-1.0)"},
"rationale": {"type": "string", "description": "Brief rationale for this diagnosis"}
},
"required": ["diagnosis", "probability", "rationale"]
},
"minItems": 2,
"maxItems": 5,
"description": "Top 2-5 differential diagnoses with probabilities"
},
"key_evidence": {
"type": "string",
"description": "Key supporting evidence for leading hypotheses"
},
"contradictory_evidence": {
"type": "string",
"description": "Critical contradictory evidence that must be addressed"
}
},
"required": ["summary", "differential_diagnoses", "key_evidence"]
}
}
}
`
Actual response is the expected json but wrapped around in some more json:
'[ {\'function\': {\'arguments\': \'{ "summary": "Differential includes musculoskeletal, vascular, and neuropathic causes for thigh pain in elderly.", "differential_diagnoses": [ { "diagnosis": "Muscle strain or sprain", "probability": 0.4, "rationale": "Common cause of thigh pain, especially if there is a history of recent physical activity or trauma." }, { "diagnosis": "Osteoarthritis", "probability": 0.3, "rationale": "Prevalent in elderly, can cause referred pain to the thigh." }, { "diagnosis": "Peripheral artery disease", "probability": 0.2, "rationale": "Common in elderly with risk factors, can cause pain due to poor circulation." }, { "diagnosis": "Sciatica", "probability": 0.1, "rationale": "May present with thigh pain if nerve root compression is present." } ], "key_evidence":"Patient\\\'s age suggests higher likelihood of degenerative or vascular conditions.", "contradictory_evidence": "No specific history of trauma or activity suggests against acute musculoskeletal injury." }\', \'name\': \'update_differential_diagnosis\' }, \'id\': \'call_YFc42mvnMKpfTDSYSkMasrtY\', \'type\': \'function\' } ]'