OpenProgram Docs

Fixed-order calls

An Agent method calls sub-methods in the order its source gives: survey, find gap, generate ideas; draft, review, revise; collect, clean, analyze.

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"                     # check between steps

        key_points = extract_key_points(survey)        # plain Python between steps
        filtered = [p for p in key_points if p["relevance"] > 0.5]

        gaps = identify_gaps(survey="\n".join(filtered))  # a Python variable carries the data
        ideas = generate_ideas(gaps=gaps)

        return llm(f"Gaps:\n{gaps}\n\nIdeas:\n{ideas}")  # optional model call

_example_agent = ExampleAgent()
survey_pipeline = _example_agent.survey_pipeline
survey_pipeline
├── survey_topic       ← step 1
├── identify_gaps      ← step 2
└── generate_ideas     ← step 3
Model calls
None (delete the llm line, return a dict), or any number of llm() calls, each a child node
Runtime
Sub-methods run on the calling method's Runtime; nothing passes it along
Fixed-orderLLM-chosen
Decides the orderPython codeThe LLM
Sub-functions runAll of themThe one chosen
Function registryNot requiredRequired
FlexibilityFixed flowVaries with the task
Last updated · 2026-11-25