Allow launching runs with whole-run and per-stage model overrides
Add `pipelines run --model PROVIDER/MODEL` and repeatable `--stage-model STAGE=PROVIDER/MODEL`, resolved with precedence per-stage > whole-run > the model pinned in the pipeline version. - A shared pure resolver (`pipeline.ParseModelOverride` / `pipeline.EffectiveModels`) owns the precedence and validation: every value must be a `provider/model` pair (`stage.ValidModel`), every stage key must exist in the pinned graph, an unknown key fails naming the valid keys, and a per-stage key that names a non-model stage is refused. - The server validates against the pinned version before admission (no run row is ever inserted for an invalid request), persists `model`/`stage_models` on the run and `provider`/`model` on each step, applies the effective pair to a clone of the stage definition so the stage and its repair/formatter path share it, overlays the returned run graph with the effective pair (presentation only), and reuses the recorded overrides on retry. - The run record echoes the overrides it was launched with and each step records the provider/model it actually ran with; the TUI Evidence pane renders that effective pair. The pinned pipeline version and `show --version N` are never modified. - CLI help, `docs/cli.md` and the packaged authoring skill references document the flags and the precedence. A TUI override picker remains a documented follow-up; the CLI is the deliverable. Tests: pure precedence/validation table tests, store round-trip and request-key-mismatch plus migration, server admission/application/overlay/retry with a controlled executor, CLI flag/help/malformed-value tests, and a TUI evidence test.
This commit is contained in:
@@ -13,6 +13,10 @@ type RunOptions struct {
|
||||
Pipeline, Prompt, Title, Workspace string
|
||||
Yes, AllowTools bool
|
||||
WritePaths []string
|
||||
// Model and StageModels are the CLI's launch-time model overrides, passed
|
||||
// through to the run request without adding a TUI picker (that is a follow-up).
|
||||
Model string
|
||||
StageModels map[string]string
|
||||
}
|
||||
|
||||
func NewRun(ctx context.Context, url string, options RunOptions) Model {
|
||||
|
||||
@@ -359,6 +359,11 @@ func evidenceLines(step protocol.RunStep) []string {
|
||||
if step.SessionID == "" {
|
||||
lines = []string{"Recorded result evidence"}
|
||||
}
|
||||
// The effective provider/model this visit ran with, for a model stage; it
|
||||
// reflects any launch-time override rather than the pinned model.
|
||||
if step.Provider != "" || step.Model != "" {
|
||||
lines = append(lines, "Ran with model: "+step.Provider+"/"+step.Model)
|
||||
}
|
||||
if step.Transcript == "" {
|
||||
return append(lines, "No captured tool evidence yet.")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
|
||||
// TestEvidenceLinesShowEffectiveModel proves the Evidence pane renders the
|
||||
// provider/model a step actually ran with, so a launch-time override is visible
|
||||
// rather than the pinned model.
|
||||
func TestEvidenceLinesShowEffectiveModel(t *testing.T) {
|
||||
step := protocol.RunStep{Sequence: 1, Stage: "one", Status: "completed", Outcome: "success", Provider: "acme", Model: "strong"}
|
||||
text := strings.Join(evidenceLines(step), "\n")
|
||||
if !strings.Contains(text, "acme/strong") {
|
||||
t.Fatalf("evidence pane omitted the effective model:\n%s", text)
|
||||
}
|
||||
// A non-model step records no provider/model and shows no model line.
|
||||
plain := strings.Join(evidenceLines(protocol.RunStep{Sequence: 2, Stage: "note", Status: "completed", Outcome: "success"}), "\n")
|
||||
if strings.Contains(plain, "Ran with model:") {
|
||||
t.Fatalf("non-model step claimed a model:\n%s", plain)
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func (m *Model) startSelectedRun() tea.Cmd {
|
||||
m.runCollapsed = nil
|
||||
m.runDetail = nil
|
||||
m.runTop = 0
|
||||
request := protocol.Message{Type: protocol.RunPipeline, PipelineID: m.detail.ID, Version: m.detail.Version, RequestKey: fmt.Sprintf("tui-%d", time.Now().UnixNano()), Title: m.cliOptions.Title, Input: initialRunInput(m.runTask), AllowTools: m.runHasMutationTools(), WritePaths: m.runPaths, Workspace: m.runWorkspace}
|
||||
request := protocol.Message{Type: protocol.RunPipeline, PipelineID: m.detail.ID, Version: m.detail.Version, RequestKey: fmt.Sprintf("tui-%d", time.Now().UnixNano()), Title: m.cliOptions.Title, Input: initialRunInput(m.runTask), AllowTools: m.runHasMutationTools(), WritePaths: m.runPaths, Workspace: m.runWorkspace, Model: m.cliOptions.Model, StageModels: m.cliOptions.StageModels}
|
||||
updated, cmd := m.runRequest(request)
|
||||
*m = updated.(Model)
|
||||
return cmd
|
||||
|
||||
Reference in New Issue
Block a user