-
-
Notifications
You must be signed in to change notification settings - Fork 55
Fix agent switching cache issue #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| (ns eca.llm-providers.openai-test | ||
| (:require | ||
| [clojure.string :as string] | ||
| [clojure.test :refer [deftest is testing]] | ||
| [eca.client-test-helpers :refer [with-client-proxied]] | ||
| [eca.llm-providers.openai :as llm-providers.openai] | ||
|
|
@@ -437,3 +438,30 @@ | |
| :arguments {"command" "ls"}}] | ||
| (first @tools-called*))) | ||
| (is (= 2 (count @requests*))))))) | ||
|
|
||
| (deftest create-response-prompt-cache-key-agent-test | ||
| (testing "prompt_cache_key includes agent suffix when agent is provided" | ||
| (let [body* (atom nil)] | ||
| (with-redefs [llm-providers.openai/base-responses-request! | ||
| (fn [{:keys [body on-stream]}] | ||
| (reset! body* body) | ||
| (on-stream "response.completed" | ||
| {:response {:output [] :usage {:input_tokens 1 :output_tokens 1}}}))] | ||
| (llm-providers.openai/create-response! | ||
| (assoc (base-provider-params) :agent "plan") | ||
| (base-callbacks {})) | ||
| (is (string/ends-with? (:prompt_cache_key @body*) "/plan") | ||
| "prompt_cache_key should end with /plan")))) | ||
|
|
||
| (testing "prompt_cache_key has no agent suffix when agent is nil" | ||
| (let [body* (atom nil)] | ||
| (with-redefs [llm-providers.openai/base-responses-request! | ||
| (fn [{:keys [body on-stream]}] | ||
| (reset! body* body) | ||
| (on-stream "response.completed" | ||
| {:response {:output [] :usage {:input_tokens 1 :output_tokens 1}}}))] | ||
| (llm-providers.openai/create-response! | ||
| (base-provider-params) | ||
| (base-callbacks {})) | ||
| (is (not (string/includes? (:prompt_cache_key @body*) "/")) | ||
| "prompt_cache_key should not contain / when agent is nil"))))) | ||
|
Comment on lines
+457
to
+467
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if it is even possible for the agent name to contain a slash or be nil. I think there always should be an agent specified (at least "plan" and "code" shipped by ECA). And we need to guarantee that the agent name does not contain a slash. I assume this is already restricted when defining an agent with an markdown file, but the json config could contain a slash. Anyway, I think this rather a marginal concern and should be dealt with a lightweight agent name validator. |
||
Uh oh!
There was an error while loading. Please reload this page.