返回 DeepSeek-Reasonix
user_input.go
根目录 / internal / agent / user_input.go
1 package agent
2
3 import "context"
4
5 type rawUserInputKey struct{}
6
7 // WithRawUserInput keeps user-authored text separate from host-rendered turn
8 // context. Runner implementations can persist the raw text while sending their
9 // composed input to the provider.
10 func WithRawUserInput(ctx context.Context, raw string) context.Context {
11 if ctx == nil {
12 ctx = context.Background()
13 }
14 return context.WithValue(ctx, rawUserInputKey{}, raw)
15 }
16
17 // RawUserInput returns the host-authenticated raw user text when available.
18 // Direct Agent callers that do not use a Controller keep their input unchanged.
19 func RawUserInput(ctx context.Context, fallback string) string {
20 if ctx == nil {
21 return fallback
22 }
23 if raw, ok := ctx.Value(rawUserInputKey{}).(string); ok {
24 return raw
25 }
26 return fallback
27 }
28
28 lines GO