From 79d57e35d10f7f0becf485168384ada64780ac48 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Mon, 8 Jun 2026 15:20:13 +0200 Subject: [PATCH] Inline error type checks in agent-run handler Drop the isType helper that merely discarded the value already returned by errors.AsType and inline the suspend and interrupt checks directly into the result-handling branch. Signed-off-by: Bryan Frimin --- pkg/agentrun/handler.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pkg/agentrun/handler.go b/pkg/agentrun/handler.go index fb3c9fc6d..f63e21424 100644 --- a/pkg/agentrun/handler.go +++ b/pkg/agentrun/handler.go @@ -197,16 +197,13 @@ func (h *handler) executeRun(ctx context.Context, run *coredata.AgentRun) error // interruption parks it in AWAITING_APPROVAL until an approval // decision requeues it. Anything else is a genuine failure. if runErr != nil { - switch { - case isType[*agent.SuspendedError](runErr): + if _, ok := errors.AsType[*agent.SuspendedError](runErr); ok { run.Status = coredata.AgentRunStatusPending runErr = nil - - case isType[*agent.InterruptedError](runErr): + } else if _, ok := errors.AsType[*agent.InterruptedError](runErr); ok { run.Status = coredata.AgentRunStatusAwaitingApproval runErr = nil - - default: + } else { run.Status = coredata.AgentRunStatusFailed run.Result = nil @@ -257,9 +254,3 @@ func (h *handler) executeRun(ctx context.Context, run *coredata.AgentRun) error return runErr } - -func isType[T error](err error) bool { - _, ok := errors.AsType[T](err) - - return ok -}