The open source coding agent.
TypeScript
improve cache
Kujtim Hoxha8e160488ff1a
diff --git a/internal/llm/provider/anthropic.go b/internal/llm/provider/anthropic.goindex 2c16a059357..86f483f649a 100644--- a/internal/llm/provider/anthropic.go+++ b/internal/llm/provider/anthropic.go@@ -57,16 +57,18 @@ func newAnthropicClient(opts providerClientOptions) AnthropicClient {}func (a *anthropicClient) convertMessages(messages []message.Message) (anthropicMessages []anthropic.MessageParam) {- cachedBlocks := 0- for _, msg := range messages {+ for i, msg := range messages {+ cache := false+ if len(messages)-3 > i {+ cache = true+ }switch msg.Role {case message.User:content := anthropic.NewTextBlock(msg.Content().String())- if cachedBlocks < 2 && !a.options.disableCache {+ if cache && !a.options.disableCache {content.OfRequestTextBlock.CacheControl = anthropic.CacheControlEphemeralParam{Type: "ephemeral",}- cachedBlocks++}anthropicMessages = append(anthropicMessages, anthropic.NewUserMessage(content))@@ -74,11 +76,10 @@ func (a *anthropicClient) convertMessages(messages []message.Message) (anthropicblocks := []anthropic.ContentBlockParamUnion{}if msg.Content().String() != "" {content := anthropic.NewTextBlock(msg.Content().String())- if cachedBlocks < 2 && !a.options.disableCache {+ if cache && !a.options.disableCache {content.OfRequestTextBlock.CacheControl = anthropic.CacheControlEphemeralParam{Type: "ephemeral",}- cachedBlocks++}blocks = append(blocks, content)}diff --git a/internal/tui/components/dialog/permission.go b/internal/tui/components/dialog/permission.goindex 1f8df21a0b2..16b63815cf9 100644--- a/internal/tui/components/dialog/permission.go+++ b/internal/tui/components/dialog/permission.go@@ -375,6 +375,9 @@ func (p *permissionDialogCmp) render() string {contentFinal = p.renderDefaultContent()}+ // Add help text+ helpText := styles.BaseStyle.Width(p.width - 4).Padding(0, 1).Foreground(styles.ForgroundDim).Render("←/→/tab: switch options a: allow A: allow for session d: deny enter/space: confirm")+content := lipgloss.JoinVertical(lipgloss.Top,title,@@ -382,6 +385,8 @@ func (p *permissionDialogCmp) render() string {headerContent,contentFinal,buttons,+ styles.BaseStyle.Render(strings.Repeat(" ", p.width - 4)),+ helpText,)return styles.BaseStyle.@@ -401,7 +406,7 @@ func (p *permissionDialogCmp) View() string {}func (p *permissionDialogCmp) BindingKeys() []key.Binding {- return layout.KeyMapToSlice(helpKeys)+ return layout.KeyMapToSlice(permissionsKeys)}func (p *permissionDialogCmp) SetSize() tea.Cmd {