Skip to content

Commit fd84e23

Browse files
committed
test message
1 parent 225efd5 commit fd84e23

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

cmd/iterate/repl_streaming.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ func newSpinnerController() (func(), func(string)) {
223223
// processStreamEvent handles a single agent stream event and returns updated state.
224224
func processStreamEvent(e iteragent.Event, fullContent string, toolStart time.Time, stopOnce func(), newSpinner func(string), repoPath string) (string, time.Time) {
225225
switch iteragent.EventType(e.Type) {
226+
case iteragent.EventThinkingUpdate:
227+
// Thinking tokens are displayed dimmed and indented; not included in fullContent.
228+
fmt.Printf("\r\033[K%s %s%s", colorDim, e.Content, colorReset)
226229
case iteragent.EventTokenUpdate:
227230
fullContent += e.Content
228231
streamingTokenCount.Add(1)

internal/commands/agent.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func registerAgentCoreCommands(r *Registry) {
2323
registerMany(r, "agent",
2424
"/model", "switch provider/model", cmdModel,
2525
"/thinking", "set thinking level", cmdThinking,
26+
"/cache", "toggle Anthropic prompt caching on/off", cmdCache,
2627
"/tools", "list available tools", cmdTools,
2728
"/skills", "list available skills", cmdSkills,
2829
)
@@ -120,6 +121,36 @@ func cmdThinking(ctx Context) Result {
120121
return Result{Handled: true}
121122
}
122123

124+
func cmdCache(ctx Context) Result {
125+
if ctx.Agent == nil {
126+
fmt.Println("No agent available.")
127+
return Result{Handled: true}
128+
}
129+
// With no argument: show current state.
130+
if !ctx.HasArg(1) {
131+
enabled := ctx.RuntimeConfig.CacheEnabled != nil && *ctx.RuntimeConfig.CacheEnabled
132+
fmt.Printf("Prompt caching: %s\n", map[bool]string{true: "on", false: "off"}[enabled])
133+
fmt.Println("Usage: /cache on|off")
134+
return Result{Handled: true}
135+
}
136+
val := strings.ToLower(ctx.Arg(1))
137+
switch val {
138+
case "on", "true", "1", "yes":
139+
on := true
140+
ctx.RuntimeConfig.CacheEnabled = &on
141+
ctx.Agent.WithCacheEnabled(true)
142+
fmt.Printf("%sPrompt caching enabled.%s\n", ColorLime, ColorReset)
143+
case "off", "false", "0", "no":
144+
off := false
145+
ctx.RuntimeConfig.CacheEnabled = &off
146+
ctx.Agent.WithCacheEnabled(false)
147+
fmt.Printf("%sPrompt caching disabled.%s\n", ColorDim, ColorReset)
148+
default:
149+
fmt.Printf("Unknown value %q. Usage: /cache on|off\n", val)
150+
}
151+
return Result{Handled: true}
152+
}
153+
123154
func cmdTools(ctx Context) Result {
124155
if ctx.Agent == nil {
125156
fmt.Println("No agent available.")

0 commit comments

Comments
 (0)