File tree Expand file tree Collapse file tree 4 files changed +13
-2
lines changed
Expand file tree Collapse file tree 4 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 165165 :content {:type :url
166166 :title (:title msg)
167167 :url (:url msg)}})
168+ :limit-reached (do
169+ (messenger/chat-content-received
170+ messenger
171+ {:chat-id chat-id
172+ :request-id request-id
173+ :role :system
174+ :content {:type :text
175+ :text (str " API limit reached. Tokens: " (:tokens msg))}})
176+ (finish-chat-prompt! chat-id :idle messenger db*))
168177 :finish (do
169178 (add-to-history! {:role " assistant" :content @received-msgs*})
170179 (finish-chat-prompt! chat-id :idle messenger db*))))
Original file line number Diff line number Diff line change 4040 (mapv #(assoc % :source :mcp ) mcp-tools))))
4141
4242(defn call-tool! [^String name ^Map arguments db config]
43- (logger/debug logger-tag (format " Calling tool '%s' with args '%s'" name arguments))
43+ (logger/info logger-tag (format " Calling tool '%s' with args '%s'" name arguments))
4444 (if-let [native-tool-handler (get-in (native-definitions db config) [name :handler ])]
4545 (native-tool-handler arguments {:db db :config config})
4646 (f.mcp/call-tool! name arguments db)))
Original file line number Diff line number Diff line change 4848 (or (tools.util/invalid-arguments arguments [[" path" (partial allowed-path? db) (str " Access denied - path $path outside allowed directories: " (tools.util/workspace-roots-strs db))]])
4949 (let [path (get arguments " path" )
5050 content (get arguments " content" )]
51- (fs/create-dirs path)
51+ (fs/create-dirs ( fs/parent ( fs/ path path)) )
5252 (spit path content)
5353 (tools.util/single-text-content (format " Successfully wrote to %s" path)))))
5454
Original file line number Diff line number Diff line change 154154 :on-response handle-response}))))
155155 " end_turn" (on-message-received {:type :finish
156156 :finish-reason (-> data :delta :stop_reason )})
157+ " max_tokens" (on-message-received {:type :limit-reached
158+ :tokens (:usage data)})
157159 nil )
158160 nil ))]
159161 (base-request!
You can’t perform that action at this time.
0 commit comments