`llm openai endpoint add` writes unparseable YAML when the existing list is indented
llm openai endpoint add still breaks extra-openai-models.yaml when the existing list is a block list indented by two spaces. _append_extra_model() writes the new record at column 0, so the file no longer parses and every llm command that loads models fails, the same outcome the 0.37.1 changelog lists as fixed for [].
At 39d3254, Python 3.15, a fresh LLM_USER_PATH:
$ printf ' - model_id: local-a\n model_name: llama3\n api_base: http://localhost:11434/v1\n' > "$LLM_USER_PATH/extra-openai-models.yaml"
$ llm models | grep local-a
OpenAI Chat: local-a
$ llm openai endpoint add http://localhost:11434/v1 -m qwen3 --id local-b
Saved local-b to .../extra-openai-models.yaml
Run a prompt with: llm -m local-b 'Hello'
$ llm models
yaml.parser.ParserError: expected '<document start>', but found '<block sequence start>'
in ".../extra-openai-models.yaml", line 4, column 1
$ cat "$LLM_USER_PATH/extra-openai-models.yaml"
- model_id: local-a
model_name: llama3
api_base: http://localhost:11434/v1
- model_id: local-b
model_name: qwen3
api_base: http://localhost:11434/v1
A file that ends with a ... document end marker fails the same way. The SequenceStartEvent the flow branch already reads also carries start_mark.column, which would give the indent for the block case. LLM itself never writes this layout, since yaml.safe_dump puts a top-level list at column 0, so this only hits hand-edited files.
@simonw should endpoint add match the indent it finds, or refuse with a clear error and leave the file alone? I'd match it, since the docstring promises to preserve existing content.
I'll work on preserving the existing block-list indentation and document end marker when adding an endpoint, with regression tests that reload the configuration and models afterwards.