# 固定顺序调用

Agent 方法按源码写定的顺序调用子方法：调研、找 gap、生成想法；写初稿、审稿、修改；采集、清洗、分析。

```
from openprogram import Agent
from openprogram.runtime.agent import llm

class ExampleAgent(Agent):
    method_options = {'survey_pipeline': {'tool': True}}

    def survey_pipeline(self, task: str) -> str:
        survey = survey_topic(topic=task)
        if not survey or "error" in survey.lower():
            return "Survey failed"                     # 步骤之间的检查

        key_points = extract_key_points(survey)        # 步骤之间的普通 Python
        filtered = [p for p in key_points if p["relevance"] > 0.5]

        gaps = identify_gaps(survey="\n".join(filtered))  # 数据由 Python 变量传递
        ideas = generate_ideas(gaps=gaps)

        return llm(f"Gaps:\n{gaps}\n\nIdeas:\n{ideas}")  # 可选的模型调用

_example_agent = ExampleAgent()
survey_pipeline = _example_agent.survey_pipeline
```

```
survey_pipeline
├── survey_topic       ← 第 1 步
├── identify_gaps      ← 第 2 步
└── generate_ideas     ← 第 3 步
```

- **模型调用**: 不调用（删掉 `llm` 那行，返回 dict），或调用任意次 `llm()`，每次一个子节点
- **Runtime**: 子方法跑在调用方的 Runtime 上，无需逐层传递

|  | 固定顺序 | LLM 选择 |
| --- | --- | --- |
| 谁决定顺序 | Python 代码 | LLM |
| 运行哪些子函数 | 全部 | 被选中的一个 |
| 函数注册表 | 不需要 | 需要 |
| 灵活度 | 流程固定 | 随任务变化 |
