Tighten ctx-suspend plumbing and trim docs
Address review feedback: - Move ErrSuspendForCheckpoint from checkpoint.go to errors.go next to the rest of the agent error declarations; drop the colon in the error string so it matches the existing `agent run <event>` style used by the supervisor sentinels. - Replace the inline `outerCtx := ctx; ctx = context.WithoutCancel(ctx)` pattern with a small `suspendShield` helper in context.go used by coreLoop, resumeWithOpts, and resumeNested. Reads more cleanly and stops surfacing the WithoutCancel mechanism at every call site. - Trim the doc comments on Run, RunStreamed, Resume, Restore, the ErrSuspendForCheckpoint declaration, and the saveCtx comment in restoreNestedSuspended down to the contract bullet. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -16,21 +16,10 @@ package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"go.probo.inc/probo/pkg/llm"
|
||||
)
|
||||
|
||||
// ErrSuspendForCheckpoint is the recommended cancel cause for callers
|
||||
// who want the agent loop to gracefully suspend (build a checkpoint
|
||||
// and return *SuspendedError) rather than treat the cancellation as a
|
||||
// silent close. The agent loop only inspects ctx.Err(); any cancel
|
||||
// cause produces a graceful suspend, but using this sentinel makes
|
||||
// the intent explicit and lets supervisors distinguish a user-driven
|
||||
// cancel from infrastructure-level causes (lease loss, heartbeat
|
||||
// failure) when they inspect context.Cause(ctx).
|
||||
var ErrSuspendForCheckpoint = errors.New("agent run: graceful suspend requested")
|
||||
|
||||
type (
|
||||
AgentStatus string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user