|
166 | 166 | (with-redefs [logger/warn (fn [_ _] nil)] |
167 | 167 | (is (= "code" (config/validate-agent-name "anything" config))))))) |
168 | 168 |
|
| 169 | +(deftest resolve-agent-inheritance-test |
| 170 | + (testing "basic inheritance copies parent fields to child" |
| 171 | + (let [agents {"plan" {:mode "primary" |
| 172 | + :disabledTools ["edit_file" "write_file"] |
| 173 | + :toolCall {:approval {:byDefault "ask"}}} |
| 174 | + "my-plan" {:inherit "plan" |
| 175 | + :description "custom plan"}}] |
| 176 | + (is (match? |
| 177 | + {"plan" {:mode "primary" |
| 178 | + :disabledTools ["edit_file" "write_file"]} |
| 179 | + "my-plan" {:mode "primary" |
| 180 | + :disabledTools ["edit_file" "write_file"] |
| 181 | + :toolCall {:approval {:byDefault "ask"}} |
| 182 | + :description "custom plan"}} |
| 183 | + (#'config/resolve-agent-inheritance agents))))) |
| 184 | + |
| 185 | + (testing "child values override parent values" |
| 186 | + (let [agents {"code" {:mode "primary" |
| 187 | + :disabledTools ["preview_file_change"] |
| 188 | + :defaultModel "anthropic/claude-sonnet-4-6"} |
| 189 | + "my-code" {:inherit "code" |
| 190 | + :defaultModel "openai/gpt-5"}}] |
| 191 | + (is (match? |
| 192 | + {"my-code" {:mode "primary" |
| 193 | + :disabledTools ["preview_file_change"] |
| 194 | + :defaultModel "openai/gpt-5"}} |
| 195 | + (#'config/resolve-agent-inheritance agents))))) |
| 196 | + |
| 197 | + (testing "missing parent is skipped with warning" |
| 198 | + (let [agents {"child" {:inherit "nonexistent" |
| 199 | + :mode "primary"}}] |
| 200 | + (is (match? |
| 201 | + {"child" {:mode "primary"}} |
| 202 | + (#'config/resolve-agent-inheritance agents))) |
| 203 | + (is (not (contains? (get (#'config/resolve-agent-inheritance agents) "child") :inherit))))) |
| 204 | + |
| 205 | + (testing "self-inheritance is skipped" |
| 206 | + (let [agents {"self" {:inherit "self" |
| 207 | + :mode "primary"}}] |
| 208 | + (is (match? |
| 209 | + {"self" {:mode "primary"}} |
| 210 | + (#'config/resolve-agent-inheritance agents))) |
| 211 | + (is (not (contains? (get (#'config/resolve-agent-inheritance agents) "self") :inherit))))) |
| 212 | + |
| 213 | + (testing "agent without inherit is unchanged" |
| 214 | + (let [agents {"code" {:mode "primary" |
| 215 | + :disabledTools ["preview_file_change"]}}] |
| 216 | + (is (match? |
| 217 | + {"code" {:mode "primary" |
| 218 | + :disabledTools ["preview_file_change"]}} |
| 219 | + (#'config/resolve-agent-inheritance agents))))) |
| 220 | + |
| 221 | + (testing "inherit key is stripped from resolved config" |
| 222 | + (let [agents {"plan" {:mode "primary"} |
| 223 | + "child" {:inherit "plan" |
| 224 | + :description "my child"}} |
| 225 | + resolved (#'config/resolve-agent-inheritance agents)] |
| 226 | + (is (not (contains? (get resolved "child") :inherit)))))) |
| 227 | + |
169 | 228 | (deftest diff-keeping-vectors-test |
170 | 229 | (testing "like clojure.data/diff" |
171 | 230 | (is (= {:b 3} |
|
0 commit comments