# External program run nodes

A function run directly from Programs, fn-form or another outside entry is one node under ROOT and one chat record. No User or LLM node is invented for it.

| Layer | Stored | Shown |
| --- | --- | --- |
| Persistence | One `role=code` node. `caller` empty; `predecessor` is the HEAD at creation, or ROOT | Unchanged by any view |
| Ownership | `caller` alone decides it; `predecessor` is only chronology | Empty or ROOT caller: top-level Program. Caller is an assistant: inside that message's `runtimeChildren` |
| DAG overview | Nothing new | `projectTopPrograms` places it on ROOT's lane at tier 1 through a derived `_overview_parent`; its internal calls join that lane |
| Retry | `retry_of` | Keeps a fork lane instead of the ROOT projection |
| Run status | The same node, updated at start and end | Same place and tile; only the tile's state and status text change |

The node is the ordinary call tile in [Layout specification](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/dag/layout.html#states). Arguments and output belong in Details.

## Chat record

| Part, in order | Behaviour |
| --- | --- |
| Avatar `ƒ` | Marks a run, not an assistant message |
| Title row | `ExecutionStrip` with a one-line summary; toggles the execution area |
| Execution area | Arguments, execution tree, usage. The existing `RuntimeBlock` and `TreeStep`, with Details, Copy, Retry, Edit & re-run and version navigation unchanged |
| Answer | Outside the fold, in ordinary chat type, with no quote styling |
| Footer | Always last, never folded; the normal time and action row |

The fold follows the conversation's transcript view until the reader clicks; the click wins over later updates. A long title stays on one line with a visible chevron and keeps its full text for assistive technology.

## Title row

Function name · status · duration · result. Built from existing fields; no model call.

| State | Example |
| --- | --- |
| Running | `report_workflow · Running… · 02:10 · 2 steps` |
| Completed | `report_workflow · Completed · 02:46 · 2 files processed` |
| Error | `report_workflow · Error · 01:22 · Permission denied` |
| Cancelled | `report_workflow · Cancelled · 00:42 · 3 steps` |

**Other statuses and the result slot**

| Case | Result |
| --- | --- |
| Running | Step count; `Starting` before the first step |
| Completed | One-line output preview, up to 48 characters; else step count |
| Error | Error preview; else output preview, step count |
| Cancelled, Interrupted, Stopped (capped), Paused | Step count |
| `gui_agent` | Its inner outcome replaces the status: Succeeded, Failed, Needs takeover, with the summary or handoff instruction as preview |

Logic and tests: `apps/web/components/chat/messages/runtime/runtime-summary.ts`, `apps/web/tests/chat/messages/runtime-summary.test.mjs`.

## Answer

`runtimeAnswer` renders what the run persisted and never starts a model call.

| Output | Answer |
| --- | --- |
| Running or paused | None |
| Empty | The error, if any |
| Object with `summary` | The summary, then `handoff_instruction` if different |
| Plain string | As is |
| Number or boolean | Its text |
| Other JSON | A fenced JSON block |

## Model for a direct run

The run belongs to the current session. Before the function process starts, the server resolves one provider and model and passes that pair in; with none it refuses with `no_model`.

1. The session's `provider_override` and `model_override`
2. The conversation Agent's configured model
3. The last used model

## Scope

- **Reused**: Call tiles, branch colours, status terms, `ExecutionStrip`, `RuntimeBlock`
- **Added**: The avatar and the fuller title
- **Excluded**: Synthetic User or LLM nodes, a new lane, large cards, percentage progress, a workflow-specific timeline, a new graph library
- **Unchanged**: Tools an LLM calls stay in the execution layer; nested function rendering and ordinary assistant messages do not change

## Implementation status

Implemented: chat record (`runtime-block.tsx`, `execution-strip.css`), title, answer, ROOT projection (`passes/project-programs.ts`), session model resolution (`runtime_management.py`).
