# 科研流水线 Demo — 可端到端运行（plan → literature），全部本地 ollama。
# rule gate + llm_judge gate 各一，验证产物 gate 逐级验收闭环。
# 运行：run_pipeline("agentexample/pipelines/research-demo.yml", "<研究方向>", agent_dir)
pipeline:
  id: research-demo
  name: 科研流水线 Demo (plan→lit)
  defaults:
    on_fail: halt

  stages:
    - id: plan
      name: 研究计划
      agent:
        type: simple
        model: {provider: ollama, name: qwen2.5:7b, temperature: 0.2, maxTokens: 600}
        systemPrompt: |
          You are a research planner. Given a topic, write a concise research plan
          (<= 200 words) that EXPLICITLY states a research hypothesis using the word
          "hypothesis". Plain prose only.
      produces:
        - {name: plan.md, type: md, path: "final/plan.md", required: true}
      gate:
        kind: rule
        rule: 'regex("plan.md", "(?i)hypothesis")'

    - id: lit
      name: 文献综述
      consumes: [plan]
      agent:
        type: simple
        model: {provider: ollama, name: qwen2.5:7b, temperature: 0.3, maxTokens: 700}
        systemPrompt: |
          You are a literature reviewer. Based on the given research plan (provided
          under UPSTREAM ARTIFACTS), write a short related-work survey (<= 250 words)
          discussing prior approaches relevant to the plan.
      produces:
        - {name: survey.md, type: md, path: "final/survey.md", required: true}
      gate:
        kind: llm_judge
        judge:
          model: {provider: ollama, name: qwen2.5:7b}
          rubric: >
            The text is a literature / related-work survey that discusses prior
            approaches or references relevant to a research plan — not off-topic text.
          threshold: 0.5
