Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.
JavaScript agent-orchestrationagentic-workflowai-agentsai-codingclaude-codecode-reviewcodebuddycodexcoding-agentscursordeveloper-toolshuman-on-the-loopllmmcpmulti-agentsdlcself-hostedsopworkflow-automationworkflow-engine
feat(chatbot): show the model a subagent ran on
roberttwang4d2ef214d1f3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ba99076f..3e690806 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,6 +4,7 @@ Platform releases use `vX.Y.Z` tags and publish `ghcr.io/tencent/loopforge`. Loo## Unreleased+- A conversation's 子 Agent shows the model it ran on: its row in the artifacts list reads 「已完成 · 模型 …」, the header of an opened subagent names the model next to its status, and each dispatch in 会话过程 notes 「模型 · …」 under the task it was given. The model is the one the Agent call named for the subagent (the `model` argument, for example `lite` or a model ID), else the model of the reply that dispatched it, which the subagent inherits; a dispatch still running uses the model the running reply was sent with. Activity events of an Agent call carry the new `model` field only when the call named one; replies saved before this change show the model of their reply.- The built-in backend, frontend and defect-fix SOPs gain a 「发起 MR」 node between 人工验收 and 交付汇总 (#717). It commits the work branch, pushes it and opens an MR/PR against the run's target branch, then records the link, branches and commit SHA in `mr-body.md`. Its command gate checks every writable repository of the run: one with commits beyond the target branch fails while it has uncommitted changes, while its checkout is off the run's work branch, or until `git ls-remote origin` shows that work branch at HEAD. A repository the run left unchanged is skipped. A second gate of the new mode `mr` has the engine look the MR up on the host with the same lookup delivery tracking uses (GitHub and Gongfeng): every writable repository whose work branch on origin carries commits beyond the target branch needs an MR from that work branch into that target branch that carries the pushed tip: an open one whose head is the tip (or whose host reports no head), or a merged one whose head is the tip. An agent that reports pass without opening an MR, opens it against the wrong branch, or leaves only an earlier merged MR on a reused work branch does not reach 交付汇总. The lookup runs as the run: on GitHub with the Git token the run pushed with (its responsible user's), falling back to the Owner of the run's own project; on Gongfeng through the run project's MCP as the responsible user. A repository bound to several projects is no longer checked as whichever project bound it first, and a failed lookup names the identity it used. A host the platform cannot query (an SSH repository, a failed lookup) goes straight to a person. `mr` gates take no commands, and the role editor keeps them when a role is saved. The gates retry once with their feedback and then wait for a person, so a run no longer succeeds with every source change left in a workspace that is reclaimed right after success. Run-scoped commands now get `AGENTFLOW_WORK_BRANCHES` (one `dir<TAB>work branch<TAB>target branch` line per writable repository) and repository-scoped commands get `AGENTFLOW_WORK_BRANCH` and `AGENTFLOW_BASE_BRANCH`; the target branch is the one frozen into the run, including a requirement's release branch and a scheduled SOP's integration branch. 交付汇总 no longer pushes or opens a PR itself. Runs without a bound repository still deliver from the task workspace. New installs get the new templates from the seed. Existing installs keep their templates until an operator runs `migrations/033_generic_sop_mr_node.sql` by hand (see docs/deployment.md); it rewrites a template only while its node graph and 交付汇总 position are the shipped original and its 交付汇总 prompt only while unedited. SOPs already adopted into a project are copies and keep their old graph. The product SOP delivers documents only and is unchanged.- A conversation reply that is still running keeps running through a slow heartbeat. A poll, the conversation list, a follow-up message or a steer used to record it as interrupted after 45 seconds without a stored heartbeat; the process then cancelled the CLI and the next message failed with 「工作区正在使用或保存,请稍后重试」 for up to 15 minutes. Reads of a turn this process executes no longer reap it, and an unchanged heartbeat on MySQL no longer counts as a lost turn. On MySQL a heartbeat's age is measured on the database clock that stamped it, so skew between an API host and MySQL neither reaps a live turn nor keeps a dead one; whether a lease holder stopped renewing is likewise judged from `run_workspace_checkpoints.lease_renewed_at`, stamped on the database clock, not from another replica's `lease_until`. When a turn whose process died is reaped, the workspace lease it recorded is released if nothing renewed it for 45 seconds, so the next message starts at once; a lease another turn took, one still renewed on another replica, and a background save are kept. `migrations/032_assistant_generation_workspace_lease.sql` adds the three columns by hand; startup AutoMigrate adds them too.diff --git a/chatbot/src/ArtifactPanel.jsx b/chatbot/src/ArtifactPanel.jsxindex 70d3ec3a..6681a1b2 100644--- a/chatbot/src/ArtifactPanel.jsx+++ b/chatbot/src/ArtifactPanel.jsx@@ -206,6 +206,7 @@ export default function ArtifactPanel({const subagents = collectSubagents(chat?.session?.messages || [],live ? chat?.live?.activity || [] : [],+ chat?.model || "",);// A new subagent is keyed by its dispatch until its agent ID arrives, so// an opened one is found by either.@@ -344,6 +345,7 @@ export default function ArtifactPanel({subagentName(agent),agent.subagent,agent.agentId,+ agent.model,subagentStatus(agent, live).label,...agent.dispatches.map((step) => step.detail),"子 Agent",@@ -530,8 +532,8 @@ export default function ArtifactPanel({{selectedAgent ? (<><span className="artifact-node-title">{subagentName(selectedAgent)}</span>- <small className="node-header-meta" title={[selectedAgent.subagent, selectedAgent.agentId].filter(Boolean).join(" · ")}>- {subagentStatus(selectedAgent, live).label}+ <small className="node-header-meta" title={[selectedAgent.subagent, selectedAgent.agentId, selectedAgent.model].filter(Boolean).join(" · ")}>+ {[subagentStatus(selectedAgent, live).label, selectedAgent.model].filter(Boolean).join(" · ")}</small></>) : null}@@ -776,6 +778,7 @@ export default function ArtifactPanel({<small><i className={`artifact-run-dot status-${{ done: "succeeded", running: "running", failed: "failed" }[status.tone] || "canceled"}`} />{status.label}+ {agent.model ? ` · 模型 ${agent.model}` : ""}{count > 1 ? ` · 派发 ${count} 次` : ""}{agent.dispatches.at(-1)?.detail? ` · ${agent.dispatches.at(-1).detail}`diff --git a/chatbot/src/SubagentSession.jsx b/chatbot/src/SubagentSession.jsxindex 642e7af5..b3e42a34 100644--- a/chatbot/src/SubagentSession.jsx+++ b/chatbot/src/SubagentSession.jsx@@ -34,8 +34,8 @@ function processSteps(step) {}// SubagentSession shows one subagent like an SOP node: what Main Bot asked,-// how it worked and what it reported, once per dispatch when it was resumed,-// plus its collected deliverables and what it published.+// the model it ran on, how it worked and what it reported, once per dispatch+// when it was resumed, plus its collected deliverables and what it published.export function SubagentSession({ agent, live = false, artifacts = [], onOpenArtifact }) {const [tab, setTab] = useState("conversation");useEffect(() => setTab("conversation"), [agent.key]);@@ -96,6 +96,11 @@ export function SubagentSession({ agent, live = false, artifacts = [], onOpenArt<RichContent message={step.input || step.detail} /></article>) : null}+ {agent.models?.[step.id] ? (+ <p className="muted subagent-model" aria-label="运行模型">+ 模型 · {agent.models[step.id]}+ </p>+ ) : null}{resumeMissed(step) ? (<p className="muted subagent-resume-missed" role="note">复用未生效:没有接着 {step.resumed} 做,已新开子 Agent。diff --git a/chatbot/src/activity.js b/chatbot/src/activity.jsindex 0bf97b64..c107e082 100644--- a/chatbot/src/activity.js+++ b/chatbot/src/activity.js@@ -104,6 +104,7 @@ export function mergeActivity(previous = [], events = []) {if (event.subagent) existing.subagent = event.subagent;if (event.role) existing.role = event.role;if (event.input) existing.input = event.input;+ if (event.model) existing.model = event.model;// A resumed dispatch names its agent before it finishes. Keep the// target apart: the CLI may still finish it under a new agent.if (event.agentId) existing.agentId = existing.resumed = event.agentId;@@ -118,6 +119,7 @@ export function mergeActivity(previous = [], events = []) {...(event.subagent ? { subagent: event.subagent } : {}),...(event.role ? { role: event.role } : {}),...(event.input ? { input: event.input } : {}),+ ...(event.model ? { model: event.model } : {}),...(event.agentId ? { agentId: event.agentId, resumed: event.agentId } : {}),});}@@ -276,20 +278,27 @@ export const resumeMissed = (step) =>// collectSubagents lists every subagent of a conversation, newest last. A// dispatch that resumed an earlier agent joins it, so one entry holds every// task that agent was given.-export function collectSubagents(messages = [], liveSteps = []) {+// A subagent runs on the model its dispatch named, else on the model of the+// reply that dispatched it; a live dispatch has no saved reply yet and uses+// liveModel, the model the running reply was sent with. agent.model is the+// latest dispatch's, agent.models[step.id] each dispatch's.+export function collectSubagents(messages = [], liveSteps = [], liveModel = "") {const agents = [];// messageIndex is the saved reply that holds the dispatch; a live one has// none yet, and its collected files are not attachments until it is saved.- const add = (step, messageIndex = null) => {+ const add = (step, messageIndex = null, replyModel = "") => {const key = step.agentId || step.id;let agent = agents.find((item) => item.key === key || (step.agentId && item.agentId === step.agentId));if (!agent) {- agent = { key, agentId: step.agentId || "", role: "", subagent: "", dispatches: [], published: [] };+ agent = { key, agentId: step.agentId || "", role: "", subagent: "", model: "", models: {}, dispatches: [], published: [] };agents.push(agent);}if (step.agentId) agent.agentId = step.agentId;agent.role = step.role || agent.role;agent.subagent = step.subagent || agent.subagent;+ const model = String(step.model || replyModel || "").trim();+ if (model) agent.models[step.id] = model;+ agent.model = model || agent.model;agent.dispatches.push(step);// What it published, and the role deliverables the platform collected// when it finished (a required one it did not write is marked missing).@@ -309,9 +318,9 @@ export function collectSubagents(messages = [], liveSteps = []) {if (message.role !== "assistant") return;savedActivity(message).filter(isDispatch)- .forEach((step) => add(step, index));+ .forEach((step) => add(step, index, message.model));});- liveSteps.filter(isDispatch).forEach((step) => add(step));+ liveSteps.filter(isDispatch).forEach((step) => add(step, null, liveModel));return agents;}// While streaming, the latest paragraph is the answer only once nothing hasdiff --git a/chatbot/src/styles.css b/chatbot/src/styles.cssindex 4637eabd..622723ed 100644--- a/chatbot/src/styles.css+++ b/chatbot/src/styles.css@@ -1263,6 +1263,12 @@ small {.node-conversation-view .node-message:first-child {margin-top: 20px;}+/* The model a subagent dispatch ran on, under the task it was given. */+.subagent-session .subagent-model {+ margin: 6px 0 0;+ font-size: 12px;+ overflow-wrap: anywhere;+}.composer-toolbar {display: flex;align-items: center;diff --git a/chatbot/tests/subagents.test.jsx b/chatbot/tests/subagents.test.jsxindex b69a4821..823e8392 100644--- a/chatbot/tests/subagents.test.jsx+++ b/chatbot/tests/subagents.test.jsx@@ -82,6 +82,57 @@ describe("dispatched subagents", () => {await userEvent.click(screen.getByRole("button", { name: /测试报告/ }));expect(setSelected).toHaveBeenLastCalledWith(report);});++ test("a subagent runs on the model its dispatch named, else on its reply's", () => {+ const dispatch = (id, extra = {}) => ({ kind: "tool", id, tool: "Agent", detail: id, subagent: "role-qa", ...extra, at });+ const steps = mergeActivity([], events(dispatch("c0"), dispatch("c0", { model: "lite" })));+ expect(steps[0].model).toBe("lite");+ const agents = collectSubagents(+ [+ { role: "assistant", model: "claude-opus-4-5", activity: [dispatch("c1"), { kind: "toolDone", id: "c1", agentId: "agent-aaa", at }] },+ { role: "assistant", model: "claude-opus-4-5", activity: [dispatch("c2", { model: "claude-haiku-4-5", agentId: "agent-aaa" }), { kind: "toolDone", id: "c2", agentId: "agent-aaa", at }] },+ { role: "assistant", activity: [dispatch("c3"), { kind: "toolDone", id: "c3", agentId: "agent-ccc", at }] },+ ],+ [dispatch("c4")],+ "gpt-5",+ );+ expect(agents.map((agent) => [agent.key, agent.model, agent.models])).toEqual([+ ["agent-aaa", "claude-haiku-4-5", { c1: "claude-opus-4-5", c2: "claude-haiku-4-5" }],+ // A reply saved without a model reports none.+ ["agent-ccc", "", {}],+ // A live dispatch runs on the model the running reply was sent with.+ ["c4", "gpt-5", { c4: "gpt-5" }],+ ]);+ });++ test("the 子 Agent card and its session show the model it ran on", async () => {+ const messages = [+ { role: "user", content: "补单测" },+ {+ role: "assistant",+ model: "claude-opus-4-5",+ activity: [+ { kind: "tool", id: "c1", tool: "Agent", detail: "补单测", input: "给 a.go 补单测", role: "测试工程师", at },+ { kind: "toolDone", id: "c1", agentId: "agent-aaa", output: "用例都通过了", at },+ ],+ },+ ];+ const chat = { session: { id: "s1", projectId: "p1", messages }, projectId: "p1", projects: [] };+ let selected = null;+ const setSelected = vi.fn((value) => (selected = value));+ const panel = () => (+ <div className="chat-shell">+ <ArtifactPanel artifacts={[]} runs={[]} selected={selected} setSelected={setSelected} chat={chat} onClose={vi.fn()} open />+ </div>+ );+ const view = render(panel());+ const card = screen.getByRole("button", { name: /测试工程师/ });+ expect(card.textContent).toContain("已完成 · 模型 claude-opus-4-5");+ await userEvent.click(card);+ view.rerender(panel());+ expect(screen.getByLabelText("运行模型").textContent).toBe("模型 · claude-opus-4-5");+ expect(screen.getByText("已完成 · claude-opus-4-5")).toBeTruthy();+ });});describe("role deliverables", () => {diff --git a/internal/domain/assistant.go b/internal/domain/assistant.goindex dff9d0eb..49638af6 100644--- a/internal/domain/assistant.go+++ b/internal/domain/assistant.go@@ -35,6 +35,10 @@ type AssistantActivityEvent struct {Subagent string `json:"subagent,omitempty"`Role string `json:"role,omitempty"`AgentID string `json:"agentId,omitempty"`+ // Model is the model an Agent dispatch asked its subagent to run on. It+ // is empty when the subagent inherits the model of the reply that+ // dispatched it.+ Model string `json:"model,omitempty"`// Input is the task an Agent dispatch hands the subagent and Output the// report it returns; the side panel shows them like an SOP node session.Input string `json:"input,omitempty"`diff --git a/internal/httpapi/assistant_stream.go b/internal/httpapi/assistant_stream.goindex 41ffe0a4..ad30600e 100644--- a/internal/httpapi/assistant_stream.go+++ b/internal/httpapi/assistant_stream.go@@ -78,10 +78,10 @@ func (f *assistantStreamFilter) acceptTool(ev assistantStreamEvent) bool {}// The CLI announces a call with empty input and repeats it once// the input is complete. Keep the repeat only when it adds- // something: the detail, or an Agent call's type and task.- seen := ev.Detail + "\x00" + ev.Subagent + "\x00" + ev.Input + "\x00" + ev.AgentID+ // something: the detail, or an Agent call's type, task and model.+ seen := ev.Detail + "\x00" + ev.Subagent + "\x00" + ev.Input + "\x00" + ev.AgentID + "\x00" + ev.Modelif previous, ok := f.seenTools[ev.ID]; ok {- if seen == previous || (ev.Detail == "" && ev.Subagent == "" && ev.Input == "") {+ if seen == previous || (ev.Detail == "" && ev.Subagent == "" && ev.Input == "" && ev.Model == "") {return false}}@@ -293,10 +293,12 @@ func assistantToolStreamEvent(id, name string, input json.RawMessage) (assistantSubagentType string `json:"subagent_type"`Prompt string `json:"prompt"`Resume string `json:"resume"`+ Model string `json:"model"`}_ = json.Unmarshal(input, &dispatch)event.Subagent = strings.TrimSpace(dispatch.SubagentType)event.Input = truncateRunes(strings.TrimSpace(dispatch.Prompt), 8000)+ event.Model = assistantDispatchModel(dispatch.Model)// A resumed dispatch names its agent up front, so the panel can put// it on that agent's row while it runs.if m := assistantAgentIDRe.FindStringSubmatch("Agent ID: " + strings.TrimSpace(dispatch.Resume)); m != nil {@@ -308,6 +310,17 @@ func assistantToolStreamEvent(id, name string, input json.RawMessage) (assistantvar assistantAgentIDRe = regexp.MustCompile(`Agent ID:\s*(agent-[A-Za-z0-9-]+)`)+// assistantDispatchModel is the model an Agent call names for its subagent.+// No model, or one that only says to inherit, leaves it to the reply's own.+func assistantDispatchModel(model string) string {+ model = strings.TrimSpace(model)+ switch strings.ToLower(model) {+ case "", "default", "inherit":+ return ""+ }+ return truncateRunes(model, 128)+}+// assistantResultText reads a tool result, which is either a string or a list// of text blocks.func assistantResultText(content json.RawMessage) string {diff --git a/internal/httpapi/assistant_stream_filter_test.go b/internal/httpapi/assistant_stream_filter_test.goindex aafdb7e9..139c83a1 100644--- a/internal/httpapi/assistant_stream_filter_test.go+++ b/internal/httpapi/assistant_stream_filter_test.go@@ -56,6 +56,8 @@ func TestAssistantStreamFilterAcceptToolDedupes(t *testing.T) {{"identical repeat", assistantStreamEvent{Tool: "Bash", ID: "t1", Detail: "ls"}, false},{"repeat with empty detail and input", assistantStreamEvent{Tool: "Bash", ID: "t1", AgentID: "a1"}, false},{"agent call adds task", assistantStreamEvent{Tool: "Agent", ID: "t2", Subagent: "Explore", Input: "find x"}, true},+ {"agent call adds model", assistantStreamEvent{Tool: "Agent", ID: "t2", Subagent: "Explore", Input: "find x", Model: "lite"}, true},+ {"agent call repeats model", assistantStreamEvent{Tool: "Agent", ID: "t2", Subagent: "Explore", Input: "find x", Model: "lite"}, false},{"no id empty tool", assistantStreamEvent{}, false},{"no id same as last", assistantStreamEvent{Tool: "Agent", Detail: ""}, false},{"no id new detail", assistantStreamEvent{Tool: "Agent", Detail: "y"}, true},diff --git a/internal/httpapi/assistant_subagents_test.go b/internal/httpapi/assistant_subagents_test.goindex 1b6f3f9f..9c97acae 100644--- a/internal/httpapi/assistant_subagents_test.go+++ b/internal/httpapi/assistant_subagents_test.go@@ -347,9 +347,21 @@ func TestEverySharedSkillIsInstalledHoweverManyAreShared(t *testing.T) {func TestSubagentStreamEventsCarryTheirDispatch(t *testing.T) {dispatch := assistantStreamEvents(`{"type":"assistant","message":{"content":[{"type":"tool_use","id":"call-1","name":"Agent","input":{"subagent_type":"role-qa","description":"补单测","prompt":"x"}}]}}`)- if len(dispatch) != 1 || dispatch[0].Subagent != "role-qa" || dispatch[0].Parent != "" || dispatch[0].Input != "x" {+ if len(dispatch) != 1 || dispatch[0].Subagent != "role-qa" || dispatch[0].Parent != "" || dispatch[0].Input != "x" || dispatch[0].Model != "" {t.Fatalf("dispatch=%+v", dispatch)}+ // A dispatch that names a model keeps it; one that only inherits does not.+ for input, want := range map[string]string{+ `"model":"claude-sonnet-4-5"`: "claude-sonnet-4-5",+ `"model":" lite "`: "lite",+ `"model":"default"`: "",+ `"model":"inherit"`: "",+ } {+ got := assistantStreamEvents(`{"type":"assistant","message":{"content":[{"type":"tool_use","id":"call-m","name":"Agent","input":{"subagent_type":"Explore","prompt":"x",` + input + `}}]}}`)+ if len(got) != 1 || got[0].Model != want {+ t.Fatalf("%s: dispatch=%+v, want model %q", input, got, want)+ }+ }if got := labelRoleSubagent(dispatch[0], []roleSubagent{{Role: domain.AgentDefinition{ID: "qa", Name: "测试工程师"}}}); got.Role != "测试工程师" {t.Fatalf("role label=%q", got.Role)}