| 1 | package planmode |
| 2 | |
| 3 | import "context" |
| 4 | |
| 5 | type activeCtxKey struct{} |
| 6 | |
| 7 | // WithActive stamps ctx with whether the executing tool call runs during the |
| 8 | // plan-first workflow. The agent's call-context constructor is the single |
| 9 | // production writer, so phase-sensitive tools stay aligned with the workflow. |
| 10 | // Leaf-package tools (which must not import the agent package) read it via |
| 11 | // Active to defer follow-up work that belongs to an execution turn. |
| 12 | func WithActive(ctx context.Context, active bool) context.Context { |
| 13 | return context.WithValue(ctx, activeCtxKey{}, active) |
| 14 | } |
| 15 | |
| 16 | // Active reports whether ctx carries an active plan-mode flag. |
| 17 | func Active(ctx context.Context) bool { |
| 18 | active, _ := ctx.Value(activeCtxKey{}).(bool) |
| 19 | return active |
| 20 | } |
| 21 |