Skip to content

Add Retrigger control to re-run a Failed task's log modal - #374

Merged
based64god merged 10 commits into
mainfrom
bandolier/add-an-option-to-manuall-kcwv13
Jul 18, 2026
Merged

based64god merged 10 commits into
mainfrom
bandolier/add-an-option-to-manuall-kcwv13

Conversation

@based64god

Copy link
Copy Markdown
Owner

Lets a user re-run a Failed (or cancelled) task as a brand-new run directly from its log modal, by recovering the original run's parameters and replaying them through deploy.

Changes

  • Add an owner-scoped agents.retrigger mutation that reads the original Job's pod template (model, effort, branch, output type, issue/review source, etc.) and replays it through deploy to spawn a fresh task, mirroring terminate's ownership scoping.
  • Add a "Retrigger" button to the log modal header, next to the close ✕, shown only for a Failed (or cancelled) task; on success it surfaces the new task and closes the stale log view.
  • Add a /dev/log-modal dev-only harness route (with ?status= param) for exercising the modal's header controls in a browser.
  • Add unit tests for agents.retrigger (404 on missing job, 400 on missing model, and correct threading of review params) and a Playwright e2e spec asserting the Retrigger control's visibility and placement.

@vercel

vercel Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bandolier Canceled Canceled Nov 8, 2026 8:02pm UTC

Request Review

@bandolier-dev bandolier-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Adds an owner-scoped agents.retrigger mutation that recovers a finished Job's run parameters from its pod-template env and replays them through deploy, plus a Retrigger button in the log-modal header for Failed tasks, a /dev/log-modal harness, unit tests, and a Playwright spec.

The design is sound and safe in the ways that matter most: it deliberately recovers only parameters (never the baked-in secrets), re-resolves credentials via deploy, mirrors terminate's owner-scoped label selector for the job lookup, and delegates the real authorization gate to deploy (which re-runs assertRepoAccess on the annotation-derived repo). Env-var names line up with what create-job.ts writes, the issue/review "don't double-expand CLAUDE_TASK" reasoning is correct, and the DOM ordering the e2e asserts matches the Modal layout. Tests pass locally (6/6). Nice work.

I have no blocking concerns — a few parameter-fidelity gaps worth a look, all of which degrade gracefully rather than break:

  1. modelProvider / modelAuth are not recovered (agents.ts ~1165). The original deploy pins the run to a specific provider and credential kind (subscription vs. metered API key) via these fields; retrigger omits both, so the re-run falls back to selectRunCredentials' precedence. For a model id served by more than one provider, or a run the user pinned to a subscription, the retriggered run can silently land on a different backend or a metered key (cost implication) than the original. Worth documenting as an intentional limitation, or recovering where feasible.

  2. Issue-run operator context is dropped (agents.ts ~1161). For an issue-sourced run, task becomes "" and deploy re-expands from GitHub with empty additional context. The operator's extra task text from the original run isn't recoverable from CLAUDE_TASK (which holds the already-expanded prompt), so the re-run loses it. Given the code can't cleanly recover it, a one-line comment noting the loss would help.

  3. Per-task compute overrides (cpu/memory) are not recovered — a run with a custom CPU/memory limit re-runs on repo/user defaults. Minor, but a fidelity gap in the same family as (1).

  4. Failure feedback is tooltip-only (log-modal.tsx:329). On a rejected retrigger the only signal is retrigger.error?.message in the button title; the button just re-enables with no visible toast/inline error. Easy to miss.

  5. canRetrigger only checks status === "Failed" (log-modal.tsx:229), yet the PR title/description say "Failed (or cancelled)". Pod phase has no "Cancelled" value, so this is fine if cancelled tasks surface as phase Failed — worth confirming the cancelled path actually reaches this button, otherwise that half of the description is unreachable.

None of these block merging.

repoFullName:
input.repoFullName ?? annotations["bandolier.io/repo"] ?? undefined,
branch: envValue("BRANCH") ?? "main",
model,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modelProvider and modelAuth from the original run aren't recovered here, so deploy falls back to selectRunCredentials' precedence rather than the provider/credential-kind the original run was pinned to. For a model id served by multiple providers this can re-run on a different backend, and a run pinned to a subscription can re-run on a metered API key (cost implication). If they can't be recovered reliably, consider a comment marking this as an intentional limitation.

Comment thread web/src/server/api/routers/agents.ts Outdated
// deploy time, so replaying the already-expanded CLAUDE_TASK would apply
// that context twice; hand them their source instead. Everything else
// replays the task prompt verbatim.
const task =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For an issue-sourced run this correctly avoids double-expanding CLAUDE_TASK, but the operator's original additional context (the raw task passed alongside the issue) is lost — deploy re-expands with an empty task. Since it isn't separately recoverable from the env, a note here about the dropped context would save a future reader some confusion.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix this. User's additional context should be preserved between re-runs.


// A finished-but-unsuccessful task can be re-run from here (needs its job
// name to look the original up server-side).
const canRetrigger = status === "Failed" && !!jobName;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only status === "Failed" enables the control, but the PR describes "Failed (or cancelled)". K8s pod phase has no Cancelled value — confirm cancelled/terminated tasks actually surface here as phase Failed, otherwise the cancelled case is unreachable from this button.

}}
disabled={retrigger.isPending}
title={
retrigger.error?.message ?? "Run this task again as a new task"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a failed retrigger the only feedback is this title tooltip; the button silently re-enables. Consider a visible inline/toast error so a user who isn't hovering knows the re-run didn't happen.

@based64god
based64god force-pushed the bandolier/add-an-option-to-manuall-kcwv13 branch from d591a49 to b302c41 Compare July 18, 2026 06:11
@bandolier-dev

bandolier-dev Bot commented Jul 18, 2026

Copy link
Copy Markdown

🤖 Bando is resuming work on this pull request.

View task on the dashboard (job: bandolier-agent-1784357838813, resumes bandolier-agent-1784348356029)

@github-actions
github-actions Bot force-pushed the bandolier/add-an-option-to-manuall-kcwv13 branch from b302c41 to 83d8d2f Compare July 18, 2026 07:00

@bandolier-dev bandolier-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of PR #374 (updated)

The two new commits (extractOperatorContext + preserve the operator's additional context on retrigger) cleanly resolve point #2 from my previous review — an issue-run retrigger no longer silently drops the operator's additional context.

I traced the full round-trip and it's correct:

  • buildIssueUserMessage appends operator context under a single OPERATOR_CONTEXT_HEADING constant, now shared with the extractor.
  • extractOperatorContext splits on the exact \n\n<heading>\n\n marker and returns the trailing section (or ""), inverting the builder precisely.
  • retrigger passes that recovered context back as task, and deploy → resolveIssueContext → buildIssueUserMessage(issue, operatorTask) re-embeds it alongside the freshly-fetched issue body — so the issue body isn't double-expanded and the operator's note survives.
  • Review runs still replay with an empty task (PR rebuilt from GitHub); plain runs replay CLAUDE_TASK verbatim.

Unit coverage is good: the new extractOperatorContext describe block covers the happy path, multi-paragraph verbatim preservation, and the empty case. All 34 tests in issue-prompt.test.ts + agents.deploy.test.ts pass locally.

Still open from the previous review (all non-blocking)

These weren't part of this update and remain as-is:

  1. modelProvider / modelAuth not recovered — a run pinned to a subscription (or an ambiguous multi-provider model id) can re-run on a different backend / metered key, since retrigger only forwards model.
  2. Per-task cpu / memory overrides not recovered — a retrigger falls back to repo/user defaults rather than the original run's compute.
  3. Retrigger failure only surfaces in the button title tooltip — an error is easy to miss; the modal also closes on success but a failed mutation leaves the user without a visible message.
  4. Client gates on status === "Failed" only, while the PR title/description say "Failed (or cancelled)." Worth confirming a cancelled/terminated task actually reports phase "Failed" here (its pod is deleted on terminate), otherwise the "or cancelled" affordance never appears.

Minor note on the new code

extractOperatorContext uses indexOf on the marker, so if an issue body itself contained the literal line ## Additional context from the operator surrounded by blank lines, the earlier (body) occurrence would win and mis-extract. This is pathological and not worth guarding in practice — flagging only for awareness.

Overall this is a solid, well-tested increment that addresses the most substantive of my earlier points.

const marker = `\n\n${OPERATOR_CONTEXT_HEADING}\n\n`;
const at = issueUserMessage.indexOf(marker);
if (at === -1) return "";
return issueUserMessage.slice(at + marker.length).trim();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice inverse — sharing OPERATOR_CONTEXT_HEADING between builder and extractor keeps the round-trip in lockstep. One marginal edge: indexOf takes the first marker occurrence, so an issue body that itself contained this exact heading (with surrounding blank lines) would mis-extract. Pathological and fine to leave; noting for awareness.

? extractOperatorContext(storedTask)
: storedTask;

const caller = createCallerFactory(agentsRouter)(ctx);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modelProvider/modelAuth and the per-task cpu/memory overrides still aren't recovered from the original Job's env here, so a retrigger can land on a different credential kind or different compute than the run it replays. Non-blocking, but the env carries enough (provider/auth aren't stored, but compute is on the pod spec) to close the compute gap if you want parity.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix this

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still unfixed. We should guarantee that reruns use the same keys and model provider.

@bandolier-dev

bandolier-dev Bot commented Jul 18, 2026

Copy link
Copy Markdown

🤖 Bando is resuming work on this pull request.

View task on the dashboard (job: bandolier-agent-1784359678569, resumes bandolier-agent-1784357838813)

@bandolier-dev bandolier-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — retrigger now replays the original run's compute

The two new commits (fix(agents): replay the original run's compute on retrigger + its test) address point #3 from my earlier review: the per-task CPU/memory are no longer dropped on re-run. I traced the full round-trip and it's correct:

  • retrigger reads container.resources.limits.{cpu,memory} from the original Job's pod spec and threads them into deploy as cpu/memory.
  • deploy runs them back through parseComputeInput → mergeCompute, where the explicit override beats the re-resolved repo/user defaults, and podResources re-derives requests = limits/2 consistently.
  • The new unit test asserts parseComputeInput is called with the exact recovered quantities ("4", "8Gi"). All 35 tests in the two touched suites pass locally.

Combined with the earlier commit, this closes points #2 (operator context) and #3 (compute) from my first pass. Nothing in the new diff is blocking — keeping this as a COMMENT.

One consideration on the new code (non-blocking)

Because podResources always stamps a limit onto the pod (falling back to DEFAULT_CPU_LIMIT/DEFAULT_MEMORY_LIMIT when no override was given), the recovered limits are always present, so every retrigger now pins the compute the original run happened to get — even runs that never set an override. That's the stated intent (comment: "lands on the same box … rather than re-deriving from the (possibly since changed) repo/user defaults"), and it's a reasonable default. The one edge worth being aware of: a task that Failed because its compute was too low (e.g. OOMKilled) will retrigger with the identical limits and fail the same way, rather than picking up a since-raised repo default. Fine to leave as-is; flagging only so the tradeoff is a conscious one.

Still open from the earlier review (unchanged, all non-blocking)

  • modelProvider/modelAuth aren't recovered — a run pinned to a subscription or an ambiguous multi-provider model id can re-run on a different backend / metered key.
  • Retrigger failure surfaces only in the button's title tooltip; a user who doesn't hover won't see why nothing happened.
  • The client gates the control on status === "Failed" while the PR/UI copy says "Failed (or cancelled)" — a terminated pod is deleted and won't appear in the list, so "cancelled" is effectively unreachable here. Worth aligning the wording with the actual gate.

Nice, well-tested increment overall.

// though: replay the exact CPU/memory limits the run used so a retrigger
// lands on the same box, rather than re-deriving from the (possibly since
// changed) repo/user defaults.
const limits = container?.resources?.limits;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid — this closes the compute-parity gap from the last review. Note the round-trip pins compute unconditionally: podResources always stamps a limits value (defaulting to DEFAULT_CPU_LIMIT/DEFAULT_MEMORY_LIMIT), so even runs that set no override get their effective limits recovered and replayed here as an explicit override. Intended per the comment, but it does mean a run that Failed due to insufficient compute (e.g. OOMKilled) will retrigger with the same limits rather than a since-raised repo default. Non-blocking.

@github-actions
github-actions Bot force-pushed the bandolier/add-an-option-to-manuall-kcwv13 branch from 1422bfa to 145e02c Compare July 18, 2026 16:28
@bandolier-dev

bandolier-dev Bot commented Jul 18, 2026

Copy link
Copy Markdown

🤖 Bando is resuming work on this pull request.

View task on the dashboard (job: bandolier-agent-1784392361508, resumes bandolier-agent-1784359678569)

@github-actions
github-actions Bot force-pushed the bandolier/add-an-option-to-manuall-kcwv13 branch 2 times, most recently from d8c8a52 to 6862ed7 Compare July 18, 2026 16:38
Recovers a run's parameters (task, model, branch, effort, output type,
issue/review source, …) from the original Job's pod template and replays
them through `deploy`, so a Failed or cancelled task can be run again as a
brand-new task under freshly resolved credentials. Owner-scoped, mirroring
`terminate`: a shared repo namespace still only lets you retrigger your own
tasks.

Signed-off-by: based64god <6633471+based64god@users.noreply.github.com>
Adds a "Retrigger" button to the log modal header, beside the close ✕, shown
only for a Failed (or cancelled) task. It calls agents.retrigger and, on
success, surfaces the fresh task in the list and closes the now-stale log view.

Signed-off-by: based64god <6633471+based64god@users.noreply.github.com>
Unit tests exercise the retrigger mutation's job lookup and parameter
recovery (404 when the job is gone, model-required guard, and review params
threaded back into deploy). A /dev/log-modal harness plus a browser smoke
test assert the Retrigger control renders beside the close ✕ for a Failed
task and is absent otherwise.

Signed-off-by: based64god <6633471+based64god@users.noreply.github.com>
…ntext

The inverse of buildIssueUserMessage: pulls the operator's additional
context back out of an already-expanded issue user message. Both sides now
share a single heading constant so the round trip can't drift.

Signed-off-by: based64god <6633471+based64god@users.noreply.github.com>
An issue-sourced run bakes the operator's additional context into
CLAUDE_TASK under a dedicated heading, alongside the issue body. Retrigger
was dropping the whole task to avoid double-expanding the issue body, which
also silently lost that operator context. Recover just the operator section
via extractOperatorContext and hand it back to deploy, which re-embeds it
alongside the freshly fetched issue. Review runs still replay with an empty
task since they carry no operator context.

Signed-off-by: based64god <6633471+based64god@users.noreply.github.com>
The provider/auth kind a run resolved to isn't stored on the Job, so
credentials stay freshly re-resolved by deploy. Compute, though, is on the
pod spec: recover the CPU/memory limits the run used and hand them back to
deploy so a retrigger lands on the same box, rather than silently re-deriving
from the (possibly since changed) repo/user defaults.

Signed-off-by: based64god <6633471+based64god@users.noreply.github.com>
Spies on parseComputeInput so the recovered pod-spec limits can be observed
threading into deploy, and extends fakeJob to carry resource limits.

Signed-off-by: based64god <6633471+based64god@users.noreply.github.com>
@github-actions
github-actions Bot force-pushed the bandolier/add-an-option-to-manuall-kcwv13 branch from 6862ed7 to bf7f09a Compare July 18, 2026 16:41
Add modelProvider/modelAuth to JobSpec and stamp them as annotations
(bandolier.io/model-provider, bandolier.io/model-auth) on the Job and pod.
The secrets themselves are never recoverable, but which provider and
credential kind a run resolved to is exactly what a retrigger needs to replay
the run on the same keys instead of re-deriving from the current precedence.

Signed-off-by: based64god <6633471+based64god@users.noreply.github.com>
…igger

deploy now stamps the provider + credential kind it resolved to onto the Job,
and retrigger reads them back off the annotations and threads them into deploy
as modelProvider/modelAuth. Without this, a retrigger re-derived credentials
from the current precedence, so it could land on a different provider or a
different credential kind (metered API key vs. subscription) than the run it
replays. deploy still resolves the secret material freshly — only the
selection is pinned.

Signed-off-by: based64god <6633471+based64god@users.noreply.github.com>
… trip

Asserts createAgentJob stamps the model-provider/model-auth annotations, and
that retrigger threads the recovered selection into deploy: a run recorded on
Gemini (or the subscription kind) re-runs against those, surfacing the
no-credentials error when only an Anthropic API key is configured — proving the
recorded selection, not the current precedence, drives the re-run.

Signed-off-by: based64god <6633471+based64god@users.noreply.github.com>

@bandolier-dev bandolier-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review after the provider/auth commits. This update adds three commits that close point #1 from my first review — the run's resolved provider and credential kind are now recovered on retrigger, so a re-run no longer silently lands on a different backend or a differently-metered key.

I verified the round-trip end to end:

  • buildJobManifest (create-job.ts:769-777) stamps bandolier.io/model-provider and bandolier.io/model-auth onto the shared annotations object, so they land on both the Job metadata and the pod template — and retrigger reads job.metadata.annotations, which is populated. The RunProviderName covers the gollm:<id> case, and the deploy input's z.enum(...).or(z.custom<gollm:...>) schema re-validates whatever the annotation held, so a tampered/legacy value is rejected rather than trusted blindly.
  • retrigger threads modelProvider/modelAuth into deploy, which feeds them to selectRunCredentials — the selection is replayed while the secret material is still resolved fresh. Secrets remain unrecoverable from the Job.
  • New tests are sharp: the deploy suite proves the recovered provider (Gemini) and auth kind (subscription) actually drive credential selection — each fails with No model credentials because only an Anthropic key exists, which only happens if the annotation, not the current precedence, won. create-job asserts both annotation placements. tsc --noEmit is clean and all 81 tests across the two touched suites pass locally.

With this, my earlier points #1 (provider/auth), #2 (operator context), and #3 (compute) are all resolved — I'm not repeating that feedback.

One conscious tradeoff to note (non-blocking, same shape as the compute pinning): pinning provider + auth means a retrigger now fails with No model credentials if the user has since removed those specific credentials, rather than gracefully falling back to another configured provider. That's the intended fidelity-over-convenience choice and the error is clear, so I'd only surface it in release notes. Legacy Jobs deployed before this PR carry no annotation and degrade to the old precedence-based behavior — fine.

Remaining non-blocking items from earlier still stand: retrigger failure only surfaces in the button tooltip (retrigger.error?.message), and the client still gates the control on status === "Failed" while the PR copy says "Failed (or cancelled)" — worth confirming a cancelled task actually reports status "Failed" here, or the control never appears for it.

Solid, well-tested increment. Keeping this as COMMENT.

// on the same keys, not whatever is primary now. `deploy` still resolves
// the secret material freshly; only the *selection* is replayed. The
// secrets themselves are never recoverable from the Job.
const modelProvider = annotations["bandolier.io/model-provider"] as

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice: pinning to the recorded provider/auth means a re-run replays the original credential selection instead of re-deriving from the current precedence. The cast to RunProviderName/AuthKind is safe because deploy's modelProvider/modelAuth zod schema re-validates the annotation value downstream. One tradeoff worth being aware of: if the user has since removed those specific credentials, the retrigger fails with No model credentials rather than falling back to another configured provider — intended fidelity, just flag it in release notes.

@based64god
based64god merged commit ff53ba6 into main Jul 18, 2026
12 of 13 checks passed
@based64god
based64god deleted the bandolier/add-an-option-to-manuall-kcwv13 branch July 18, 2026 20:03

This branch had an error being deployed

1 failed deployment
production — db755e81 Deployed Jul 18, 2026 by based64god via delete-branch #281
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant