From 5ea115746c3a16598f60180a33ec011e50800b02 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Tue, 10 Nov 2026 23:19:29 +1100 Subject: [PATCH] fix(dashboard): blocked tasks say what they need, and a provider refusal names its fix --- CHANGELOG.md | 12 ++++++ internal/agentexec/modelloop/loop_runner.go | 22 ++++++++++- internal/domain/agentrun/runner.go | 11 ++++++ internal/domain/workflow/step_flow_test.go | 6 +++ internal/domain/workflow/task/task.go | 3 ++ internal/domain/workflow/workflow.go | 15 +++++++- internal/gateway/gateway.go | 2 +- .../agenttransport/nats/transport.go | 6 +++ internal/infrastructure/postgres/resources.go | 2 +- .../infrastructure/staterpc/task_grants.go | 7 ++++ .../staterpc/usage_grant_test.go | 22 ++++++----- internal/taskstate/taskstate.go | 5 ++- internal/webui/task_recovery.go | 38 ++++++++++++------- ui/src/dashboard/DashboardPage.vue | 2 +- ui/src/dashboard/LiveActivityCard.vue | 2 +- ui/src/dashboard/NeedsAttentionCard.vue | 16 ++++++-- ui/src/dashboard/QuickTask.vue | 4 +- ui/src/dashboard/activity-filter.ts | 4 +- ui/src/lib/task-meta-snapshot.ts | 2 +- ui/src/tasks/TaskHeader.vue | 2 +- ui/src/tasks/task.ts | 2 +- 21 files changed, 143 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4b975e9b..5353f2afb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ release's per-component sections are labelled beneath its heading. ## [Unreleased] +### archied + +- A model provider that refuses a task's credential or has run out of credit now blocks the task with a fix to follow, instead of leaving a raw API error, and the task is flagged for retry once the provider settings change. +- New Google providers added from the catalogue work without setting a base URL. + +### archie-ui + +- Parked tasks are shown as Blocked. The dashboard's attention list says what each task is missing in words, keeps the raw error on hover, and makes the fix the primary action ahead of Retry. +- The task bar reads "Describe what Archie should do" and labels its workflow picker. Activity opens on Tasks. +- A reopened conversation shows why a chat turn failed instead of leaving the question unanswered. +- Revoking an API token on the account page works. + ## [1.62.0] - 2026-11-10 ### archied diff --git a/internal/agentexec/modelloop/loop_runner.go b/internal/agentexec/modelloop/loop_runner.go index 227ae5feb..86866bfe0 100644 --- a/internal/agentexec/modelloop/loop_runner.go +++ b/internal/agentexec/modelloop/loop_runner.go @@ -3,17 +3,21 @@ package modelloop import ( "context" "encoding/json" + "errors" "fmt" "log/slog" "maps" + "net/http" "slices" "github.com/samcharles93/ai-sdk/agentloop" "github.com/samcharles93/ai-sdk/core" + errx "github.com/samcharles93/ai-sdk/error" "github.com/samcharles93/ai-sdk/runtime" "github.com/samcharles93/archie-core/internal/agentexec" "github.com/samcharles93/archie-core/internal/domain/agentrun" + "github.com/samcharles93/archie-core/internal/taskstate" "github.com/samcharles93/archie-core/internal/tools" ) @@ -115,7 +119,23 @@ func (r *LoopRunner) Run(ctx context.Context, workspace string, req agentrun.Req if cause := context.Cause(ctx); cause != nil { return result, cause } - return result, err + return result, providerBlocked(err) +} + +// providerBlocked marks a provider refusal the operator must fix: a rejected +// credential, or an account without credit. Retrying either fails the same way. +func providerBlocked(err error) error { + failure, ok := errors.AsType[*errx.ProviderError](err) + if !ok { + return err + } + switch failure.StatusCode { + case http.StatusUnauthorized, http.StatusForbidden: + return &agentrun.BlockedError{Blocker: taskstate.BlockerModelCredential, Err: err} + case http.StatusPaymentRequired: + return &agentrun.BlockedError{Blocker: taskstate.BlockerModelCredit, Err: err} + } + return err } func resultFromRun(req agentrun.Request, res agentloop.Result, appended []string, captures map[string][]json.RawMessage) agentrun.Result { diff --git a/internal/domain/agentrun/runner.go b/internal/domain/agentrun/runner.go index 484db1f20..1b4c73085 100644 --- a/internal/domain/agentrun/runner.go +++ b/internal/domain/agentrun/runner.go @@ -83,3 +83,14 @@ type TranscriptToolCall struct { Args string `json:"args,omitempty"` ArgsBytes int `json:"args_bytes,omitempty"` } + +// BlockedError is a run failure an operator fixes outside the run, such as a +// model provider refusing its credential. Blocker is the taskstate blocker +// that names the fix. +type BlockedError struct { + Blocker string + Err error +} + +func (e *BlockedError) Error() string { return e.Err.Error() } +func (e *BlockedError) Unwrap() error { return e.Err } diff --git a/internal/domain/workflow/step_flow_test.go b/internal/domain/workflow/step_flow_test.go index 575ca7a82..06ffae362 100644 --- a/internal/domain/workflow/step_flow_test.go +++ b/internal/domain/workflow/step_flow_test.go @@ -32,6 +32,7 @@ type fakeTransition struct { taskID int64 from, to string detail string + blocker string } func (f *fakeStepStore) Update(context.Context, *task.Task) error { return nil } @@ -41,6 +42,11 @@ func (f *fakeStepStore) Transition(_ context.Context, taskID int64, from, to, de return nil } +func (f *fakeStepStore) ParkTask(_ context.Context, taskID int64, from, detail, _, blocker string) error { + f.transitions = append(f.transitions, fakeTransition{taskID: taskID, from: from, to: task.StatusParked, detail: detail, blocker: blocker}) + return nil +} + func (f *fakeStepStore) InsertEvent(_ context.Context, e events.Event) (int64, error) { f.events = append(f.events, e) return 0, nil diff --git a/internal/domain/workflow/task/task.go b/internal/domain/workflow/task/task.go index c1feb5e4c..f4fdf19e0 100644 --- a/internal/domain/workflow/task/task.go +++ b/internal/domain/workflow/task/task.go @@ -211,6 +211,9 @@ func (t Task) EffectivePRNumber() int { type Store interface { Update(ctx context.Context, t *Task) error Transition(ctx context.Context, taskID int64, from, to, detail string) error + // ParkTask parks a running task with the class and blocker its park site + // chose, so the dashboard can route the operator to the fix. + ParkTask(ctx context.Context, taskID int64, from, detail, class, blocker string) error InsertEvent(ctx context.Context, e events.Event) (int64, error) // StartStep records a step entering running and returns its id and the // persisted event. diff --git a/internal/domain/workflow/workflow.go b/internal/domain/workflow/workflow.go index 9c7ee96e0..387d586a4 100644 --- a/internal/domain/workflow/workflow.go +++ b/internal/domain/workflow/workflow.go @@ -5,6 +5,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "log/slog" "maps" @@ -555,6 +556,9 @@ func endsRun(ctx context.Context, tc *TaskContext, stage Stage, err error, log, // Parking here publishes the failure; the store has already // recorded the step that produced it. tc.Task.ParkReason = fmt.Sprintf("stage %s: %v", stage.Name, err) + if blocked, ok := errors.AsType[*agentrun.BlockedError](err); ok { + tc.Task.ParkBlocker = blocked.Blocker + } park(ctx, tc, tc.Task.ParkReason) return true } @@ -643,7 +647,7 @@ func park(ctx context.Context, tc *TaskContext, reason string) { if err := tc.Store.Update(ctx, t); err != nil { tc.Log.ErrorContext(ctx, "task fields could not be persisted while parking", "err", err) } - if err := tc.Store.Transition(ctx, t.ID, StatusRunning, StatusParked, reason); err != nil { + if err := parkTransition(ctx, tc, t, reason); err != nil { tc.Log.ErrorContext(ctx, "task park transition failed", "err", err) return } @@ -660,6 +664,15 @@ func park(ctx context.Context, tc *TaskContext, reason string) { tc.Log.ErrorContext(ctx, "task parked", "stage", tc.Stage, "reason", reason) } +// parkTransition moves the task to parked, through the classified park when +// the failure names what the operator must fix. +func parkTransition(ctx context.Context, tc *TaskContext, t *Task, reason string) error { + if t.ParkBlocker == "" { + return tc.Store.Transition(ctx, t.ID, StatusRunning, StatusParked, reason) + } + return tc.Store.ParkTask(ctx, t.ID, StatusRunning, reason, taskstate.ParkNeedsDecision, t.ParkBlocker) +} + const clipMarker = "\n…(truncated)" // clip bounds s to n bytes, marker included, cut on a rune boundary, so a diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go index fede657ef..eaf8abad5 100644 --- a/internal/gateway/gateway.go +++ b/internal/gateway/gateway.go @@ -699,7 +699,7 @@ type taskStateDisplay struct { var taskStateDisplays = map[string]taskStateDisplay{ taskstate.Running: {icon: "▶", label: "Running"}, taskstate.WaitingApproval: {icon: "👤", label: "Waiting"}, - taskstate.Parked: {icon: "⏸", label: "Parked"}, + taskstate.Parked: {icon: "⏸", label: "Blocked"}, taskstate.Queued: {icon: "⏳", label: "Queued"}, taskstate.PROpen: {icon: "🔀", label: "PR open"}, taskstate.Merged: {icon: "✅", label: "Merged"}, diff --git a/internal/infrastructure/agenttransport/nats/transport.go b/internal/infrastructure/agenttransport/nats/transport.go index 356851bd6..e1447826c 100644 --- a/internal/infrastructure/agenttransport/nats/transport.go +++ b/internal/infrastructure/agenttransport/nats/transport.go @@ -232,6 +232,12 @@ func (d deadlineStore) Transition(ctx context.Context, taskID int64, from, to, d return d.Store.Transition(ctx, taskID, from, to, detail) } +func (d deadlineStore) ParkTask(ctx context.Context, taskID int64, from, detail, class, blocker string) error { + ctx, cancel := d.withDeadline(ctx) + defer cancel() + return d.Store.ParkTask(ctx, taskID, from, detail, class, blocker) +} + func (d deadlineStore) InsertEvent(ctx context.Context, e events.Event) (int64, error) { ctx, cancel := d.withDeadline(ctx) defer cancel() diff --git a/internal/infrastructure/postgres/resources.go b/internal/infrastructure/postgres/resources.go index e8bebabef..f9032e12a 100644 --- a/internal/infrastructure/postgres/resources.go +++ b/internal/infrastructure/postgres/resources.go @@ -99,7 +99,7 @@ func blockersFixedBy(kind string) []string { case "credential-bindings": return []string{taskstate.BlockerConnectionCredential, taskstate.BlockerModelCredential} case "provider-settings": - return []string{taskstate.BlockerModelCredential} + return []string{taskstate.BlockerModelCredential, taskstate.BlockerModelCredit} case "workflow-enablement": return []string{taskstate.BlockerWorkflowDisabled} } diff --git a/internal/infrastructure/staterpc/task_grants.go b/internal/infrastructure/staterpc/task_grants.go index bacb15b6d..e08b3854d 100644 --- a/internal/infrastructure/staterpc/task_grants.go +++ b/internal/infrastructure/staterpc/task_grants.go @@ -118,6 +118,13 @@ var taskScopedTargets = map[string]func(any) int64{ } return r.TaskId }, + pb.TaskService_ParkTask_FullMethodName: func(req any) int64 { + r, ok := req.(*pb.ParkTaskRequest) + if !ok { + return 0 + } + return r.TaskId + }, pb.TaskEventService_InsertEvent_FullMethodName: func(req any) int64 { r, ok := req.(*pb.InsertEventRequest) if !ok || r.Event == nil { diff --git a/internal/infrastructure/staterpc/usage_grant_test.go b/internal/infrastructure/staterpc/usage_grant_test.go index f7d40d4a2..7c7b23961 100644 --- a/internal/infrastructure/staterpc/usage_grant_test.go +++ b/internal/infrastructure/staterpc/usage_grant_test.go @@ -6,22 +6,24 @@ import ( pb "github.com/samcharles93/archie-core/internal/contracts/state/v1" ) -// A run credential records usage only against its own task, so one tenant's -// task cannot bill another's. -func TestRecordUsageAuthority(t *testing.T) { +// A run credential acts only on its own task: it records usage and parks +// against task 7, so one tenant's task cannot bill or park another's. +func TestTaskScopedCallAuthority(t *testing.T) { for _, tt := range []struct { name string - record *pb.UsageRecord + method string + req any allowed bool }{ - {"own task", &pb.UsageRecord{TaskId: 7}, true}, - {"another task", &pb.UsageRecord{TaskId: 8}, false}, - {"no task", &pb.UsageRecord{Source: "chat"}, false}, - {"no record", nil, false}, + {"usage on own task", pb.ExecutionService_RecordUsage_FullMethodName, &pb.RecordUsageRequest{Record: &pb.UsageRecord{TaskId: 7}}, true}, + {"usage on another task", pb.ExecutionService_RecordUsage_FullMethodName, &pb.RecordUsageRequest{Record: &pb.UsageRecord{TaskId: 8}}, false}, + {"usage with no task", pb.ExecutionService_RecordUsage_FullMethodName, &pb.RecordUsageRequest{Record: &pb.UsageRecord{Source: "chat"}}, false}, + {"usage with no record", pb.ExecutionService_RecordUsage_FullMethodName, &pb.RecordUsageRequest{}, false}, + {"park own task", pb.TaskService_ParkTask_FullMethodName, &pb.ParkTaskRequest{TaskId: 7, Blocker: "model_credit"}, true}, + {"park another task", pb.TaskService_ParkTask_FullMethodName, &pb.ParkTaskRequest{TaskId: 8, Blocker: "model_credit"}, false}, } { t.Run(tt.name, func(t *testing.T) { - req := &pb.RecordUsageRequest{Record: tt.record} - if got := authorizesTaskScopedCall(pb.ExecutionService_RecordUsage_FullMethodName, req, 7); got != tt.allowed { + if got := authorizesTaskScopedCall(tt.method, tt.req, 7); got != tt.allowed { t.Fatalf("authorized = %v, want %v", got, tt.allowed) } }) diff --git a/internal/taskstate/taskstate.go b/internal/taskstate/taskstate.go index dc3b5ccaa..c04898105 100644 --- a/internal/taskstate/taskstate.go +++ b/internal/taskstate/taskstate.go @@ -240,7 +240,7 @@ func Statuses() []StatusMeta { {ID: PROpen, Label: "In review", Kind: "ok"}, {ID: Merged, Label: "Merged", Kind: "ok"}, {ID: Completed, Label: "Done", Kind: "ok"}, - {ID: Parked, Label: "Parked", Kind: "warn", NeedsAttention: true}, + {ID: Parked, Label: "Blocked", Kind: "warn", NeedsAttention: true}, {ID: Dead, Label: "Stopped: retry cap", Kind: "danger"}, {ID: Rejected, Label: "Rejected", Kind: "danger"}, {ID: Declined, Label: "Won't do", Kind: "idle"}, @@ -309,6 +309,9 @@ const ( // BlockerModelCredential: a model provider the run needs has no usable // credential. BlockerModelCredential Blocker = "model_credential" + // BlockerModelCredit: a model provider refused the run for want of + // credit or quota on its account. + BlockerModelCredit Blocker = "model_credit" ) // Blocker is the persisted park blocker string. diff --git a/internal/webui/task_recovery.go b/internal/webui/task_recovery.go index 1a31bf994..5a6c7f020 100644 --- a/internal/webui/task_recovery.go +++ b/internal/webui/task_recovery.go @@ -9,10 +9,12 @@ import ( "github.com/samcharles93/archie-core/internal/taskstate" ) -// taskRecoveryView is the fix for a parked task's blocker: the dashboard page -// that supplies what the task is missing. +// taskRecoveryView is the fix for a parked task's blocker: what the task is +// missing, in words, and the dashboard page that supplies it. The park reason +// keeps the raw error. type taskRecoveryView struct { Blocker taskstate.Blocker `json:"blocker"` + Summary string `json:"summary"` Label string `json:"label"` Link string `json:"link"` } @@ -20,31 +22,39 @@ type taskRecoveryView struct { // recoveryRoute is where a blocker is fixed: the page, and the API write that // page makes, which decides whether the viewer may act there. type recoveryRoute struct { - label, page, method, api string - instance bool + summary, label, page, method, api string + instance bool } func blockerRoute(t *task.Task) (recoveryRoute, bool) { workflowPage := "/workflows?workflow=" + url.QueryEscape(t.Workflow) + connections := recoveryRoute{page: "/org/connections", method: http.MethodPost, api: "/api/control-plane/resources/forge-connections/commands/replace"} + models := recoveryRoute{page: "/org/models", method: http.MethodPost, api: "/api/control-plane/resources/provider-settings/commands/replace"} switch t.ParkBlocker { case taskstate.BlockerWorkflowDisabled: - return recoveryRoute{label: "Enable workflow", page: workflowPage, method: http.MethodPut, api: "/api/workflows/" + url.PathEscape(t.Workflow) + "/enabled"}, true + return recoveryRoute{summary: "Workflow " + t.Workflow + " is disabled", label: "Enable workflow", page: workflowPage, method: http.MethodPut, api: "/api/workflows/" + url.PathEscape(t.Workflow) + "/enabled"}, true case taskstate.BlockerWorkflowIdentity: - return recoveryRoute{label: "Set execution identity", page: workflowPage, method: http.MethodPost, api: "/api/control-plane/resources/workflow-definitions/commands/apply"}, true + return recoveryRoute{summary: "Workflow has no execution identity", label: "Set identity", page: workflowPage, method: http.MethodPost, api: "/api/control-plane/resources/workflow-definitions/commands/apply"}, true case taskstate.BlockerAgentAssignment: - return recoveryRoute{label: "Assign agent", page: "/org/agents", method: http.MethodPut, api: "/api/orgs/" + url.PathEscape(t.OrgOrDefault()) + "/agents/_", instance: true}, true + return recoveryRoute{summary: "Agent is not assigned to this organisation", label: "Assign agent", page: "/org/agents", method: http.MethodPut, api: "/api/orgs/" + url.PathEscape(t.OrgOrDefault()) + "/agents/_", instance: true}, true case taskstate.BlockerConnectionPermit: - return recoveryRoute{label: "Edit connection permissions", page: "/org/connections", method: http.MethodPost, api: "/api/control-plane/resources/forge-connections/commands/replace"}, true + connections.summary, connections.label = "Agent may not use this connection", "Edit permissions" + return connections, true case taskstate.BlockerRepository: - return recoveryRoute{label: "Set up repository", page: "/org/repositories", method: http.MethodPost, api: "/api/control-plane/resources/repository-policies/commands/replace"}, true + return recoveryRoute{summary: "Repository is not set up", label: "Set up repository", page: "/org/repositories", method: http.MethodPost, api: "/api/control-plane/resources/repository-policies/commands/replace"}, true case taskstate.BlockerConnectionCredential: - return recoveryRoute{label: "Fix connection credential", page: "/org/connections", method: http.MethodPost, api: "/api/control-plane/resources/forge-connections/commands/replace"}, true + connections.summary, connections.label = "Connection credential is unavailable", "Fix credential" + return connections, true case taskstate.BlockerForgeExtension: - return recoveryRoute{label: "Enable forge extension", page: "/settings/extensions", method: http.MethodPut, api: "/api/extensions/_/enabled", instance: true}, true + return recoveryRoute{summary: "Forge extension is not running", label: "Enable extension", page: "/settings/extensions", method: http.MethodPut, api: "/api/extensions/_/enabled", instance: true}, true case taskstate.BlockerModelCredential: - return recoveryRoute{label: "Set up model", page: "/org/models", method: http.MethodPost, api: "/api/control-plane/resources/provider-settings/commands/replace"}, true + models.summary, models.label = "Model provider rejected its credential", "Set up model" + return models, true + case taskstate.BlockerModelCredit: + models.summary, models.label = "Model provider is out of credit", "Check provider" + return models, true case taskstate.BlockerPolicyDenied: - return recoveryRoute{label: "Edit policies", page: "/org/policies", method: http.MethodPut, api: "/api/access/policies"}, true + return recoveryRoute{summary: "An access policy refuses the run", label: "Edit policies", page: "/org/policies", method: http.MethodPut, api: "/api/access/policies"}, true } return recoveryRoute{}, false } @@ -62,7 +72,7 @@ func (s *Server) taskRecovery(r *http.Request, t *task.Task) *taskRecoveryView { if !s.mayCall(r, route.method, route.api) { return nil } - return &taskRecoveryView{Blocker: t.ParkBlocker, Label: route.label, Link: route.page} + return &taskRecoveryView{Blocker: t.ParkBlocker, Summary: route.summary, Label: route.label, Link: route.page} } // mayCall reports whether the request's principal may make the API call, the diff --git a/ui/src/dashboard/DashboardPage.vue b/ui/src/dashboard/DashboardPage.vue index 60dc50b16..c4abbe15f 100644 --- a/ui/src/dashboard/DashboardPage.vue +++ b/ui/src/dashboard/DashboardPage.vue @@ -25,7 +25,7 @@ const setupIncomplete = computed(() => setupPanelState(setup.value).kind === "in Archie is not responding: {{ error }}
- +
diff --git a/ui/src/dashboard/LiveActivityCard.vue b/ui/src/dashboard/LiveActivityCard.vue index 7339f7b28..e3ca24b00 100644 --- a/ui/src/dashboard/LiveActivityCard.vue +++ b/ui/src/dashboard/LiveActivityCard.vue @@ -58,7 +58,7 @@ const { activity } = storeToRefs( /** Which view of the feed is showing: everything, task runs, or the daemon's * own background work. */ -const filter = ref("all"); +const filter = ref("tasks"); const shown = computed(() => filterActivity(activity.value, filter.value)); // A blocked task already leads the page under Needs attention. const pinned = computed(() => diff --git a/ui/src/dashboard/NeedsAttentionCard.vue b/ui/src/dashboard/NeedsAttentionCard.vue index c56eb9209..7425dc52e 100644 --- a/ui/src/dashboard/NeedsAttentionCard.vue +++ b/ui/src/dashboard/NeedsAttentionCard.vue @@ -28,7 +28,13 @@ const shown = computed(() => waiting.value.slice(0, 5)); function meta(task: AttentionTask): string { const where = task.owner && task.repo ? `${task.owner}/${task.repo}${task.issue_url && task.issue_number ? ` #${task.issue_number}` : ""}` : ""; - return [where, task.workflow, task.park_reason || task.plan].filter(Boolean).join(" · "); + return [where, task.workflow].filter(Boolean).join(" · "); +} + +// A blocker's summary says what is missing; the raw reason stays on hover and +// on the task page. +function reason(task: AttentionTask): string { + return task.recovery?.summary || task.park_reason || task.plan || ""; } @@ -44,12 +50,14 @@ function meta(task: AttentionTask): string { {{ task.title || `Task ${task.id}` }} -

{{ meta(task) }}

+

+ {{ meta(task) }} +

- - + diff --git a/ui/src/dashboard/QuickTask.vue b/ui/src/dashboard/QuickTask.vue index 5638a4df8..995b299d2 100644 --- a/ui/src/dashboard/QuickTask.vue +++ b/ui/src/dashboard/QuickTask.vue @@ -81,9 +81,9 @@ async function run() {
- +