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
fix(clarify): stop swapping a Codex model for CodeBuddy in CodeBuddy-only entries (#304)
fx-kurumi463b16c925e7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 31d26437..69b93cfe 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,7 @@ Platform releases use `vX.Y.Z` tags and publish `ghcr.io/tencent/loopforge`. Loo- Upgrading with `./start.sh pull` now re-applies the schema pieces gorm AutoMigrate cannot create: the `run_telemetry.adapter` and `run_logs.level` generated columns from `migrations/001_run_obs_generated_columns.sql`, and the `INSERT IGNORE` starter catalog. A data volume from an older release no longer fails with `Error 1054 Unknown column 'adapter'` the first time someone opens a run detail. The installer and the upgrade command share one script, `scripts/install-schema-extensions.sh`, and a failed step stops the command with the migration file an operator has to run by hand.- `docs/deployment.md` splits `migrations/` into scripts the installer already covers, scripts an upgrade must run once, and scripts that only backfill existing rows.- The 预览/源码 switch in the chat artifact preview now matches the 30px copy and download buttons beside it (36px on narrow screens) instead of using the 48px page-level tab size.+- Requirement clarification, Bot replies, run evals and the SOP preview build list only CodeBuddy models, because they run on CodeBuddy. `POST /api/chat-clarify`, `POST /api/issues/{id}/chat-clarify` and `POST /api/runs/{id}/eval` answer 400 for a model of another CLI (such as `codex:…`) instead of switching it to the CodeBuddy default; a Codex model saved earlier in these pickers falls back to the CLI default (#228).- Repository clone URLs no longer carry credentials. Saving a `cloneUrl` with a user name or password, such as `https://user:[email protected]/acme/app.git`, is rejected with a pointer to the Git token in personal settings; the repositories API, bootstrap payload, run, task and requirement views, and the runner task management list strip credentials from `cloneUrl` and `webUrl` of rows saved earlier; a `webUrl` with credentials is rejected on save; runner clone errors and redacted Git output mask them. `ssh://git@host/...` and `git@host:path` remotes are still accepted.diff --git a/README.md b/README.mdindex 3ab5601e..8141eec3 100644--- a/README.md+++ b/README.md@@ -112,7 +112,7 @@ New accounts join the **LoopForge demo project**, which includes an SOP made onl<br>-- **Executors.** Pick one of ten CLIs beside the home composer, then a model. Every SOP role can choose its executor independently (built-in roles default to CodeBuddy). Requirement clarification and AI notification summaries currently use CodeBuddy; scheduled assistant tasks run on the CLI the task selects.+- **Executors.** Pick one of ten CLIs beside the home composer, then a model. Every SOP role can choose its executor independently (built-in roles default to CodeBuddy). Requirement clarification, AI notification summaries, Bot replies and run evals currently use CodeBuddy, so their model pickers list CodeBuddy models only and the server refuses a model of another CLI instead of switching it to CodeBuddy; scheduled assistant tasks run on the CLI the task selects.| Executor | Credentials | Installation || --- | --- | --- |diff --git a/README.zh-CN.md b/README.zh-CN.mdindex b0684be2..d70bf45e 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -112,7 +112,7 @@ GitLab、Gitea、Gogs 等托管可[配置 Git SSH](docs/deployment.md#git-reposi<br>-- **执行器。** 在首页输入框旁从 10 种 CLI 中选择一种,再选择模型。每个 SOP 角色都可以独立选择执行器(内置角色默认 CodeBuddy)。需求澄清和通知 AI 汇总目前使用 CodeBuddy;定时助手任务使用任务所选的执行器。+- **执行器。** 在首页输入框旁从 10 种 CLI 中选择一种,再选择模型。每个 SOP 角色都可以独立选择执行器(内置角色默认 CodeBuddy)。需求澄清、通知 AI 汇总、Bot 回复和运行评测目前使用 CodeBuddy,这些入口的模型列表只列 CodeBuddy 模型,服务端收到其他 CLI 的模型会直接拒绝并说明原因,不会悄悄换成 CodeBuddy;定时助手任务使用任务所选的执行器。| 执行器 | 凭据 | 安装方式 || --- | --- | --- |diff --git a/internal/httpapi/clarify_engine_test.go b/internal/httpapi/clarify_engine_test.gonew file mode 100644index 00000000..042566aa--- /dev/null+++ b/internal/httpapi/clarify_engine_test.go@@ -0,0 +1,74 @@+package httpapi++import (+ "bytes"+ "context"+ "encoding/json"+ "net/http"+ "net/http/httptest"+ "strings"+ "testing"++ "agentflow/internal/domain"+ "agentflow/internal/repo"+)++// Issue #228: clarification and run evals run on CodeBuddy only. A model of+// another CLI ("codex:…") must be refused up front, not silently swapped for+// the CodeBuddy default.+func TestClarifyModelEngineError(t *testing.T) {+ for _, id := range []string{"", "default", "glm-5.1", "public-model"} {+ if err := clarifyModelEngineError(id); err != nil {+ t.Fatalf("CodeBuddy model %q refused: %v", id, err)+ }+ }+ for _, id := range []string{"codex:gpt-5.5", "claude-code:sonnet"} {+ if err := clarifyModelEngineError(id); err != errClarifyNeedsCodeBuddy {+ t.Fatalf("model %q = %v, want errClarifyNeedsCodeBuddy", id, err)+ }+ }+}++func TestChatClarifyRefusesOtherCLIModel(t *testing.T) {+ called := false+ setClarifyExecForTest(func(context.Context, domain.Issue, chatClarifyRequest, func(string, any)) (any, string, map[string]any, error) {+ called = true+ return map[string]any{}, "{}", map[string]any{}, nil+ })+ t.Cleanup(func() { setClarifyExecForTest(nil) })++ _, h := clarifyTestServer(t)+ body, _ := json.Marshal(map[string]any{"projectId": "platform", "message": "加个徽章", "model": "codex:gpt-5.5"})+ req := httptest.NewRequest(http.MethodPost, "/api/chat-clarify", bytes.NewReader(body))+ req.Header.Set("Content-Type", "application/json")+ rec := httptest.NewRecorder()+ h.ServeHTTP(rec, req)+ if rec.Code != http.StatusBadRequest {+ t.Fatalf("status = %d, want 400: %s", rec.Code, rec.Body.String())+ }+ if !strings.Contains(rec.Body.String(), "只支持 CodeBuddy") {+ t.Fatalf("error does not explain the CodeBuddy limit: %s", rec.Body.String())+ }+ if called {+ t.Fatal("clarification started with a Codex model")+ }+}++func TestRunEvalRefusesOtherCLIModel(t *testing.T) {+ f := cvBNewHTTPFixture(t)+ if _, err := f.s.UpdateUserCredentials(f.user.ID, repo.UserCredentialUpdate{CodeBuddyAPIKey: "eval-key"}); err != nil {+ t.Fatal(err)+ }+ done := domain.Run{ID: "eval-codex-run", Status: "succeeded", WorkflowID: "missing",+ ExecutionContext: domain.TelemetryContext{ProjectID: "platform"}, Nodes: map[string]*domain.NodeRun{}}+ if err := f.s.PutRun(done); err != nil {+ t.Fatal(err)+ }+ rec := cvBRequest(t, f, http.MethodPost, "/api/runs/eval-codex-run/eval", map[string]any{"model": "codex:gpt-5.5"}, true)+ if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), "只支持 CodeBuddy") {+ t.Fatalf("status = %d body = %s, want 400 explaining the CodeBuddy limit", rec.Code, rec.Body.String())+ }+ if _, busy := f.s.ActiveRunEval(done.ID); busy {+ t.Fatal("a Codex model must not start a run eval")+ }+}diff --git a/internal/httpapi/clarify_mcp.go b/internal/httpapi/clarify_mcp.goindex 3c070ec1..a725ae70 100644--- a/internal/httpapi/clarify_mcp.go+++ b/internal/httpapi/clarify_mcp.go@@ -3,6 +3,7 @@ package httpapiimport ("context""encoding/json"+ "errors""fmt""path/filepath""regexp"@@ -26,6 +27,20 @@ func clarifyAllowedModel(id string) string {return assistantAllowedModel(id, assistantKnownCatalog())}+// errClarifyNeedsCodeBuddy is returned when a clarification asks for a model of+// another CLI: clarification runs on CodeBuddy only, so a "codex:…" id must be+// refused instead of being swapped for the CodeBuddy default.+var errClarifyNeedsCodeBuddy = errors.New("需求澄清目前只支持 CodeBuddy 模型,请在模型列表中改选 CodeBuddy 模型")++// clarifyModelEngineError reports whether id names a model of a CLI that+// requirement clarification cannot run.+func clarifyModelEngineError(id string) error {+ if engine, _ := assistantModelEngine(id); engine != assistantEngineCodeBuddy {+ return errClarifyNeedsCodeBuddy+ }+ return nil+}+func asStringKeyMap(v any) map[string]any {m, ok := v.(map[string]any)if !ok || m == nil {diff --git a/internal/httpapi/run_eval.go b/internal/httpapi/run_eval.goindex ece98f01..56d6aa3d 100644--- a/internal/httpapi/run_eval.go+++ b/internal/httpapi/run_eval.go@@ -116,6 +116,12 @@ func (h *runsHandlers) startRunEval(c *gin.Context) {if c.Request.ContentLength > 0 && !decode(c, &req) {return}+ // Run evals run on CodeBuddy only: refuse a "codex:…" id instead of+ // silently evaluating with the CodeBuddy default.+ if engine, _ := assistantModelEngine(req.Model); engine != assistantEngineCodeBuddy {+ c.JSON(http.StatusBadRequest, map[string]string{"error": "运行评测目前只支持 CodeBuddy 模型,请改选 CodeBuddy 模型"})+ return+ }catalog := loadAssistantModels(c.Request.Context(), user.CodeBuddyInternetEnvironment)model := assistantAllowedModel(req.Model, catalog)project, _ := h.repo.Project(run.ExecutionContext.ProjectID)diff --git a/internal/httpapi/stream.go b/internal/httpapi/stream.goindex dfa445f2..af6b1639 100644--- a/internal/httpapi/stream.go+++ b/internal/httpapi/stream.go@@ -374,6 +374,10 @@ func clarifyRepositorySource(repository domain.Repository, selectedBaseBranch st}func (h *streamHandlers) runChatClarify(c *gin.Context, issue domain.Issue, request chatClarifyRequest) {+ if err := clarifyModelEngineError(request.Model); err != nil {+ c.JSON(400, map[string]string{"error": err.Error()})+ return+ }if strings.TrimSpace(issue.ID) != "" {h.handleIssueClarify(c, issue, request)returndiff --git a/web/app/assistant-models.js b/web/app/assistant-models.jsindex 13dd58ed..5d580664 100644--- a/web/app/assistant-models.js+++ b/web/app/assistant-models.js@@ -1,6 +1,7 @@// Shared AI model catalog for the classic SPA. The SOP preview, role, Bot,// scheduler, run-eval and requirement-clarification pickers all read// window.AgentFlowAssistantModels, so this file must load before them.+// Pickers for entries that only run on CodeBuddy use renderCodeBuddyList.// Only the picker chrome lives here; per-feature selections stay in the// callers (localStorage keys, hidden inputs, form fields).(() => {@@ -122,6 +123,23 @@function renderList(menu, selectedId, onPick) {renderOptions(menu, catalog.models || [], selectedId, onPick);}+ // Requirement clarification, Bot replies, run evals and the SOP preview+ // build run on CodeBuddy only, so their pickers list CodeBuddy models and+ // never offer a "codex:…" id the server would have to refuse.+ function codeBuddyModels() {+ return (catalog.models || []).filter(m => (m.engine || 'codebuddy') === 'codebuddy');+ }+ function renderCodeBuddyList(menu, selectedId, onPick) {+ renderOptions(menu, codeBuddyModels(), selectedId, onPick);+ }+ // codeBuddyModel keeps a CodeBuddy id and turns an empty id, or a saved id+ // of another CLI, into the CLI default the server resolves itself.+ function codeBuddyModel(id) {+ const value = String(id || '').trim();+ // The catalog may not have landed yet; the built-in CLI prefixes still count.+ if (!value || /^(codex|claude-code):/.test(value) || engineOf(value) !== 'codebuddy') return DEFAULT_MODEL;+ return value;+ }async function fetchCatalog() {const resp = await fetch('/api/assistant/models', {headers: {Accept: 'application/json'}, credentials: 'same-origin'});if (!resp.ok) throw new Error(`模型列表加载失败(${resp.status})`);@@ -141,10 +159,13 @@window.AgentFlowAssistantModels = {DEFAULT: DEFAULT_MODEL,catalog: () => catalog,+ codeBuddyModel,+ codeBuddyModels,engineOf,load,paint,paintItem,+ renderCodeBuddyList,renderList,renderOptions};diff --git a/web/app/bots.js b/web/app/bots.jsindex cf5d6626..3dd63320 100644--- a/web/app/bots.js+++ b/web/app/bots.js@@ -9,7 +9,7 @@ function bindBotModelPicker(host){toggle.onclick=event=>{event.stopPropagation();if(toggle.disabled||toggle.closest('fieldset')?.disabled)return;const open=menu.hidden;closeBotModelPicker();if(!open)return;- models.renderList(menu,value.value,id=>{value.value=id;models.paint(toggle,id);captureBotDraft(host);closeBotModelPicker()});+ models.renderCodeBuddyList(menu,value.value,id=>{value.value=id;models.paint(toggle,id);captureBotDraft(host);closeBotModelPicker()});const rect=toggle.getBoundingClientRect(),width=Math.min(Math.max(rect.width,320),window.innerWidth-24),height=Math.min(320,window.innerHeight-24),below=window.innerHeight-rect.bottom-12,above=rect.top-12;menu.style.width=width+'px';menu.style.left=Math.max(12,Math.min(rect.left,window.innerWidth-width-12))+'px';const down=below>=Math.min(height,above);const available=down?below:above;diff --git a/web/app/flows.js b/web/app/flows.jsindex 9b3fb6a1..16d6a1d4 100644--- a/web/app/flows.js+++ b/web/app/flows.js@@ -22,7 +22,8 @@ function workflowPreviewModel(wf){}function previewModelChoices(){const api=window.AgentFlowAssistantModels;- const models=api?.catalog?.()?.models;+ // The preview build node runs on CodeBuddy (executorId codebuddy).+ const models=api?.codeBuddyModels?.()||api?.catalog?.()?.models;if(models&&models.length)return models.map(m=>({id:m.id,name:m.name||m.id}));return PREVIEW_MODEL_FALLBACK.slice();}diff --git a/web/app/runs.js b/web/app/runs.jsindex f29c0b4f..36141fb9 100644--- a/web/app/runs.js+++ b/web/app/runs.js@@ -1205,7 +1205,8 @@ function defaultRunEval(){return{enabled:true,version:1,threshold:70,dimensions:{id:'recovery',name:'错误恢复',question:'相同错误是否反复出现?',weight:10},{id:'delivery',name:'交付完整',question:'终态、产物和验证信号是否齐全?',weight:10}]}}-function runEvalModel(){return state.runEvalModel||localStorage.getItem('agentflow.runEvalModel')||(window.AgentFlowAssistantModels&&window.AgentFlowAssistantModels.DEFAULT)||'default'}+// Run evals run on CodeBuddy only; a saved "codex:…" id falls back.+function runEvalModel(){const api=window.AgentFlowAssistantModels,stored=state.runEvalModel||localStorage.getItem('agentflow.runEvalModel')||'';if(api?.codeBuddyModel)return api.codeBuddyModel(stored);return stored||(api&&api.DEFAULT)||'default'}function setRunEvalModel(id){state.runEvalModel=id;localStorage.setItem('agentflow.runEvalModel',id)}function runEvalHasKey(){return !!(userById(state.currentUser?.id)||state.currentUser||{}).codeBuddyApiKeyConfigured}function runEvalApplyable(rec){if(!rec||rec.status==='applied')return false;const action=((rec.target||'')+'.'+(rec.action||'')).replace(/^\./,'').toLowerCase();const full=rec.action&&rec.action.includes('.')?rec.action.toLowerCase():action;return ['workflow.update_node','agent.upsert_gate','agent.remove_gate','agent.append_instructions','agent.append_task_prompt'].includes(full)}@@ -1305,7 +1306,7 @@ function bindRunEvalModelPicker(host){const open=menu.hidden;menu.hidden=!open;toggle.setAttribute('aria-expanded',open?'true':'false');- if(open)api.renderList(menu,runEvalModel(),id=>{setRunEvalModel(id);paint();menu.hidden=true;toggle.setAttribute('aria-expanded','false')});+ if(open)api.renderCodeBuddyList(menu,runEvalModel(),id=>{setRunEvalModel(id);paint();menu.hidden=true;toggle.setAttribute('aria-expanded','false')});};document.addEventListener('click',e=>{if(host.contains(e.target))return;menu.hidden=true;toggle.setAttribute('aria-expanded','false')});}diff --git a/web/app/sync-schedule.js b/web/app/sync-schedule.jsindex 7ce9a358..38229149 100644--- a/web/app/sync-schedule.js+++ b/web/app/sync-schedule.js@@ -101,6 +101,8 @@ function scheduleModelAPI(){return window.AgentFlowAssistantModels}function selectedClarifyModel(){const api=window.AgentFlowAssistantModels;const stored=localStorage.getItem('agentflow.clarifyModel')||'';+ // Clarification runs on CodeBuddy only; a saved "codex:…" id falls back.+ if(api?.codeBuddyModel)return api.codeBuddyModel(stored);return stored||(api&&api.DEFAULT)||'default';}function setClarifyModel(id){@@ -138,7 +140,7 @@ function bindClarifyModelPicker(host){menu.hidden=!open;toggle.setAttribute('aria-expanded',open?'true':'false');if(open){- api.renderList(menu, selectedClarifyModel(), id=>{+ api.renderCodeBuddyList(menu, selectedClarifyModel(), id=>{setClarifyModel(id);api.paint(toggle, id);menu.hidden=true;diff --git a/web/assistant_models_test.js b/web/assistant_models_test.jsindex dfaea544..76b4285b 100644--- a/web/assistant_models_test.js+++ b/web/assistant_models_test.js@@ -72,7 +72,9 @@ const ctx = {models: [{ id: 'model-a', name: 'Model A', family: 'claude', credits: 'x1.00' },{ id: 'model-b', name: 'Model B', family: 'glm', credits: 'x0.06' },+ { id: 'codex:gpt-5.5', name: 'GPT-5.5', family: 'gpt', engine: 'codex' },],+ engines: [{ id: 'codebuddy', name: 'CodeBuddy' }, { id: 'codex', name: 'Codex' }],}),}),};@@ -91,13 +93,20 @@ vm.runInContext(moduleSource, ctx);assert.equal(api.DEFAULT, 'default');// Pickers keep painting before the catalog lands, so the built-in fallback// must already render a usable label.+ assert.equal(api.codeBuddyModel('codex:gpt-5.5'), 'default', 'codex ids fall back before the catalog loads');api.paint(toggle, api.DEFAULT);assert.equal(label.textContent, 'CLI 默认模型');assert.equal(icon.dataset.family, 'other');await api.load();assert.equal(api.catalog().default, 'model-b');- assert.equal(api.catalog().models.length, 2, 'catalog adopts /api/assistant/models');+ assert.equal(api.catalog().models.length, 3, 'catalog adopts /api/assistant/models');+ // Issue #228: clarification runs on CodeBuddy only, so CodeBuddy-only+ // pickers hide other CLIs and a saved "codex:…" id falls back.+ assert.deepEqual(api.codeBuddyModels().map(m => m.id), ['model-a', 'model-b']);+ assert.equal(api.codeBuddyModel('codex:gpt-5.5'), 'default');+ assert.equal(api.codeBuddyModel(''), 'default');+ assert.equal(api.codeBuddyModel('model-a'), 'model-a');// Pull the real picker helpers out of the bundle and bind them to the stub host.for (const name of ['selectedClarifyModel', 'setClarifyModel', 'bindClarifyModelPicker']) {@@ -112,7 +121,8 @@ vm.runInContext(moduleSource, ctx);toggle.onclick({ stopPropagation() {} });assert.equal(menu.hidden, false, 'clicking 选择模型 must open the menu');- assert.equal(menu.children.length, 2, 'menu lists the catalog models');+ assert.equal(menu.children.length, 2, 'menu lists only CodeBuddy models');+ assert.ok(!menu.children.some(opt => opt.dataset.id.startsWith('codex:')), 'clarify menu hides Codex models');assert.ok(menu.children[0].className.includes('is-active'), 'stored model is marked active');menu.children[1].onclick();@@ -120,5 +130,9 @@ vm.runInContext(moduleSource, ctx);assert.equal(input.value, 'model-b');assert.equal(menu.hidden, true);assert.equal(label.textContent, 'Model B');++ // A Codex id saved before this fix must not reach chat-clarify.+ store.set('agentflow.clarifyModel', 'codex:gpt-5.5');+ assert.equal(ctx.selectedClarifyModel(), 'default');console.log('assistant models ok');})().catch(err => { console.error(err); process.exit(1); });