# llm-engine

## Role

`llm-engine` owns provider-independent model turn orchestration over committed history, tools, callbacks, retries, continuation, pruning, and compaction boundaries.

## Boundaries

Owns:

- Engine history mutation and append contracts
- tool-call loop semantics
- pre-stream retry and stream-started continuation policy
- pruning/compaction coordination from the Engine perspective
- provider-neutral events/callbacks/interceptors

Does not own:

- Worker names, sockets, process lifecycle, or scope delegation (`worker`)
- product CLI shape (`yoi`)
- provider catalog and secret resolution (`provider`, `secrets`)
- durable Worker current state (`session-store` worker metadata)

## Design notes

The Engine is where turn lifecycle belongs because it sees history, in-flight usage, partial output, and tool-call state. It should not receive context-only volatile facts; model-affecting inputs must first be appended to history.

## See also

- [`../../docs/design/context-history.md`](../../docs/design/context-history.md)
- [`../../docs/design/compaction.md`](../../docs/design/compaction.md)
- [`../../docs/design/provider-model-boundary.md`](../../docs/design/provider-model-boundary.md)
