ask-agent 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/lib/ask/agent/chat.rb +7 -3
- data/lib/ask/agent/configuration.rb +1 -0
- data/lib/ask/agent/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82d7ec2cb06f4ce9cbaa41ece0ac4800772b44dcbe54c33e46f6edefb863f1b2
|
|
4
|
+
data.tar.gz: b8b5cfec092ae7b0117f0a4ec3b441becc0ea21c806107cb0ae9c51c5b215618
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d9a3dd55f214105d58858f31122a0064a9a94165f37d5b8fc8d1f202ce87fe19ff8ad4f0c6e52de1d66bf115940e3c48e8673762d16912514668b82cabd8daa3
|
|
7
|
+
data.tar.gz: ecaecabad77df46494a9ee0f99840cbeeaf59163cecaf1ccb8af8810e98bfa8333455c1ed3b50d1bc66c106c38e74b98329d28fea3d2e4393cacdd9453213c23
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [0.9.0] — 2026-07-21
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- **Prompt caching support** — `prompt_caching` option enables provider-native prompt caching for significant cost savings on repeated conversation prefixes. Works with both Anthropic and OpenAI.
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
# Global config
|
|
9
|
+
Ask::Agent.configure do |c|
|
|
10
|
+
c.prompt_caching = true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Or per-session
|
|
14
|
+
session = Ask::Agent::Session.new(model: "claude-sonnet-4", prompt_caching: true)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Anthropic**: Caches the system prompt and the last user message content. The provider automatically returns cached reads instead of processing the full context on repeated calls. Response metadata includes `cache_creation_input_tokens` and `cache_read_input_tokens`.
|
|
18
|
+
|
|
19
|
+
**OpenAI**: Caching is automatic for prompts exceeding 1024 tokens. Response metadata includes `cached_tokens` from `usage.prompt_tokens_details.cached_tokens`.
|
|
20
|
+
|
|
21
|
+
- **Prompt caching capability** — Both `Ask::Providers::Anthropic` and `Ask::Providers::OpenAI` now advertise `prompt_caching: true` in their capabilities.
|
|
22
|
+
|
|
1
23
|
## [0.8.1] — 2026-07-21
|
|
2
24
|
|
|
3
25
|
### Added
|
data/lib/ask/agent/chat.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Ask
|
|
|
33
33
|
|
|
34
34
|
attr_writer :test_provider
|
|
35
35
|
|
|
36
|
-
def initialize(model:, tools: [], temperature: nil, schema: nil, provider: nil, **)
|
|
36
|
+
def initialize(model:, tools: [], temperature: nil, schema: nil, provider: nil, prompt_caching: nil, **)
|
|
37
37
|
@model_id = model.respond_to?(:id) ? model.id : model.to_s
|
|
38
38
|
@model_info = Ask::ModelCatalog.find(@model_id)
|
|
39
39
|
@tools = tools
|
|
@@ -43,10 +43,11 @@ module Ask
|
|
|
43
43
|
@provider_override = provider
|
|
44
44
|
@provider = nil
|
|
45
45
|
|
|
46
|
-
# Read configured middleware and
|
|
46
|
+
# Read configured middleware, transforms, and caching from global config
|
|
47
47
|
config = Ask::Agent.configuration
|
|
48
48
|
@middleware_pipeline = config.middleware.configured? ? config.middleware : nil
|
|
49
49
|
@transform_pipeline = config.stream_transforms.configured? ? config.stream_transforms : nil
|
|
50
|
+
@prompt_caching = prompt_caching.nil? ? config.prompt_caching : prompt_caching
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
def ask(message = nil, &block)
|
|
@@ -142,6 +143,9 @@ module Ask
|
|
|
142
143
|
# Build the request hash for the provider call.
|
|
143
144
|
# Middleware can mutate this hash to inject defaults, modify params, etc.
|
|
144
145
|
def build_request(stream)
|
|
146
|
+
extra = (@extra_params || {}).dup
|
|
147
|
+
extra[:prompt_caching] = true if @prompt_caching
|
|
148
|
+
|
|
145
149
|
{
|
|
146
150
|
messages: @messages.map(&:to_h),
|
|
147
151
|
model: @model_id,
|
|
@@ -149,7 +153,7 @@ module Ask
|
|
|
149
153
|
temperature: @temperature,
|
|
150
154
|
stream: stream,
|
|
151
155
|
schema: @schema&.respond_to?(:to_json_schema) ? @schema.to_json_schema : @schema,
|
|
152
|
-
extra_params:
|
|
156
|
+
extra_params: extra
|
|
153
157
|
}
|
|
154
158
|
end
|
|
155
159
|
|
data/lib/ask/agent/version.rb
CHANGED