mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-07-12 03:06:00 +00:00
20 lines
568 B
Go
20 lines
568 B
Go
package hooks
|
|
|
|
import "context"
|
|
|
|
type ctxKey string
|
|
|
|
const skipHooksKey ctxKey = "skip_hooks"
|
|
|
|
// WithSkipHooks returns a context that signals hook evaluation should be skipped.
|
|
// Used by evaluate_loop and agent evaluator to prevent recursive hook firing.
|
|
func WithSkipHooks(ctx context.Context, skip bool) context.Context {
|
|
return context.WithValue(ctx, skipHooksKey, skip)
|
|
}
|
|
|
|
// SkipHooksFromContext returns true if hooks should be skipped for this context.
|
|
func SkipHooksFromContext(ctx context.Context) bool {
|
|
v, _ := ctx.Value(skipHooksKey).(bool)
|
|
return v
|
|
}
|