Programs code structure
Everything the Agent can call is a Program.
Directory layout
openprogram/
├── runtime/agent/
│ ├── llm.py # llm(): one model call
│ ├── agent_function.py # agent(): model tool-call loop
│ └── agent_class.py # Agent: named roles with methods
└── programs/
├── __init__.py # TOOLSETS, DEFAULT_TOOLS, agent_tools, apply_tool_policy
├── tools/ # always given to the Agent
│ ├── files/ code/ web/ interaction/ knowledge/ jobs/
│ ├── agents/ computer_use/ runtime/ system/
│ └── planning/ # todo/ plan_mode/ open_work/ goal/
├── applications/ # each enabled or disabled as a unit
│ ├── browser/ # tabs and Pages
│ ├── meeting/ # records, transcribes and summarizes calls
│ ├── workflow_recording/ # the demonstration recorder
│ └── office_editor/ # the ONLYOFFICE document editor
├── _authoring/ # imported by Program code: application_client,
│ # json_parsing, reports/, helpers ...
└── _host/ # loads and runs Programs; Program code never imports it
├── runtime.py # @function and the shared tool registry
├── context.py # ProgramContext, one per owner
├── registry.py # loader for built-in, user and harness Programs
└── packages.py sources.py execution.py services.py ui/ ...
~/.openprogram/programs/<name>/ # Python packages, applications, harness clones
Each capability has one implementation and one public import path. No functions/, workflows/ or packages/ under programs/, and no aliases for old paths.
Where a Program comes from
| Source | Holds | Loads |
|---|---|---|
Built-in toolsprograms/tools/ | Files, shell, search, planning, asking the user, memory, jobs, web, computer use | Always, and cannot be disabled one by one. Most through @function on import; a package with PROGRAM_ENTRIES through a ProgramContext owned by tool:<name> |
Built-in applicationsprograms/applications/ | browser, workflow_recording, office_editor, each providing the named service the core reaches it through; meeting, an application package that reaches the host only through capabilities (Meetings) | Only while enabled (openprogram programs enable|disable <name> or the Applications page). Context owner application:<name> |
User Programs~/.openprogram/programs/ | Packages listing PROGRAM_ENTRIES, directories with application.json, harness clones recorded by openprogram programs install | Through the same contexts. Package contract: Workflows |
Portable package sources
Project-local Programs record locations as relative paths scoped by programs, never relative to the chat working directory. An external installation binding connects the installed runtime to the source checkout. Only exact authorized package names join Python resolution, not the whole external directory. Rejection and publishing rules: Workflow package contract.
Primitives and Workflows
| Entry | Meaning | Location |
|---|---|---|
llm() | One model call, structured output, no tool loop | runtime/agent/llm.py |
agent() | Multi-round model tool-call loop | runtime/agent/agent_function.py |
Agent | Named role whose methods run model calls and can be offered as tools | runtime/agent/agent_class.py |
goal() | Starts a chat Goal. Session state, not a primitive | programs/tools/planning/goal/ |
A Workflow is ordinary Python that defines flow, state and acceptance by calling these and other Programs. Anything that makes model calls, calls other Workflows, or keeps multi-stage state and completion checks is a Workflow, including a single model call wrapped in a role.
Goal runs as ordinary chat turns
| Aspect | Rule |
|---|---|
| One mechanism | Session state in planning/goal/. After each successful chat turn, chat.py decides whether to start another for the active Goal. No separate Goal loop, judge Workflow or nested working agent. |
| Programs form | goal(prompt) takes only the objective, saves a chat Goal in the current conversation; the route starts the first turn through the same controls as /goal. |
| Chat and Agent | /goal <objective> and the create_goal tool create the same Goal. The goal Program is never offered to agents as a tool. |
| Completion | update_goal(status="complete") or a finished todo plan only submits a candidate. verification.py runs one independent read-only verification turn before the Goal is achieved. |
| Limits | No round limit. Two automatic turns in a row without a tool call stop it as stalled. Optional token, active-time and cost limits are the only budgets. |
| Restart | A Goal whose lease belonged to a previous worker comes back paused with a resume action (restart.py). |
File or directory
| Form | When | Example |
|---|---|---|
Single .py | One public entry and a few local helpers; readable on its own | tools/files/edit.py |
| Same-name package | Several modules with distinct responsibilities, resource files or session adapters | tools/planning/goal/, applications/browser/ |
Internal directory, _ prefix | Shared implementation serving only its neighbours; never a Programs UI node | programs/_authoring/, programs/_host/ |
File count and responsibility boundaries decide a split, not uniformity.
Permitted dependencies
| Caller | Allowed | Forbidden |
|---|---|---|
| Tool | Standard library, approved dependencies, deterministic helpers | llm(), agent(), Workflows, Applications |
| Workflow | Tools, its own roles, other Workflows without cycles | Depending on Applications, copying other Workflows, dispatch by string name |
| Application | Public Tools and Workflows, its own UI and services | Modifying the called Program or keeping a second implementation |
| Program code | programs/_authoring/ and the public runtime API | programs/_host/ |
Registration and Programs UI
| Aspect | Rule |
|---|---|
| Registration | _host/registry.py loads built-in tools, enabled built-in applications, the user's Programs and recorded harnesses. Each package registers through its own ProgramContext, kept by owner (tool:<name>, application:<name>, the package's name, external:<package>). Unloading or reloading disposes it and everything it added. |
| Programs tree | Mirrors source directories only. A registered entry is runnable and shows Use. Expanding a same-name package lists its modules from the actual directory (goal/command.py), readable but not extra Programs. __init__.py and _ directories never become nodes. |
| Stable contract | Moving source does not change public names, parameter schemas, permissions, DAG semantics or session state formats. Old paths fail directly: no aliases, no dual scanning. |
Excluded
- No
@workflowdecorator; directories and metadata express classification. - No
call_workflow(name); Workflows use ordinary Python imports and calls. - No versioned old and new directories, and no runtime choice between them.
Dynamic tool argument mappings
Canonical schemas distinguish mappings whose keys arrive at invocation time from objects with declared fields.
| Canonical object | Local validation | Provider tool mode |
|---|---|---|
Anonymous mapping, Python dict or Mapping | Accepts dynamic keys; enforces object and declared value types | Mapping schema, non-strict |
Declared fields, even an empty set, or explicit additionalProperties: false | Required fields, types, closed-field rejection. Never opened. | Strict where supported |
| Request with both kinds | Each call against its own schema | Mode per tool; strict is never disabled request-wide |
program.argsaccepts a registered program's legal keyword arguments, includingtask. Nullable mappings keep their null behavior.models/providers/schema/strict.pyrefuses to make a schema with dynamic keys strict, so an open mapping never becomes an empty closed object.- OpenAI strict mode needs closed objects: dynamic-mapping tools send
strict: falseon Responses, Codex and Chat Completions; fixed-field tools stay strict. - Anthropic is per tool too: mapping tools keep the ordinary input schema without the strict flag.
- The fixed
execute_codeschema stays strict.
Implementation status: everything on this page is implemented.