OpenProgram Docs

Direct calls, Agent classes and automatic DAG context

NameDefines
AgentReusable model configuration. Owns no default conversation
ContextParent, named content, dynamic providers, history visibility. Built by the framework; applications need not construct one
Reused unchangedRuntime, AgentSpec, tool policy, execution control, Session DAG

Usage

from openprogram import agent
answer = agent("Analyze this paper", model="configured-model")

Uses the current execution session, or opens one independent execution.

from openprogram import Agent
bot = Agent(model="configured-model")
first = bot("Investigate this topic")
second = bot(first)

Reuses configuration, not history: execution scope decides continuity, and independent top-level calls share none.

class Researcher(Agent):
    model = "configured-model"
    def research(self, question):
        text = self.prepare(question)
        return self(text)
    def prepare(self, text):
        return text.strip()
result = Researcher().research("A topic")

No per-method decorators. research is an entry, prepare an unrecorded helper.

EntryRule
agent(), Agent.__call__Synchronous. Both delegate to one internal execution function
await bot.arun(...), await agent_async(...)For calls inside an active event loop
ConstructionResolves configuration only: no model request, no persistent session. The first execution resolves the session
Global stateNo process-global default Bot stores history

Context lifecycle

TriggerRule
Program or top-level entryEstablish a scope, bind its Context; inherit an ambient session and explicit branch
Function or method entryDerive a scope with ancestry and visibility rules; history is not copied
Before each model requestResolve DAG sources, instance content, dynamic content, call overrides; select, deduplicate, budget
Model returnUpdate execution state, visible to later construction by the rules
Return, error, cancellationRestore the parent. Completed interactions follow expose and render_range; children are not merged unconditionally
Top-level exitUnbind task-local state, close owned resources
RelationDetermines
Invocation ancestryInheritance and visibility
PredecessorConversation order
Each Agent executionOwns its DAG. Records user messages, model requests, directly dispatched tools; ordinary helpers create no durable nodes
Calling another AgentIndependent DAG; the parent stores the result and a child_session_id
Permission, cancellation, file checkpointsStay with the originating execution, whatever owns the graph

Context is a runtime construction object; complete intermediate values are neither copied nor persisted. Session persistence and Trace export stay separate.

One Context model

parent Context + Agent configuration + call content
    → derive current Context
    → evaluate named content and select visible DAG interactions
    → apply existing budget and compaction
    → Runtime.exec model request
PartBehavior
ParentA child inherits the current Context; scope exit restores the parent
ContentNamed instructions and business data. A child overrides a name without touching its parent. Instance binding is this, attached when the invocation derives its Context
EvaluationPython providers receive the current Context and run during request construction. Expression strings are not evaluated
VisibilitySession DAG rules select interactions by branch, call scope, expose, render_range
  • History selection and content replacement are separate. Equal text does not identify the same interaction; selected DAG identities are recorded at the actual request.
  • No second history database or provider runtime. Tool authorization is independent of history visibility.
APIBehavior
Context.current()Current binding
Context.derive()Child Context
bind()Publishes the task context and explicit writer, rejects a conflicting ambient writer, restores on exit
Context(store=writer, head_id=None)Binds an existing SessionNodeWriter for repeated calls: NOOA-style instance event lifetime, made explicit. head_id picks a branch tip, default the session head. The caller owns the store

Ordinary function capture

def research(question):
    data = prepare(question)
    return analyze(data)
def prepare(question):
    return question.strip()
def analyze(data):
    return agent(data)
CodeTreatment
Registered Program sourcesThe managed loader keeps Runtime injection and entry adaptation; helpers get lightweight scopes with no per-call persistence
Agent methods, including _ helpersAutomatic scopes; neither append DAG nodes nor become tools. Instance, static and class methods follow Agent ownership
Host files, dependencies, lambdas, generated code, unavailable sourceNo capture. agent() still works; Python ancestry is not persisted
AllSignatures, returns, exceptions, imports keep Python semantics. Entry registration and tool exposure stay explicit. Generator creation records no completed call

Configuration and authority

SettingOwnership
model, effort, instructions, toolsCall override → instance → class default → ambient session → product default. Omission differs from an explicit empty value
expose, render_rangeExisting defaults; method_options or explicit metadata sets them
Tool visibility, approvalSeparate from DAG visibility. Inner configuration cannot expand outer authority
AgentSpec, sessionSaved Bots reuse AgentSpec. A Python object creates no sidebar Bot or schedule

Default construction needs model interactions and call relationships, not ordinary arguments or locals. Explicit content is bounded; self is represented by identity or type; method names are qualified by module and class. Call recording does not approve arbitrary Python effects; the sandbox still governs them.

Concurrency and failure

  • Current Context, call identity and effective configuration bind per task and restore on exit. Inheritance copies no history or mutable branch configuration. Nested reentry is allowed.
  • Shared Agent configuration does not imply shared history. Mutable instance content and shared sessions need defined synchronization.
  • Errors, timeouts and cancellation restore the parent and keep completed interactions. Recovery uses safe points and explicit steps, never arbitrary Python stacks. Standalone calls reuse permission context and non-interactive approval rules.
  • Without an outer execution, the entry owns an environment and releases it on exit.
  • Resumable functions keep one durable node ID across call and continuation; provider tool-call identity stays in node metadata.

Implementation contract

PartWhere and how
Public entriesAgent, Context, agent, agent_async
Contextopenprogram/runtime/context/model.py
Agentopenprogram/runtime/agent/agent_class.py
CallScopeopenprogram/runtime/agent/call_scope.py. Separates recorded operations from lightweight functions. Handles explicit metadata and automatic scopes
History selectionopenprogram/runtime/agent/runtime/history.py
Managed loadingopenprogram/programs/_host/source_loader.py, _registry in programs/_host/runtime.py
Internal call stateopenprogram/runtime/agent/call_state.py
RequestsRuntime.exec, existing providers, authorization, budgets, compaction
English interface textASD-STE100 sentence structure, consistent terms

No function decorator

  • The removed public decorator has no adapter or replacement. Agent.method_options keeps input metadata, Runtime injection, registration and schemas, availability, permissions, visibility, retry, execution controls and explicit-step recovery.
  • Managed sources declare PROGRAM_ENTRIES and __agent_options__. Methods carry _is_agent_method. Stored node schemas and history stay readable.
  • First-party workflows, generated programs, scanners and dispatchers use ordinary Agent classes.
  • Harness packages migrate in their own repositories and keep their agentics paths; the runtime bundles none. Six locally published workflows migrated in isolation, which is no upstream release.
Behavior-test host and cancellation display
  • The host initializes the standard SessionStore before the OS sandbox. The runner binds its SessionNodeWriter through Context and Agent calls reuse it. Candidate tests cannot spawn processes, write the source snapshot, read host secrets or use the network.
  • Cancellation closes the canonical execution; unresolved external effects stay inspectable.
  • The assistant projection retries through the durable DAG outbox when its node or storage is unavailable. A display failure does not reject an applied cancellation.
  • Cancelling a paused continuation error replaces its error display with cancelled, clears error metadata and keeps content.
  • Resource-release observer failures stay visible to the control caller. Normal Job completion keeps its result-bearing projection owner; cancellation notifications do not publish other terminal Job rows before it supplies result and error fields.
Acceptance
ScenarioObservable result
Non-model parentCorrect research → prepare, analyze → agent scopes; attributable model inputs, outputs, failures
Inheritance and evaluationParent inheritance, instance blocks, per-request dynamic refresh, override order, deduplication that keeps distinct repeated interactions
EquivalenceSame history for old and new entries with the same DAG, branch, policy; provenance recorded at actual requests
Session lifetimeNo constructor effects; same instance in unrelated tasks isolated; different Agents in one task share permitted context; existing sessions need explicit continuation
Budget and compactionExisting compaction with provenance; summary usage metered; failures do not drop history
Concurrency and resourcesSibling isolation, explicit policy for shared instance state, reentry, parent restoration, owner-only cleanup
Loading and identityAuthorized sources only; recursion and import aliases keep records; same-name methods do not collide; metadata does not duplicate nodes
Policy and displayRecording exposes no tool; deny before effects; standalone entries enforce policy; the default App shows function, model and tool calls and terminal state

Also covers conversation projections, Goal lifecycle, cancellation, recovery and shipped Programs. Recording keeps DAG relationships without changing content, ownership or authority. Checks are the smallest affected set.

Relationship to NOOA

AreaChoice
Classes and methodsAdopt class declarations, ordinary calls, framework-managed methods
Context modelingAdopt class-based instance content, dynamic resolution, scoped overrides; add DAG sources. Effective context belongs to execution scope
History filteringNOOA filters by call_id with nested policy inheritance. OpenProgram keeps DAG branch and frame rules
Trace and model contextNOOA separates events and traces. OpenProgram keeps one DAG with distinct display and input views
Not adoptedPer-function manual contexts, process-global history, whole-interpreter tracing, second provider or event database

Public documentation credits NVIDIA-labs OO Agents and cites its repository and paper. Retain applicable licenses if source is reused.

Implementation status

ItemStatus
Public entries, shared scopes, managed sources, decorator removalImplemented
Installed AppVerified separately from source checks, on the default App (default profile, port 18100, ~/.openprogram, /Applications/OpenProgram.app)
NOOA Predict, CodeAct, typed returns, persistent cellsSeparate later work. No upstream API compatibility or benchmark parity is claimed
References
Last updated · 2026-11-25