# Features

Why it works this way: [Agentic Programming philosophy](https://fzkuji.github.io/OpenProgram/docs/capabilities/agentic-programming/philosophy.html).

## Automatic context

Every `Agent` method call is a node in the session's conversation DAG, with user messages and LLM calls. Nested calls thread themselves: when `verify` calls the LLM, it already sees what `observe` and `click` returned.

```
login_flow ✓ 8.8s
├── observe ✓ 3.1s → "found login form at (200, 300)"
├── click ✓ 2.5s → "clicked login button"
└── verify ✓ 3.2s → "dashboard confirmed"
```

```
from openprogram import Agent

class ExampleAgent(Agent):
    method_options = {
        'navigate': {'tool': True, 'expose': 'full', 'render_range': {'callers': 1}},
    }

    def navigate(self, target): ...
```

| Option | Controls |
| --- | --- |
| `expose` | What later calls see of this one: `io` input and output (default for tools), `llm` its LLM exchanges, `full` everything (default otherwise), `hidden` no node |
| `render_range={"callers": N}` | How much earlier history this function sees; `0` walls it off |
| `render_range={"subcalls": N}` | Its own in-frame history in long loops |

## Functions that author functions

Writing and fixing `Agent` methods is ordinary agent work with file-editing tools, following the [agentic function API](https://fzkuji.github.io/OpenProgram/docs/reference/api/agent.html). No `create()` or `fix()` framework calls exist. The skill is the spec: file location, decorator metadata, docstring versus `content`, a validation checklist and a smoke test. Programs improve through write, run, fail, fix.

## Conversation as a git DAG

Every exchange is a commit. Branches are first-class.

| Operation | Effect |
| --- | --- |
| **Branch off** | Explore from any past exchange, keeping the original thread |
| **Attach** | Bring context from another session in as a labelled user message |
| **Merge** | Combine two or more branches into one aggregated reply |

Branches that touch files run in isolated git worktrees: the fork is of the underlying repository, not a copy of messages.

## Memory that writes itself

1. **Finished turns** collect until enough, or 30 min of quiet
2. **One write pass** sorts facts by subject
   
   Invalid write: refused, workspace byte for byte unchanged
3. **topics/** timeline/ rebuilt from it
4. **03:00 pass** splits, merges, repairs

Paths, commands, tools and write guarantees: [Memory](https://fzkuji.github.io/OpenProgram/docs/capabilities/memory.html).

## DAG view

The right rail draws every node (user message, LLM call, code Call, attach) and edge. It scrolls with the chat, highlights the range in view, and clicking a node scrolls to its message. [Rendering rules](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/dag/rendering.html).

## Several keys per provider

Each provider holds an ordered list of API keys and sign-ins. Name them, reorder them, turn one off, or pin a conversation to one.

```
openprogram providers keys openai add --name work
openprogram providers keys openai list
openprogram providers keys openai strategy evenly
```

The same list is in Web (Settings → Model services) and TUI (`/login <provider>`, which completes OAuth, device code, CLI import or key paste in the terminal).

| Key handling | Rule |
| --- | --- |
| Add | Paste; checked first, then joins the end of the list. A key in the provider's environment variable is listed too, read-only |
| Use | A conversation keeps the key it started on; sub-agents and Goal turns use the same one |
| Switch | Rate limited, out of quota or refused: the next usable key takes over, with a one-line notice |
| Cooldown | `429` the provider's Retry-After, else 1 minute doubling to 15; quota until its reset; `5xx` retried twice on the same key |
| Strategy | `in-order`, `evenly`, `least-used`; reorder with `move` |

[Design and status](https://fzkuji.github.io/OpenProgram/docs/reference/design/providers/auth/unified-account-management.html).

## Multiple agents and channels

A session already supports several `agent_id`s: each row records its producer, the sidebar can colour by author, and channels (Telegram, Discord, Slack, WeChat) map to per-account identities. Next: cross-channel routing and declarative tool availability.
