# DAG edge fields

|  | `caller` | `predecessor` |
| --- | --- | --- |
| Question | Who called me | Who I follow in chat order |
| Edge | Sub-call | Conversation chain |
| Field | `Call.caller` | `Call.predecessor` |
| Example | The LLM that invoked a tool | Second-round user follows first-round reply |
| Decides | Sub-call indentation, internal nodes | Forks: one predecessor with several children |

The two often differ. A top-level user node hangs off ROOT but follows the previous reply, and a spawn root has a caller but no predecessor. One name for both once let a helper read the wrong edge.

## No compatibility layer

Only these two key names exist: no alias, no backfill in `from_dict` or the message adapters, no unused parent field in `GNode`. The backend graph dict and frontend are one protocol, so a key rename lands on both sides at once.

**Where each name is used**

### Backend (openprogram/state/store/session/)

| Symbol | Role |
| --- | --- |
| `nodes.py` `Call` | The two dataclass fields |
| `_msg_adapter.py` `_msg_to_node` | Message keys to fields; `predecessor` is popped from metadata so no mirror survives |
| `_msg_adapter.py` `_node_to_msg` | Fields to two explicit keys |
| `session_store/shared.py` | `_node_conv_predecessor`, `_node_caller` |
| `memory_index.py` `append` | Indexes `children_by_predecessor`, `children_by_caller` |
| `graph/builder.py` `build_session_graph` | Graph dict with both keys |
| `graph/layout/_common.py` | `predecessor_of`, `caller_of` |
| `graph/layout/tier.py` | Caller, for sub-call indentation |
| `graph/layout/lane.py` | Predecessor |
| `graph/layout/depth.py`, `topology.py` | Both; depth takes predecessor first, then caller |

### Frontend (apps/web/lib/runtime-bridge/)

| Symbol | Role |
| --- | --- |
| `dag/types.ts` `GNode` | Carries both |
| `dag/types.ts` `semanticParent`, `layoutParent` | `predecessor`, else `caller`; layout prefers `_overview_parent`. The caller fallback connects internal code and LLM rows and spawn roots. |
| `dag/pipeline.ts` `render` | `caller` marks internal nodes; `predecessor` drives the chain |
| `dag/render/` `edges`, `nodes`, `agents`, `labels/badges` | Read `predecessor` to draw edges and detect branches |
| `session/conversations.ts` `LegacyMessage`, `BranchRow` | Carry both keys through |

## Implementation status

Implemented on both sides. [The session data model](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/dag/overview.html) treats both edges as authoritative.
