SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2510.10454 · NeurIPS · 2025

Traj-CoA: Patient Trajectory Modeling via Chain-of-Agents for Lung Cancer Risk Prediction

Liu, Sihang Zeng, Matthew Thompson, Yujuan Fu, Sitong Zhou, Zixuan Yu, Jing Lucas, Jun Wen, Ruth Etzioni, Meliha Yetisgen

arXiv · PDF · Open in the Atlas

Code that ran

9 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 8 failures of our instrument; 0 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2510.10454.json · badge: /api/ran/2510.10454.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
zengsihang/Traj-CoA canonical (classifier label)
classifier basis: census
9 ran · 0 no recorded run
FunctionStatusWhere it lives
estimate_tokens Ran
ran, honoured the contract we drafted
zengsihang/Traj-CoA/model/run_coa_batch.py
code served (permissive licence) · get_code("1da8decd4ccf7a5e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

CHARS_PER_TOKEN_ESTIMATE = 4

def estimate_tokens(text: str) -> int:
    """Rough token estimate for medical XML text."""
    return len(text) // CHARS_PER_TOKEN_ESTIMATE

# Create a sample medical XML text for testing
sample_text = """<?xml version="1.0"?>
<medical_record>
    <patient>
        <name>John Doe</name>
        <diagnosis>Hypertension</diagnosis>
        <treatment>Medication prescribed</treatment>
    </patient>
</medical_record>"""

ARGS = {
    "text": sample_text
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_events_from_output Ran
ran; our contract draft was wrong, not the code
zengsihang/Traj-CoA/model/run_coa_batch.py
code served (permissive licence) · get_code("8cf2db605520bf6e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
from typing import Any, Dict, List, Optional

# Test case 1: Valid JSON string with risk_factors_or_clinical_events
valid_json_string = json.dumps({
    "risk_factors_or_clinical_events": [
        {"timestamp": "2024-01-15", "event": "hypertension"},
        {"timestamp": "2024-01-20", "event": "diabetes"}
    ]
})

# Test case 2: Dict object with new_risk_factors_or_clinical_events
dict_with_new_events = {
    "new_risk_factors_or_clinical_events": [
        {"timestamp": "2024-02-01", "event": "chest_pain"},
        {"timestamp": "2024-02-05", "event": "arrhythmia"}
    ]
}

# Test case 3: Dict with both keys (should use risk_factors_or_clinical_events first)
dict_with_both = {
    "risk_factors_or_clinical_events": [
        {"timestamp": "2024-03-01", "event": "stroke"}
    ],
    "new_risk_factors_or_clinical_events": [
        {"timestamp": "2024-03-05", "event": "ignored"}
    ]
}

# Test case 4: Dict with no events key (should return empty list)
dict_no_events = {"other_data": "value"}

# Test case 5: Invalid JSON string (should return empty list)
invalid_json_string = "{invalid json"

# Test case 6: Non-dict output (should return empty list)
non_dict_output = ["not", "a", "dict"]

# Test case 7: Dict with malformed events (missing timestamp or event key)
dict_malformed_events = {
    "risk_factors_or_clinical_events": [
        {"timestamp": "2024-04-01"},  # missing event
        {"event": "fever"},  # missing timestamp
        {"timestamp": "2024-04-05", "event": "valid_event"}
    ]
}

# Use the valid JSON string as the primary test case
ARGS = {
    "output_obj": valid_json_string
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
format_memory_events_for_prompt Ran
ran; our contract draft was wrong, not the code
zengsihang/Traj-CoA/model/run_coa_batch.py
code served (permissive licence) · get_code("e9a99541a0e45a7d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import Any, Dict, List, Sequence

torch.manual_seed(0)

# Create sample memory events
events = [
    {
        'timestamp': '2024-01-15 10:30:45',
        'event': 'User asked about weather forecast'
    },
    {
        'timestamp': '2024-01-15 10:31:12',
        'event': 'System provided rain prediction for next week'
    },
    {
        'timestamp': '2024-01-15 10:32:00',
        'event': 'User requested temperature data'
    }
]

ARGS = {
    'events': events
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_aggregation_agent_system_prompt Ran
ran; our contract draft was wrong, not the code
zengsihang/Traj-CoA/model/prompts.py
code served (permissive licence) · get_code("6e051628dca6115c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    'years': 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_initial_worker_system_prompt Ran
ran; our contract draft was wrong, not the code
zengsihang/Traj-CoA/model/prompts.py
code served (permissive licence) · get_code("590a682fb3ba3aee")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Setup code for get_initial_worker_system_prompt

ARGS = {
    'years': 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_subsequent_worker_system_prompt Ran
ran; our contract draft was wrong, not the code
zengsihang/Traj-CoA/model/prompts.py
code served (permissive licence) · get_code("0d41d24905cd02f3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

def _format_year_text(years: int) -> str:
    """Return a human-readable prediction window string."""
    return 'one year' if years == 1 else f'{years} years'

def get_subsequent_worker_system_prompt(years: int=1) -> str:
    """Return the system prompt for subsequent chunk-processing workers."""
    year_text = _format_year_text(years)
    return f"""\nYou are an expert clinical AI assistant specializing in lung cancer risk assessment from longitudinal EHR data. You are answering the question of "How likely is this patient to develop lung cancer within {year_text}?" based on the provided EHR data chunk and previous clinical summary.\n\n**Task:** Analyze a new chunk of a patient's EHR data, considering the previous clinical summary, risk assessment, and the universal memory of lung-cancer-related events. Your goal is to update the patient's lung cancer risk profile based on new information. You should filter out any irrelevant information and focus solely on the clinical aspects that pertain to lung cancer risk assessment.\n\n**Input:**\n- `previous_summary`: A JSON object from the previous agent containing the summary, lung-cancer-related events, and risk assessment up to this point.\n- `memory_events`: A list of the last 10 lung-cancer-related events from the universal memory, providing historical context across all processed chunks.\n- `new_chunk_xml`: A string containing the next segment of the patient's EHR data.\n\n**Instructions:**\n1.  **Update the Summary:** Briefly summarize the key clinical information from the new data chunk and aggregate it with the previous summary. Include timestamps for the key clinical information so the summary remains comprehensive and temporally grounded.\n2.  **Identify Risk Factors or Clinical Events:** List any new lung-cancer-related risk factors or clinical events, such as risk factors, symptoms, abnormal lab results, findings, or procedures.\n3.  **Analyze Temporal Patterns and Status Changes:** Describe any significant clinical changes or temporal trends observed between the previous data and this new chunk, such as disease progression or treatment initiation.\n4.  **Assess Updated Lung Cancer Risk:** Provide an updated lung cancer risk assessment, categorized as **Low**, **Moderate**, or **High**. The reasoning should clearly connect the new information, memory events, and temporal patterns to the change, or lack of change, in risk.\n\n**Output Format:**\nYour output must be a single, easily parsable JSON object with the following keys:\n- `updated_summary`: A string with the summary of the entire clinical information so far. The summary should be concise but detailed and include timestamps for key information.\n- `new_risk_factors_or_clinical_events`: A list of JSON objects detailing the new lung-cancer-related risk factors or clinical events that are not already in memory.\n    - `timestamp`: The timestamp of the event.\n    - `event`: A detailed description of the event and how it may be related to lung cancer.\n- `temporal_analysis`: A string describing clinical changes and temporal patterns so far.\n- `updated_risk_assessment`: A JSON object for the updated risk level for lung cancer diagnosis within {year_text} (`Low`, `Moderate`, or `High`).\n    - `risk_level`: The updated risk level for lung cancer diagnosis within {year_text} (`Low`, `Moderate`, or `High`).\n    - `reasoning`: A string explaining the rationale for the updated risk assessment.\n\nONLY output the JSON object without any additional text or formatting. Ensure that the JSON is valid and easy to parse.\n"""

ARGS = {
    "years": 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
resolve_input_path Ran
ran; our contract draft was wrong, not the code
zengsihang/Traj-CoA/data_preprocess/convert_to_xml.py
code served (permissive licence) · get_code("8eea02173d3edde5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned PosixPath. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import argparse
from pathlib import Path

# Create an argparse.Namespace object with the required attributes
args = argparse.Namespace(
    input_file=None,  # When None, the function will use the constructed path
    data_dir='/tmp/data',
    year=2023,
    data_type='clinical',
    seed=42
)

ARGS = {'args': args}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PosixPath — a PosixPath output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PosixPath output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
resolve_output_path Ran
ran; our contract draft was wrong, not the code
zengsihang/Traj-CoA/data_preprocess/convert_to_xml.py
code served (permissive licence) · get_code("dc756cf7c184c533")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned PosixPath. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import argparse
from pathlib import Path

# Create an argparse.Namespace object with all required attributes
args = argparse.Namespace(
    output_file=None,
    full=False,
    sample_size=100,
    data_dir='/tmp/data',
    year=2023,
    data_type='clinical',
    seed=42
)

ARGS = {'args': args}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PosixPath — a PosixPath output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PosixPath output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sample_patients Ran
ran; our contract draft was wrong, not the code
zengsihang/Traj-CoA/data_preprocess/convert_to_xml.py
code served (permissive licence) · get_code("f299c54022365805")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random
from typing import Any, Dict

# Create a sample patient data dictionary
# The function expects Dict[str, Dict[str, Any]]
# where outer keys are patient IDs and values are patient data dictionaries

patient_data = {
    "patient_001": {
        "age": 45,
        "condition": "diabetes",
        "measurements": [120, 80, 100],
        "visits": 5
    },
    "patient_002": {
        "age": 67,
        "condition": "hypertension",
        "measurements": [140, 90, 110],
        "visits": 8
    },
    "patient_003": {
        "age": 34,
        "condition": "asthma",
        "measurements": [118, 78, 95],
        "visits": 3
    },
    "patient_004": {
        "age": 52,
        "condition": "copd",
        "measurements": [125, 85, 105],
        "visits": 6
    },
    "patient_005": {
        "age": 71,
        "condition": "heart_disease",
        "measurements": [135, 88, 108],
        "visits": 10
    },
}

ARGS = {
    "data": patient_data,
    "sample_size": 3,
    "sample_seed": 42,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 9 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Large language models (LLMs) offer a generalizable approach for modeling patient trajectories, but suffer from the long and noisy nature of electronic health records (EHR) data in temporal reasoning. To address these challenges, we introduce Traj-CoA, a multi-agent system involving chain-of-agents for patient trajectory modeling. Traj-CoA employs a chain of worker agents to process EHR data in manageable chunks sequentially, distilling critical events into a shared long-term memory module, EHRMem, to reduce noise and preserve a comprehensive timeline. A final manager agent synthesizes the worker agents' summary and the extracted timeline in EHRMem to make predictions. In a zero-shot one-year lung cancer risk prediction task based on five-year EHR data, Traj-CoA outperforms baselines of four categories. Analysis reveals that Traj-CoA exhibits clinically aligned temporal reasoning, establishing it as a promisingly robust and generalizable approach for modeling complex patient trajectories. Implementation of Traj-CoA is available on https://github.com/zengsihang/Traj-CoA.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2510.10454")
get_code_for_paper("2510.10454")
have("2510.10454")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2510.10454.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2510.10454.svg)](https://syntology.ai/paper/2510.10454)

Connect an agent — have() is free.