OpenProgram Docs

Fixed-order calls

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

class ExampleAgent(Agent):
    method_options = {
        'survey_pipeline': {'tool': True, 'input': {'task': {'description': 'Research topic.'}}},
    }

    def survey_pipeline(self, task: str) -> dict:
        """Run the full research pipeline: survey, find gaps, generate ideas."""
        survey = survey_topic(topic=task)
        gaps = identify_gaps(survey=survey)
        ideas = generate_ideas(gaps=gaps)

        return {"survey": survey, "gaps": gaps, "ideas": ideas}

        # Or summarise with one model call instead:
        # return llm([{"type": "text", "text": f"Survey:\n{survey}\n\nGaps:\n{gaps}\n\nIdeas:\n{ideas}"}])

_example_agent = ExampleAgent()
survey_pipeline = _example_agent.survey_pipeline

Survey, gaps, ideas. Also: draft, review, revise; collect, clean, analyze.

PointRule
llm()Optional, any number of calls in one function, mixed with any number of Agent method calls
DataPlain Python variables: one return value is the next argument
RuntimeSub-methods run on the caller's; no runtime argument between steps

Python between steps

survey = survey_topic(topic=task)

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

gaps = identify_gaps(survey="\n".join(filtered))

Session DAG

CallRecorded as
The method that starts the executionOne node
Each llm() or model requestOne child node, caller pointing at that method
Helper or method on the same AgentNo node of its own; shares the active call
Another AgentIts own DAG; the parent stores the result and a child_session_id reference

Errors

try:
    survey = survey_topic(topic=task)
except Exception as e:
    return {"error": f"Survey failed: {e}"}

A raised exception reaches the orchestrator; a recorded call's node ends with status='error'.

A sub-function that returns an error string
survey = survey_topic(topic=task)
if not survey or "error" in survey.lower():
    return {"error": "Survey failed", "survey": survey}

Versus LLM-selected calls

Fixed orderTool calling or decision
Order decided byPythonThe LLM
Sub-functions runAll of themTool loop: many, across rounds. Decision menu: one.
FlexibilityFixed pipelineVaries with the task
Last updated · 2026-11-25