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.
| Point | Rule |
|---|---|
llm() | Optional, any number of calls in one function, mixed with any number of Agent method calls |
| Data | Plain Python variables: one return value is the next argument |
| Runtime | Sub-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
| Call | Recorded as |
|---|---|
| The method that starts the execution | One node |
Each llm() or model request | One child node, caller pointing at that method |
| Helper or method on the same Agent | No node of its own; shares the active call |
| Another Agent | Its 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 order | Tool calling or decision | |
|---|---|---|
| Order decided by | Python | The LLM |
| Sub-functions run | All of them | Tool loop: many, across rounds. Decision menu: one. |
| Flexibility | Fixed pipeline | Varies with the task |
Last updated · 2026-11-25