OpenProgram Docs

Unified session context

Installed from the command line or the Web, a function should behave the same. Several capabilities read a per-turn session context, and a caller that builds none loses them without an error.

Without a session (_store=None)

CapabilityFailure pointSymptom
Docstring into promptNever reached in render.pyFunction instructions never reach the model; the Agent degrades into “What would you like to do”
DAG persistenceNode append is a no-opThe run is not in session history
History from the DAG_render_history_messages returns NoneEach exec cannot see earlier steps
ask_user trackingPlaceholder and finish nodes not writtenQuestions are not in history
Nested called_by_call_id=NoneNode attribution is lost

All follow the pattern store=_store.get(); if store is None: return.

What the context is made of

SessionDB (default_db / SessionStore)
  └─ ~/.openprogram/projects/<project-id>/chats/<session_id>/
SessionNodeWriter(db, session_id)      append / update / load DAG nodes
ContextVars, set and reset in pairs:
  _store            SessionNodeWriter  deep code writes the DAG, renders docs
  _current_turn_id                     which message a file backup belongs to
  _current_runtime  create_runtime()   Agent method auto-injection
  _call_id          Agent wrapper      called_by attribution

A work directory (research output such as literature review, ideas, paper) and a session (the conversation DAG) are independent. Building a session does not touch the work directory.

Design

One context manager, session_context, guarantees paired set and reset. A caller passing nothing still gets a real session, with its id exposed.

r1 = run_research("survey agent reliability")        # None: new session
r2 = run_research("now turn it into a paper",
                  session_id=r1.session_id)           # same session, history carries over
r3 = run_research("unrelated: GUI agent benchmark")   # independent session
  • One call is not one session: continuity is the caller passing the id, as with openprogram --resume <id> and the Web client.
  • Cleanup belongs to session management (list, delete), not to each call.
  • Stage instructions live in the docstring. With the context installed, a command-line run no longer needs them moved into content, so no stage function changes.

Implementation status

StepVerified byState
Add the managerVariables set inside, reset afterDone
A harness main.py wraps paper_agentCaptured command-line prompt contains the docstringDone
Dispatcher switches overExisting dispatcher tests passNot done: TurnBindings.bind still binds its own
process_runner and tests convergeSubprocess DAG tracking and fixtures still workNot done: process_runner still sets its own
Last updated · 2026-11-25