OpenProgram Docs

Function metadata

Each fact has one home. What the signature can say is not repeated in input; what input can say is not repeated in the docstring. Below, input.x means method_options[method]["input"]["x"].

FieldLives inRead as
Function namedef name(...)fn.__name__
Parameter names, types, defaultsSignatureinspect.signature(fn).parameters
One-line summary: what, when to pickDocstring, first paragraphinspect.getdoc(fn)
Instructions for one callThe prompt passed to that llm()At call time
Parameter descriptioninput.x.descriptionfn.input_meta["x"]["description"]
Enuminput.x.optionsfn.input_meta["x"]["options"]
Hidden from the LLMinput.x.hiddenfn.input_meta["x"]["hidden"]
WebUI placeholder, multilineinput.x.placeholder, input.x.multilinefn.input_meta["x"]
Dynamic optionsinput.x.options_from: "functions"fn.input_meta["x"]["options_from"]
Override the ambient system promptsystemfn.system
What callers see in their DAG render: "io", "llm", "full", "hidden"exposefn.expose
How much history this function's llm() calls readrender_rangefn.render_range
Skill trigger words, agent discoverySibling SKILL.md frontmatterSkill loader
from openprogram import Agent

class ExampleAgent(Agent):
    method_options = {
        'review_essay': {'tool': True, 'input': {
            'essay': {'description': 'Essay to review.', 'placeholder': 'Paste the essay text here...', 'multiline': True},
            'rubric_id': {'description': 'Which rubric to apply.', 'options': ['ielts_writing', 'toefl_writing', 'gre_argument']},
            'max_score': {'description': 'Upper bound for the numeric score.'},
            'show_rubric_internals': {'description': 'Include rubric breakdown in the output.'},
            'session_id': {'hidden': True},   # filled by Python via context, not the LLM
        }},
    }

    def review_essay(self, essay: str, rubric_id: str, max_score: int,
                     show_rubric_internals: bool, session_id: str) -> dict:
        """Score an essay against a named rubric and return a structured report."""
        ...

_example_agent = ExampleAgent()
review_essay = _example_agent.review_essay

The docstring keeps only the summary: no Args: or Returns:. Field meanings that matter downstream go in a TypedDict or dataclass return type.

Defaults

AspectDefault
expose"full" for ordinary methods; "io" for explicit tools (name, input and output; internal llm() calls hidden)
render_range.callersNone: nodes before this frame uncapped. 0 walls off all prior context. N: the most recent N.
render_range.subcalls-1: the frame sees all its own progress. Child internals are hidden by the child's expose. N caps prompt size in a long loop; 0 walls off in-frame nodes.
Top-level chat turnframe_entry_seq=-1: all nodes are in-frame, same code path as any frame
ToolsBare runtime.exec: full registry. tools=[...]: a menu. toolset="none" or tools=[]: none. Nested exec inherits (_current_tools).
systemNone: the runtime's existing system prompt

render_range counts nodes by seq.

Docstring and prompt

docstringllm(prompt)
ScopeThe whole functionOne model call; a function may make several
Read byHumans, decision menus, tool specs, meta tooling. Carried as metadata.doc and rendered as descriptive context.The model, as authoritative instruction
Must holdA one-line summary, stated directly. More detail is welcome. No filler such as "You are a helpful assistant", no role-play or metaphor.Instruction, data and the exact output format, even if the docstring says it too
llm([{"type": "text", "text": (
    f"Classify the sentiment of the following text. Reply with exactly one "
    f"word: positive, negative, or neutral.\n\nText:\n{text}"
)}])

Items are dicts such as {"type": "text", "text": ...} or {"type": "image", "path": ...}. The default system prompt comes from the ambient runtime and the skills block, not the docstring.

Who reads what

ConsumerNeeds
runtime.exec(tools=[fn])Name, description, parameter JSON schema
render_options(options)Name, when to pick, parameter name, type, description, enum, whether system-filled
parse_args(reply, options, ...)Parameter names, types, enum, hidden flag, auto-inject list
WebUI formdescription, placeholder, multiline, options, hidden
render_contextexpose, render_range
Trace and persistenceIdentity, arguments, return value, timing

Tool spec description falls back: description, then placeholder as "e.g. …", then name and type only. render_options reads only description and options. Neither reads a docstring Args: section, so legacy Args: runs but is dead text there.

Plain callables

Accepted by render_options, decision.make and choices=. runtime.exec(tools=[...]) takes only an Agent method, a {"spec", "execute"} dict or an object with .spec and .execute; anything else raises TypeError.

Agent methodPlain callable
Parameter descriptioninputEmpty
Enuminput.x.optionsNone
Hiddeninput.x.hiddenAuto-injected names only
Session DAGRecorded when it starts an executionNot recorded

Fine for simple branches with few parameters and no WebUI surface.

Auto-injected parameters

NameValue
runtimeThe current Runtime
exec_runtimeExecution Runtime in multi-runtime setups
review_runtimeReview Runtime in multi-runtime setups

Hidden from the LLM. New methods do not declare them: a method runs on its Agent's or the caller's Runtime; injection stays for existing functions. To add a name, edit both _RUNTIME_PARAMS in openprogram/runtime/agent/call_state.py and _AUTO_PARAMS in decision.py; do not use hidden per call site.

WebUI form controls

ParameterControl
boolYes and No buttons
str, multiline unsetTextarea
str, multiline: FalseSingle-line input
Other types, multiline unsetSingle-line input
optionsChips plus free text
options_from: "functions"Dropdown of registered non-builtin, non-meta functions
hidden: TrueOmitted
Python default, no placeholderDefault as ghost text; Tab in the empty field fills it. None and values starting with _ are suppressed.

description is a small label by the name, with the type on that row and an "optional" marker when not required. For a registered function the form uses its live input_meta; otherwise function_catalog.py parses the source, so only a literal input dict shows.

Tool registration and gating options

name, description, toolset, unsafe_in, requires_approval, check_fn, available_if, defer: see function-calling design. cache and cache_ttl memoize on name and arguments. timeout stops the body after N seconds with an error result.

Fields that do not exist yet

effects, permissions, idempotent, latency_hint and cost_hint are not implemented: no consumer exists. Gating already has its own options above.

Checklist for a new method

ItemRule
Function nameClear: the LLM sees it as the action name
DocstringOpens with a one-line summary; no Args: or Returns:
LLM-visible parametersEach has description
EnumsUse options, not description text
System-filled parametershidden: True
runtime parameterNone

Agent calls and methods · Tool calling · Next-step decision

Last updated · 2026-11-25