name: book_research
description: "Research trends and context for a book -- live search + synthesis + documented findings."
debug: true
rag_exclude: [business_plan, charter]
system: agent_prompt

agent_prompt:
  - "= identity.md"
  - "agent.rag.json"

sections:
  - agent
  - project
  - history
  - rag
  - prior_results
  - message
  - instructions

builders:
  prior_results: |
    *** WEB SEARCH RESULTS ***
    {steps[1].text}

    (If the above is empty, use your expert training knowledge to answer this question.)

steps:
  - type: think
    hint: |
      You are researching the current fiction landscape for this book project.

      GENRE: {genre_name|[infer from the project description above]}
      TARGET AUDIENCE: {genre_audience|[infer from the project description above]}
      RESEARCH FOCUS: {research_focus|[infer: what trends, tropes, and reader expectations matter most for this project?]}

      NOTE: If GENRE, TARGET AUDIENCE, or RESEARCH FOCUS are blank above, read the
      PROJECT DESCRIPTION section and infer them from the project's stated goal.

      Your mission: identify the single best search query to find what's TRENDING RIGHT NOW
      in this fiction genre in 2025-2026.

      State your analysis, then on the last line write:
      SEARCH QUERY: [your query here]

      Query rules: 3-8 words. Specific.

  - type: tool
    capability: Tool_WebSearcher
    input_from: last_text
    optional: true

  - type: think
    hint: |
      You have live search results above (in PRIOR RESULTS).
      If the web search results are empty or unavailable, use your expert training knowledge.

      Infer the GENRE and AUDIENCE from the PROJECT DESCRIPTION if not explicitly provided above.

      Synthesize the findings into an actionable publishing brief for this book:

      1. TOP TRENDING -- What sub-genres and themes are hot right now? Rank them.
      2. AUDIENCE INSIGHTS -- What does the target reader ({genre_audience}) demand?
      3. STORY MECHANICS -- What structural patterns are winning?
      4. HOT TOPIC RECOMMENDATIONS -- Give 3 distinct book concept seeds, each with:
         - Working title
         - Core hook (one sentence)
         - Protagonist archetype
         - Central conflict
         - Why it will resonate now
      5. COMPETITIVE GAPS -- Where is the market undersupplied?
      6. SOURCES -- Key URLs or references.

  - type: document
    filename: "{{task_name_slug}}"

  - type: spawn
    task_type: book_outline
    task_name: "Book Outline: {project.name}"
    message: "{task.message}"

  - type: close
    rag_update: true

adjudication:
  enabled: true
  pass_threshold: 65
  deliverable_type: coordination
  criteria:
    accuracy:
      weight: 35
      description: "Facts are correct and verifiable"
    thoroughness:
      weight: 30
      description: "Topic covered in sufficient depth"
    source_quality:
      weight: 20
      description: "Sources are credible and relevant"
    organization:
      weight: 15
      description: "Findings are well-structured"
