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"].
| Field | Lives in | Read as |
|---|---|---|
| Function name | def name(...) | fn.__name__ |
| Parameter names, types, defaults | Signature | inspect.signature(fn).parameters |
| One-line summary: what, when to pick | Docstring, first paragraph | inspect.getdoc(fn) |
| Instructions for one call | The prompt passed to that llm() | At call time |
| Parameter description | input.x.description | fn.input_meta["x"]["description"] |
| Enum | input.x.options | fn.input_meta["x"]["options"] |
| Hidden from the LLM | input.x.hidden | fn.input_meta["x"]["hidden"] |
| WebUI placeholder, multiline | input.x.placeholder, input.x.multiline | fn.input_meta["x"] |
| Dynamic options | input.x.options_from: "functions" | fn.input_meta["x"]["options_from"] |
| Override the ambient system prompt | system | fn.system |
What callers see in their DAG render: "io", "llm", "full", "hidden" | expose | fn.expose |
How much history this function's llm() calls read | render_range | fn.render_range |
| Skill trigger words, agent discovery | Sibling SKILL.md frontmatter | Skill 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
| Aspect | Default |
|---|---|
expose | "full" for ordinary methods; "io" for explicit tools (name, input and output; internal llm() calls hidden) |
render_range.callers | None: 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 turn | frame_entry_seq=-1: all nodes are in-frame, same code path as any frame |
| Tools | Bare runtime.exec: full registry. tools=[...]: a menu. toolset="none" or tools=[]: none. Nested exec inherits (_current_tools). |
system | None: the runtime's existing system prompt |
render_range counts nodes by seq.
Docstring and prompt
| docstring | llm(prompt) | |
|---|---|---|
| Scope | The whole function | One model call; a function may make several |
| Read by | Humans, decision menus, tool specs, meta tooling. Carried as metadata.doc and rendered as descriptive context. | The model, as authoritative instruction |
| Must hold | A 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
| Consumer | Needs |
|---|---|
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 form | description, placeholder, multiline, options, hidden |
render_context | expose, render_range |
| Trace and persistence | Identity, 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 method | Plain callable | |
|---|---|---|
| Parameter description | input | Empty |
| Enum | input.x.options | None |
| Hidden | input.x.hidden | Auto-injected names only |
| Session DAG | Recorded when it starts an execution | Not recorded |
Fine for simple branches with few parameters and no WebUI surface.
Auto-injected parameters
| Name | Value |
|---|---|
runtime | The current Runtime |
exec_runtime | Execution Runtime in multi-runtime setups |
review_runtime | Review 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
| Parameter | Control |
|---|---|
bool | Yes and No buttons |
str, multiline unset | Textarea |
str, multiline: False | Single-line input |
Other types, multiline unset | Single-line input |
options | Chips plus free text |
options_from: "functions" | Dropdown of registered non-builtin, non-meta functions |
hidden: True | Omitted |
Python default, no placeholder | Default 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
| Item | Rule |
|---|---|
| Function name | Clear: the LLM sees it as the action name |
| Docstring | Opens with a one-line summary; no Args: or Returns: |
| LLM-visible parameters | Each has description |
| Enums | Use options, not description text |
| System-filled parameters | hidden: True |
runtime parameter | None |
Agent calls and methods · Tool calling · Next-step decision