mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-29 09:10:58 +01:00
Return persisted planning acceptance or refusal inside the investigation turn. Keep model judgment separate from action authority and preserve accepted action identity across provider failures. Enforce actor/request idempotency atomically and retain complete approval and independent verification context. Preserve unknown disk evidence, stream whitespace and historical resolution timestamps. Keep conversation scrolling inside its own panel. Record real-model, disposable-lab and browser qualification with explicit population limits. Refs #1782
31 lines
969 B
Go
31 lines
969 B
Go
package tools
|
|
|
|
import (
|
|
"context"
|
|
"crypto/sha256"
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type invocationScopeContextKey struct{}
|
|
|
|
// WithInvocationScope binds provider tool IDs to a trusted persisted user turn.
|
|
// The scope is transport context and is never accepted from model arguments.
|
|
func WithInvocationScope(ctx context.Context, sessionID, messageID string) context.Context {
|
|
scope, _ := json.Marshal([]string{sessionID, messageID})
|
|
return context.WithValue(ctx, invocationScopeContextKey{}, string(scope))
|
|
}
|
|
|
|
func actionRequestIDForInvocation(ctx context.Context) string {
|
|
scope, _ := ctx.Value(invocationScopeContextKey{}).(string)
|
|
invocation := InvocationIDFromContext(ctx)
|
|
if scope == "" || invocation == "" {
|
|
// Direct internal callers without a replay identity request a fresh plan.
|
|
return uuid.NewString()
|
|
}
|
|
identity, _ := json.Marshal([]string{scope, invocation})
|
|
return fmt.Sprintf("assistant:%x", sha256.Sum256(identity))
|
|
}
|