@tinyweb_dev/agent-framework-agent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +279 -0
- package/package.json +41 -0
- package/src/agent.ts +317 -0
- package/src/attachments.ts +155 -0
- package/src/bus/bus.ts +89 -0
- package/src/bus/index.ts +1 -0
- package/src/define-tool.ts +41 -0
- package/src/events.ts +162 -0
- package/src/http-handlers.ts +251 -0
- package/src/index.ts +120 -0
- package/src/loop-guard.ts +99 -0
- package/src/mcp/client.ts +110 -0
- package/src/mcp/index.ts +1 -0
- package/src/permission.ts +72 -0
- package/src/plugin/apply.ts +89 -0
- package/src/plugin/index.ts +3 -0
- package/src/plugin/loader.ts +42 -0
- package/src/plugin/types.ts +134 -0
- package/src/prompt/index.ts +90 -0
- package/src/prompt/objective.ts +104 -0
- package/src/prompt/response-style.ts +59 -0
- package/src/prompt/tool-use-guidelines.ts +57 -0
- package/src/prompt/tool-use.ts +27 -0
- package/src/runtime.ts +22 -0
- package/src/session/adapter.ts +37 -0
- package/src/session/compaction.ts +160 -0
- package/src/session/index.ts +11 -0
- package/src/session/memory.ts +154 -0
- package/src/session/overflow.ts +50 -0
- package/src/session/postgres.ts +330 -0
- package/src/session/processor.ts +500 -0
- package/src/session/replay.ts +140 -0
- package/src/session/schema.ts +140 -0
- package/src/session/sqlite.ts +281 -0
- package/src/session-api.ts +103 -0
- package/src/skill/index.ts +113 -0
- package/src/sse-handler.ts +67 -0
- package/src/transcript.ts +126 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// Adapted from opencode@v1.14.48 packages/opencode/src/session/compaction.ts
|
|
2
|
+
//
|
|
3
|
+
// Auto-compaction. Replaces a leading slice of the conversation with a
|
|
4
|
+
// summarisation marker so subsequent turns replay only [marker, ...tail].
|
|
5
|
+
// Critically we NEVER delete/recreate the session — the sessionId, owner and
|
|
6
|
+
// metadata stay stable; only the message log is appended to.
|
|
7
|
+
import { LLM, LLMClient, type ModelRef } from "@tinyweb-agent-framework/llm"
|
|
8
|
+
import { Effect } from "effect"
|
|
9
|
+
import type { SessionStore } from "./adapter"
|
|
10
|
+
import { estimateTokens } from "./overflow"
|
|
11
|
+
import {
|
|
12
|
+
findCompactionPart,
|
|
13
|
+
makeCompactionMessage,
|
|
14
|
+
type Message,
|
|
15
|
+
type MessageID,
|
|
16
|
+
type SessionID,
|
|
17
|
+
type TextPart,
|
|
18
|
+
} from "./schema"
|
|
19
|
+
|
|
20
|
+
const SUMMARY_PROMPT = `You are a conversation summarizer. Summarize the entire conversation below into a concise factual summary (1-3 paragraphs) that preserves: user intent, key facts established, decisions made, and outstanding tasks. Do not add commentary.`
|
|
21
|
+
|
|
22
|
+
const SUMMARY_FALLBACK_MAX_CHARS = 200_000
|
|
23
|
+
|
|
24
|
+
const partText = (part: unknown): string => {
|
|
25
|
+
const tagged = part as { type?: string; text?: string; summary?: string }
|
|
26
|
+
if (tagged.type === "text") return tagged.text ?? ""
|
|
27
|
+
if (tagged.type === "reasoning") return tagged.text ?? ""
|
|
28
|
+
if (tagged.type === "compaction") return `[previous summary] ${tagged.summary ?? ""}`
|
|
29
|
+
return ""
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const messageToWireText = (msg: Message): string => {
|
|
33
|
+
const role = msg.role.toUpperCase()
|
|
34
|
+
const text = msg.parts
|
|
35
|
+
.map((p) => partText(p))
|
|
36
|
+
.filter((s) => s.length > 0)
|
|
37
|
+
.join("\n")
|
|
38
|
+
return `[${role}] ${text}`
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Trim transcript to fit inside the summariser's own context window. Mirrors
|
|
43
|
+
* opencode's `truncateToolOutput` pattern — when even the summariser would
|
|
44
|
+
* overflow, prefer the head + tail of each message.
|
|
45
|
+
*/
|
|
46
|
+
const truncateForSummary = (transcript: string, max: number): string => {
|
|
47
|
+
if (transcript.length <= max) return transcript
|
|
48
|
+
const half = Math.floor(max / 2) - 64
|
|
49
|
+
return `${transcript.slice(0, half)}\n\n[... ${transcript.length - max} chars elided ...]\n\n${transcript.slice(-half)}`
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type CompactInput = {
|
|
53
|
+
readonly sessionId: SessionID | string
|
|
54
|
+
readonly store: SessionStore
|
|
55
|
+
readonly model: ModelRef
|
|
56
|
+
/** Number of trailing turns to keep verbatim. Default 4. */
|
|
57
|
+
readonly keepRecent?: number
|
|
58
|
+
/** True when triggered by a ContextOverflowReason from the previous turn. */
|
|
59
|
+
readonly overflow?: boolean
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type CompactResult = {
|
|
63
|
+
readonly compacted: boolean
|
|
64
|
+
readonly summary?: string
|
|
65
|
+
readonly markerId?: MessageID
|
|
66
|
+
readonly tailStartId?: MessageID
|
|
67
|
+
/** Approximate prompt tokens BEFORE compaction (estimateTokens of the head slice). */
|
|
68
|
+
readonly prevTokens?: number
|
|
69
|
+
/** Approximate prompt tokens AFTER compaction (`[marker, ...tail]`). */
|
|
70
|
+
readonly newTokens?: number
|
|
71
|
+
/** USD cost of the summariser call when the route surfaces it. */
|
|
72
|
+
readonly cost?: number
|
|
73
|
+
/** Model id used for the summarisation call. Today: same as the main agent. */
|
|
74
|
+
readonly modelId?: string
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Run an auto-compaction pass. Appends a marker user message that summarises
|
|
79
|
+
* the leading slice of history; replay logic in `replay.ts` will then emit
|
|
80
|
+
* only `[marker, ...tail]` for subsequent LLM calls.
|
|
81
|
+
*
|
|
82
|
+
* Idempotent: if the most recent compaction marker has nothing prior to
|
|
83
|
+
* summarise we no-op.
|
|
84
|
+
*/
|
|
85
|
+
export const compact = (
|
|
86
|
+
input: CompactInput,
|
|
87
|
+
): Effect.Effect<CompactResult, unknown, typeof LLMClient.Service> =>
|
|
88
|
+
Effect.gen(function* () {
|
|
89
|
+
const keepRecent = input.keepRecent ?? 4
|
|
90
|
+
const all = yield* input.store.getMessages(input.sessionId)
|
|
91
|
+
if (all.length <= keepRecent + 1) return { compacted: false } satisfies CompactResult
|
|
92
|
+
|
|
93
|
+
// Find the last existing marker so we don't re-summarise already-summarised history.
|
|
94
|
+
const lastMarkerIdx = (() => {
|
|
95
|
+
for (let i = all.length - 1; i >= 0; i--) {
|
|
96
|
+
if (findCompactionPart(all[i]!)) return i
|
|
97
|
+
}
|
|
98
|
+
return -1
|
|
99
|
+
})()
|
|
100
|
+
|
|
101
|
+
const head = all.slice(lastMarkerIdx + 1, Math.max(lastMarkerIdx + 1, all.length - keepRecent))
|
|
102
|
+
if (head.length === 0) return { compacted: false } satisfies CompactResult
|
|
103
|
+
|
|
104
|
+
const tail = all.slice(all.length - keepRecent)
|
|
105
|
+
const tailStartId = tail[0]?.id
|
|
106
|
+
|
|
107
|
+
const transcript = truncateForSummary(
|
|
108
|
+
head.map(messageToWireText).join("\n\n"),
|
|
109
|
+
SUMMARY_FALLBACK_MAX_CHARS,
|
|
110
|
+
)
|
|
111
|
+
const request = LLM.request({
|
|
112
|
+
model: input.model,
|
|
113
|
+
system: SUMMARY_PROMPT,
|
|
114
|
+
messages: [LLM.user(`Conversation transcript to summarize:\n\n${transcript}`)],
|
|
115
|
+
})
|
|
116
|
+
const response = yield* LLMClient.generate(request)
|
|
117
|
+
const summary = response.text.trim().length > 0 ? response.text : extractFallbackSummary(head)
|
|
118
|
+
|
|
119
|
+
const marker = makeCompactionMessage({
|
|
120
|
+
summary,
|
|
121
|
+
tailStartId,
|
|
122
|
+
auto: true,
|
|
123
|
+
overflow: input.overflow ?? false,
|
|
124
|
+
})
|
|
125
|
+
yield* input.store.appendMessage(input.sessionId, marker)
|
|
126
|
+
|
|
127
|
+
// Token accounting for the UI affordance. `prevTokens` is the size of the
|
|
128
|
+
// slice we replaced; `newTokens` is the resulting view (marker + tail).
|
|
129
|
+
// We deliberately use `estimateTokens` (cheap, provider-agnostic) rather
|
|
130
|
+
// than the provider's usage object — providers don't agree on what counts.
|
|
131
|
+
const prevTokens = estimateTokens(head)
|
|
132
|
+
const newTokens = estimateTokens([marker, ...tail])
|
|
133
|
+
|
|
134
|
+
// Cost / model id are best-effort: not every route fills `response.usage.cost`
|
|
135
|
+
// and we never want a missing field to abort the compaction.
|
|
136
|
+
const usage = response.usage as { cost?: number } | undefined
|
|
137
|
+
const cost = typeof usage?.cost === "number" ? usage.cost : undefined
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
compacted: true,
|
|
141
|
+
summary,
|
|
142
|
+
markerId: marker.id,
|
|
143
|
+
tailStartId,
|
|
144
|
+
prevTokens,
|
|
145
|
+
newTokens,
|
|
146
|
+
cost,
|
|
147
|
+
modelId: input.model.id,
|
|
148
|
+
} satisfies CompactResult
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
/** Best-effort offline summary when the summariser returns empty text. */
|
|
152
|
+
const extractFallbackSummary = (msgs: ReadonlyArray<Message>): string => {
|
|
153
|
+
const lines = msgs.flatMap((m) =>
|
|
154
|
+
m.parts
|
|
155
|
+
.map((p) => ((p as TextPart).type === "text" ? (p as TextPart).text : ""))
|
|
156
|
+
.filter((s) => s.length > 0),
|
|
157
|
+
)
|
|
158
|
+
const head = lines.slice(0, 4).join(" ")
|
|
159
|
+
return `Compacted ${msgs.length} prior message(s). ${head.slice(0, 400)}`
|
|
160
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./schema"
|
|
2
|
+
export * from "./adapter"
|
|
3
|
+
export { makeMemoryStore } from "./memory"
|
|
4
|
+
// NOTE: `makeSqliteStore` / `makePostgresStore` are NOT re-exported here to
|
|
5
|
+
// avoid pulling `bun:sqlite` / `postgres` into bundlers (Next.js webpack, etc.)
|
|
6
|
+
// when the consumer doesn't actually use them. Import them directly:
|
|
7
|
+
// import { makeSqliteStore } from "@tinyweb-agent-framework/agent/session/sqlite"
|
|
8
|
+
// import { makePostgresStore } from "@tinyweb-agent-framework/agent/session/postgres"
|
|
9
|
+
export { makeProcessor, type Processor, type ProcessorConfig, type TurnInput } from "./processor"
|
|
10
|
+
export { estimateTokens, isOverflow } from "./overflow"
|
|
11
|
+
export { compact, type CompactInput } from "./compaction"
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Effect } from "effect"
|
|
2
|
+
import type { ListSessionsOpts, ListSessionsResult, SessionPatch, SessionStore, GetMessagesOpts } from "./adapter"
|
|
3
|
+
import {
|
|
4
|
+
newSessionID,
|
|
5
|
+
type CreateSessionInput,
|
|
6
|
+
type Message,
|
|
7
|
+
type MessageID,
|
|
8
|
+
type Session,
|
|
9
|
+
type SessionID,
|
|
10
|
+
} from "./schema"
|
|
11
|
+
|
|
12
|
+
type Entry = { info: Session.Info; messages: Message[] }
|
|
13
|
+
|
|
14
|
+
type Cursor = { readonly updatedAt: number; readonly id: string }
|
|
15
|
+
|
|
16
|
+
const encodeCursor = (cursor: Cursor): string =>
|
|
17
|
+
Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url")
|
|
18
|
+
|
|
19
|
+
const decodeCursor = (raw: string): Cursor | undefined => {
|
|
20
|
+
const json = Buffer.from(raw, "base64url").toString("utf8")
|
|
21
|
+
const parsed = JSON.parse(json) as Partial<Cursor>
|
|
22
|
+
if (typeof parsed.updatedAt !== "number" || typeof parsed.id !== "string") return undefined
|
|
23
|
+
return { updatedAt: parsed.updatedAt, id: parsed.id }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const makeMemoryStore = (): SessionStore => {
|
|
27
|
+
const store = new Map<string, Entry>()
|
|
28
|
+
|
|
29
|
+
const createSession = (input: CreateSessionInput): Effect.Effect<Session.Info> => {
|
|
30
|
+
const now = Date.now()
|
|
31
|
+
const info: Session.Info = {
|
|
32
|
+
id: newSessionID(),
|
|
33
|
+
agentName: input.agentName,
|
|
34
|
+
title: input.title,
|
|
35
|
+
metadata: input.metadata,
|
|
36
|
+
createdAt: now,
|
|
37
|
+
updatedAt: now,
|
|
38
|
+
}
|
|
39
|
+
store.set(info.id, { info, messages: [] })
|
|
40
|
+
return Effect.succeed(info)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const getSession = (id: SessionID | string): Effect.Effect<Session.Info | undefined> =>
|
|
44
|
+
Effect.succeed(store.get(id)?.info)
|
|
45
|
+
|
|
46
|
+
const upsertSession = (
|
|
47
|
+
input: CreateSessionInput & { id?: SessionID | string },
|
|
48
|
+
): Effect.Effect<Session.Info> => {
|
|
49
|
+
const existing = input.id ? store.get(input.id) : undefined
|
|
50
|
+
if (existing) return Effect.succeed(existing.info)
|
|
51
|
+
if (!input.id) return createSession(input)
|
|
52
|
+
const now = Date.now()
|
|
53
|
+
const info: Session.Info = {
|
|
54
|
+
id: input.id as SessionID,
|
|
55
|
+
agentName: input.agentName,
|
|
56
|
+
title: input.title,
|
|
57
|
+
metadata: input.metadata,
|
|
58
|
+
createdAt: now,
|
|
59
|
+
updatedAt: now,
|
|
60
|
+
}
|
|
61
|
+
store.set(info.id, { info, messages: [] })
|
|
62
|
+
return Effect.succeed(info)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const listSessions = (opts?: ListSessionsOpts): Effect.Effect<ListSessionsResult> => {
|
|
66
|
+
const limit = opts?.limit ?? 50
|
|
67
|
+
const filtered = Array.from(store.values())
|
|
68
|
+
.map((e) => e.info)
|
|
69
|
+
.filter((info) => (opts?.agentName ? info.agentName === opts.agentName : true))
|
|
70
|
+
.filter((info) =>
|
|
71
|
+
opts?.ownerId ? (info.metadata as { ownerId?: string } | undefined)?.ownerId === opts.ownerId : true,
|
|
72
|
+
)
|
|
73
|
+
.sort((a, b) => {
|
|
74
|
+
if (b.updatedAt !== a.updatedAt) return b.updatedAt - a.updatedAt
|
|
75
|
+
return b.id.localeCompare(a.id)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const cursor = opts?.cursor ? decodeCursor(opts.cursor) : undefined
|
|
79
|
+
const startIdx = cursor
|
|
80
|
+
? filtered.findIndex(
|
|
81
|
+
(info) =>
|
|
82
|
+
info.updatedAt < cursor.updatedAt ||
|
|
83
|
+
(info.updatedAt === cursor.updatedAt && info.id.localeCompare(cursor.id) < 0),
|
|
84
|
+
)
|
|
85
|
+
: 0
|
|
86
|
+
if (startIdx === -1) return Effect.succeed({ items: [] })
|
|
87
|
+
|
|
88
|
+
const page = filtered.slice(startIdx, startIdx + limit)
|
|
89
|
+
const tail = page[page.length - 1]
|
|
90
|
+
const hasMore = startIdx + limit < filtered.length
|
|
91
|
+
const nextCursor = hasMore && tail ? encodeCursor({ updatedAt: tail.updatedAt, id: tail.id }) : undefined
|
|
92
|
+
return Effect.succeed({ items: page, nextCursor })
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const updateSession = (
|
|
96
|
+
id: SessionID | string,
|
|
97
|
+
patch: SessionPatch,
|
|
98
|
+
): Effect.Effect<Session.Info | undefined> => {
|
|
99
|
+
const entry = store.get(id)
|
|
100
|
+
if (!entry) return Effect.succeed(undefined)
|
|
101
|
+
entry.info = {
|
|
102
|
+
...entry.info,
|
|
103
|
+
...(patch.title !== undefined ? { title: patch.title } : {}),
|
|
104
|
+
...(patch.metadata !== undefined ? { metadata: patch.metadata } : {}),
|
|
105
|
+
updatedAt: Date.now(),
|
|
106
|
+
}
|
|
107
|
+
return Effect.succeed(entry.info)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const appendMessage = (sessionId: SessionID | string, msg: Message): Effect.Effect<void> => {
|
|
111
|
+
const entry = store.get(sessionId)
|
|
112
|
+
if (!entry) return Effect.void
|
|
113
|
+
entry.messages.push(msg)
|
|
114
|
+
entry.info = { ...entry.info, updatedAt: Date.now() }
|
|
115
|
+
return Effect.void
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const getMessages = (sessionId: SessionID | string, opts?: GetMessagesOpts): Effect.Effect<Message[]> => {
|
|
119
|
+
const msgs = store.get(sessionId)?.messages ?? []
|
|
120
|
+
const sliced = opts?.before ? msgs.slice(0, msgs.findIndex((m) => m.id === opts.before)) : msgs
|
|
121
|
+
const limited = opts?.limit ? sliced.slice(-opts.limit) : sliced
|
|
122
|
+
return Effect.succeed([...limited])
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const deleteMessage = (
|
|
126
|
+
sessionId: SessionID | string,
|
|
127
|
+
messageId: MessageID | string,
|
|
128
|
+
): Effect.Effect<void> => {
|
|
129
|
+
const entry = store.get(sessionId)
|
|
130
|
+
if (!entry) return Effect.void
|
|
131
|
+
const idx = entry.messages.findIndex((m) => m.id === messageId)
|
|
132
|
+
if (idx === -1) return Effect.void
|
|
133
|
+
entry.messages.splice(idx, 1)
|
|
134
|
+
entry.info = { ...entry.info, updatedAt: Date.now() }
|
|
135
|
+
return Effect.void
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const deleteSession = (id: SessionID | string): Effect.Effect<void> => {
|
|
139
|
+
store.delete(id)
|
|
140
|
+
return Effect.void
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
createSession,
|
|
145
|
+
getSession,
|
|
146
|
+
upsertSession,
|
|
147
|
+
listSessions,
|
|
148
|
+
updateSession,
|
|
149
|
+
appendMessage,
|
|
150
|
+
getMessages,
|
|
151
|
+
deleteMessage,
|
|
152
|
+
deleteSession,
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Adapted from opencode@v1.14.48 packages/opencode/src/session/overflow.ts
|
|
2
|
+
//
|
|
3
|
+
// Token-budget helpers used by the auto-compaction pre-flight check. We
|
|
4
|
+
// deliberately keep this provider-agnostic — the agent layer feeds in a
|
|
5
|
+
// `ModelLimits` (from `ModelRef`) and a reserved output buffer.
|
|
6
|
+
import type { ModelLimits } from "@tinyweb-agent-framework/llm"
|
|
7
|
+
import type { Message, ReasoningPart, TextPart } from "./schema"
|
|
8
|
+
|
|
9
|
+
const DEFAULT_OUTPUT_RESERVE = 20_000
|
|
10
|
+
|
|
11
|
+
const textFromPart = (part: { type: string }): string => {
|
|
12
|
+
if ((part as TextPart).type === "text") return (part as TextPart).text
|
|
13
|
+
if ((part as ReasoningPart).type === "reasoning") return (part as ReasoningPart).text
|
|
14
|
+
return ""
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Approximate tokens by chars/4. Cheap, provider-agnostic. */
|
|
18
|
+
export const estimateTokens = (msgs: ReadonlyArray<Message>): number => {
|
|
19
|
+
const totalChars = msgs.reduce(
|
|
20
|
+
(acc, msg) => acc + msg.parts.reduce((sum, part) => sum + textFromPart(part as { type: string }).length, 0),
|
|
21
|
+
0,
|
|
22
|
+
)
|
|
23
|
+
return Math.ceil(totalChars / 4)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type UsableInput = {
|
|
27
|
+
readonly limits: ModelLimits | undefined
|
|
28
|
+
/** Override reserved output buffer. Default min(20_000, limits.output). */
|
|
29
|
+
readonly reservedTokens?: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Compute the usable input budget. Returns `Infinity` when the model exposes
|
|
34
|
+
* no `context` limit, mirroring opencode behaviour (no enforced cap).
|
|
35
|
+
*/
|
|
36
|
+
export const usable = (input: UsableInput): number => {
|
|
37
|
+
const context = input.limits?.context
|
|
38
|
+
if (context === undefined || context <= 0) return Number.POSITIVE_INFINITY
|
|
39
|
+
const output = input.limits?.output ?? DEFAULT_OUTPUT_RESERVE
|
|
40
|
+
const reserved = input.reservedTokens ?? Math.min(DEFAULT_OUTPUT_RESERVE, output)
|
|
41
|
+
const budget = context - reserved
|
|
42
|
+
return budget > 0 ? budget : Math.floor(context * 0.9)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** True when estimated tokens would overflow the usable budget. */
|
|
46
|
+
export const isOverflowEstimate = (tokens: number, budget: number): boolean => tokens >= budget
|
|
47
|
+
|
|
48
|
+
/** Convenience: estimate + compare in one call. */
|
|
49
|
+
export const isOverflow = (msgs: ReadonlyArray<Message>, budget: number): boolean =>
|
|
50
|
+
isOverflowEstimate(estimateTokens(msgs), budget)
|