mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
fix(assistant): leave room for the attached file tools when loading tool groups
A trip turn with an attached file adds read_attached_file and keep_attached_file to the session's tools, so loading groups now stops two short of the 128 tools OpenAI and Azure accept in one request.
This commit is contained in:
@@ -25,6 +25,9 @@ export const MAX_CARDS_PER_STEP = 12;
|
||||
*/
|
||||
export const MAX_OFFERED_TOOLS = 128;
|
||||
|
||||
/** Tools a trip turn may offer beside its session's own (read_attached_file, keep_attached_file), which loading groups leaves room for. */
|
||||
export const TURN_ADDED_TOOLS = 2;
|
||||
|
||||
/** What a tool answer may cost the conversation, as JSON text, after it was cut down to its structure. */
|
||||
export const MAX_TOOL_OUTPUT_CHARS = 40_000;
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ import {
|
||||
PINNED_ARG,
|
||||
PREVIEW_BOOK_PAGE_TOOL,
|
||||
REMEMBER_TOOL,
|
||||
TURN_ADDED_TOOLS,
|
||||
} from './assistant-tools.constants';
|
||||
import type { ToolCards } from './cards/card-types';
|
||||
import {
|
||||
@@ -476,8 +477,9 @@ ${hint}`,
|
||||
|
||||
/**
|
||||
* Loads groups as the ones used last, then unloads the ones used longest
|
||||
* ago until the step offers no more than MAX_OFFERED_TOOLS. Groups asked for
|
||||
* together that do not fit even alone are left out from the last one asked.
|
||||
* ago until the step, with the tools its turn adds, offers no more than
|
||||
* MAX_OFFERED_TOOLS. Groups asked for together that do not fit even alone
|
||||
* are left out from the last one asked.
|
||||
*/
|
||||
private use(groups: readonly string[]): { unloaded: string[]; refused: string[] } {
|
||||
for (const group of groups) {
|
||||
@@ -490,7 +492,7 @@ ${hint}`,
|
||||
this.loaded.delete(group);
|
||||
this.unoffered.delete(group);
|
||||
};
|
||||
while (this.offeredSpecs().length > MAX_OFFERED_TOOLS) {
|
||||
while (this.offeredSpecs().length > MAX_OFFERED_TOOLS - TURN_ADDED_TOOLS) {
|
||||
const oldest = [...this.loaded].find((group) => !groups.includes(group));
|
||||
if (oldest) {
|
||||
drop(oldest);
|
||||
|
||||
Reference in New Issue
Block a user