agent-orchestration
Initialize, configure, and safely exercise the MedRAX LangGraph agent with a selected tool registry, prompt sections, OpenAI-compatible chat model, checkpointed threads, and tool-call logs.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- agent-orchestration
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Initialize, configure, and safely exercise the MedRAX LangGraph agent with a selected tool registry, prompt sections, OpenAI-compatible chat model, checkpointed threads, and tool-call logs.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/api-reference.md6.1 KB
- 参考文档references/troubleshooting.md5.8 KB
- 参考文档references/workflows.md6.6 KB
- 参考文档resources/system_prompts.txt660 B
- 脚本scripts/check_medrax_import.py5.9 KB
- 脚本scripts/medrax_agent_factory.py6.2 KB
03 SKILL.md 正文
MedRAX agent orchestration
Use this skill when a Researcher needs the MedRAX control plane rather than the
implementation details of a particular chest-X-ray model. It covers building an
Agent, selecting tools without accidentally loading optional weights, choosing
an OpenAI-compatible endpoint, loading the medical system prompt, invoking a
checkpointed thread, and inspecting tool-call logs.
Do not use this skill to explain a model's input/output semantics. Route those
questions to chest-xray-analysis. Route DICOM and visualization work to
image-data-utilities, UI/demo launch to web-interface, and benchmark cases
or metrics to benchmark-evaluation.
Operating contract
- Work from an installed MedRAX package and a caller-owned prompt file. The
bundled
resources/system_prompts.txtis a portable template; do not require a source checkout or hard-coded checkout path. - Keep model-weight directories, temporary files, logs, and credentials outside the skill tree. Never put API keys in code or prompt files.
- Treat medical output as decision support, not a diagnosis. Preserve tool results and uncertainty for the caller to review.
- Before constructing the real agent, run the bundled safe checker when the
environment or dependency set is uncertain:
python scripts/check_medrax_import.py --project-root .. It parses signatures and performs only lightweight imports; it does not create aChatOpenAI, initialize a tool, download weights, or make a network call.
Standard initialization
- Confirm an accessible prompt file containing
[MEDICAL_ASSISTANT](or choose another explicit section) and a writabletemp_dirif a selected utility needs temporary files. - Choose a small
tools_to_uselist. The exact registry inmain.initialize_agentis documented in api-reference.md. Start withImageVisualizerToolandDicomProcessorToolfor orchestration smoke tests; add model-backed tools only after their own sibling skill and backend are ready. - Build
openai_kwargsfrom the process environment. Passapi_keyand, when needed,base_url; never print either value. A local OpenAI-compatible service commonly usesOPENAI_BASE_URL=http://localhost:11434/v1and a provider-specific placeholder key. See workflows.md. - Call the adapted
scripts/medrax_agent_factory.pyfunctionbuild_agent(prompt_file, tools_to_use=..., model_dir=..., temp_dir=..., device=..., model=..., temperature=..., top_p=..., openai_kwargs=...); it returns(agent, tools_dict)and refuses an implicit all-tools selection. When integrating with the original application, the equivalentmain.initialize_agentsignature is recorded in api-reference.md. - Invoke the compiled graph with a message state and a stable configurable
thread identifier, for example:
agent.workflow.invoke({"messages": [HumanMessage(content="...")]}, {"configurable": {"thread_id": "smoke-001"}}). Keep the samethread_idto continue a conversation; use a new one for an isolated run. Exact invocation and fake-model examples are in the workflow reference.
Safety and selection rules
tools_to_use=Noneselects every registered tool. In this implementation, an empty list is also replaced by every tool because selection usestools_to_use or all_tools.keys(); use a non-empty explicit list when excluding model-backed tools.- Unknown names are silently ignored by
initialize_agent. Compareset(requested) - set(tools_dict)after initialization and fail closed in a wrapper if any were omitted. - Do not select
LlavaMedTool,XRayPhraseGroundingTool,ChestXRayGeneratorTool,XRayVQATool,ChestXRayReportGeneratorTool, or other weight-backed tools merely to test graph wiring. Their constructors may download or load large models. The two utility tools are the safe default. Agentbinds every constructed tool throughmodel.bind_tools(tools). A model that cannot bind LangChain tool schemas is not a compatible backend.- Use
MemorySaver()as the in-memory checkpointer for a process-local test. It is not a durable or multi-process store; do not present it as persistence.
Agent state machine and logs
Agent stores messages as an append-only AgentState field. The compiled
LangGraph starts at process, invokes the bound model, routes to execute if
the last response has tool calls, executes each call by registered name, then
returns to process. An unknown call name yields a ToolMessage containing
invalid tool, please retry; it is not executed. A response with no tool calls
ends the graph.
With log_tools=True (the initialize_agent default), log_dir defaults to
logs; the agent creates that directory and writes timestamped
tool_calls_YYYYMMDD_HHMMSS.json files containing tool_call_id, name,
args, content, and an ISO timestamp. Set log_tools=False for a no-log
synthetic test. Ensure log_dir exists or its parent is writable; avoid
sensitive arguments in logs and treat log files as sensitive operational data.
For API details, tool registry entries, prompt parsing, and failure recovery,
use the linked references rather than guessing parameter names. For a
source-independent construction path, import build_agent from
scripts/medrax_agent_factory.py; importing that module alone performs no model,
tool, or network operation. Its command-line default only prints safe help.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).