File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33## Unreleased
44
55- Fix MCP OAuth credentials cache not invalidating when the server URL changes.
6+ - Add ` isSubagent ` condition variable for chat system instructions
67
78## 0.112.0
89
Original file line number Diff line number Diff line change 9292 (str " \n <additionalContext from=\" chatStart\" >\n " startup-ctx " \n </additionalContext>\n\n " ))
9393 " </contexts>" ))
9494
95- (defn ^:private ->base-selmer-ctx [all-tools db]
96- (merge
97- {:workspaceRoots (shared/workspaces-as-str db)}
98- (reduce
99- (fn [m tool]
100- (assoc m (keyword (str " toolEnabled_" (:full-name tool))) true ))
101- {}
102- all-tools)))
95+ (defn ^:private ->base-selmer-ctx
96+ ([all-tools db]
97+ (->base-selmer-ctx all-tools nil db))
98+ ([all-tools chat-id db]
99+ (merge
100+ {:workspaceRoots (shared/workspaces-as-str db)
101+ :isSubagent (boolean (get-in db [:chats chat-id :subagent ]))}
102+ (reduce
103+ (fn [m tool]
104+ (assoc m (keyword (str " toolEnabled_" (:full-name tool))) true ))
105+ {}
106+ all-tools))))
103107
104108(defn build-chat-instructions [refined-contexts rules skills repo-map* agent-name config chat-id all-tools db]
105- (let [selmer-ctx (->base-selmer-ctx all-tools db)]
109+ (let [selmer-ctx (->base-selmer-ctx all-tools chat-id db)]
106110 (multi-str
107111 (selmer/render (eca-chat-prompt agent-name config) selmer-ctx)
108112 (when (seq rules)
Original file line number Diff line number Diff line change 5858 (is (string/includes? result " <resource uri=\" custom://my-resource\" >some-cool-content</resource>" ))
5959 (is (string/includes? result " </contexts>" ))
6060 (is (string? result)))))
61+
62+ (deftest build-instructions-subagent-condition-test
63+ (let [config {:prompts {:chat " {% if isSubagent %}SUBAGENT{% endif %}{% if not isSubagent %}MAIN{% endif %}" }}]
64+ (testing " renders subagent-only content for subagent chats"
65+ (let [db (assoc-in (h/db ) [:chats " sub-chat" :subagent ] {:name " explorer" })
66+ result (prompt/build-chat-instructions [] [] [] (delay " TREE" ) " code" config " sub-chat" [] db)]
67+ (is (string/includes? result " SUBAGENT" ))
68+ (is (not (string/includes? result " MAIN" )))))
69+
70+ (testing " renders main-agent-only content for non-subagent chats"
71+ (let [db (assoc-in (h/db ) [:chats " main-chat" ] {:id " main-chat" })
72+ result (prompt/build-chat-instructions [] [] [] (delay " TREE" ) " code" config " main-chat" [] db)]
73+ (is (string/includes? result " MAIN" ))
74+ (is (not (string/includes? result " SUBAGENT" )))))))
You can’t perform that action at this time.
0 commit comments