Orchestrator
Core orchestration logic for the multi-agent grading pipeline.
Pipeline stages
- Validate the input summary.
- Parallel Score: three clinical roles score independently via
asyncio.gather(). - Validate Scorecards: retry any role whose output fails validation (missing dims, out-of-range scores, etc.).
- Disagreement Map: compute per-dimension cross-role score gaps.
- Conditional Adjudication (LLM mode only): if any gap ≥ threshold, an adjudicator LLM refines disputed dimensions.
- Aggregate: compute per-role weighted overalls and cross-role mean.
- Return structured result dict.
build_disagreement_map(scorecards_by_role_id, gap_threshold)
Build a per-dimension disagreement map across the three roles.
For each dimension, computes the score gap (max - min) and flags
dimensions where the gap meets or exceeds gap_threshold.
Returns:
| Type | Description |
|---|---|
Dict[str, Dict[str, Any]]
|
Dict mapping dimension_id → {role_scores, score_gap, flag}. |
Source code in src/grading_pipeline/orchestrator.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
calibrate_weights(w_prior, delta_w=None)
Combine prior weights with an optional delta adjustment and normalize.
Note: delta_w is currently a no-op stub (always zeros). It exists
as a hook for future weight calibration logic.
Source code in src/grading_pipeline/orchestrator.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
run_pipeline(summary, mode, output_format, *, rubric, roles, model='gpt-4o-mini', temperature=0.2, gap_threshold=0.5, max_retries=2, role_scorer=None, adjudicator=None)
async
Run the full grading pipeline end-to-end.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
summary
|
str
|
Raw clinical summary text. |
required |
mode
|
str
|
|
required |
output_format
|
str
|
|
required |
rubric
|
Rubric
|
Loaded rubric with dimension definitions. |
required |
roles
|
List[RoleProfile]
|
List of 3 |
required |
model
|
str
|
OpenAI model ID (LLM mode only). |
'gpt-4o-mini'
|
temperature
|
float
|
Sampling temperature (LLM mode only). |
0.2
|
gap_threshold
|
float
|
Min score gap to trigger adjudication. |
0.5
|
max_retries
|
int
|
Max re-scoring attempts per role on validation failure. |
2
|
role_scorer
|
Callable[[str, RoleProfile, Rubric], AgentScore] | None
|
Optional override for the per-role scoring function (useful for testing without API calls). |
None
|
adjudicator
|
Callable[..., Dict[str, Dict[str, Dict[str, Any]]]] | None
|
Optional override for the adjudication function. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict with keys: |
Dict[str, Any]
|
|
Source code in src/grading_pipeline/orchestrator.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | |