@triggerlink/sdk 0.6.0 → 0.6.1
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/README.md +1 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,6 +123,7 @@ const researcher = createAgent({
|
|
|
123
123
|
system: "You are a research assistant. Answer concisely.",
|
|
124
124
|
tools: { search: searchKb },
|
|
125
125
|
maxIterations: 10, // safety cap; the run fails when exceeded
|
|
126
|
+
maxOutputTokens: 1024, // per-LLM-call output token cap (optional)
|
|
126
127
|
});
|
|
127
128
|
|
|
128
129
|
const answerQuestion = createFunction(
|
package/dist/agent.d.ts
CHANGED
|
@@ -76,6 +76,8 @@ export interface AgentOpts {
|
|
|
76
76
|
tools?: Record<string, AgentTool<any, any>>;
|
|
77
77
|
/** 迭代上限(一次迭代 = 一次 LLM 调用 + 其全部工具执行),默认 10;超限抛错使 run 失败 */
|
|
78
78
|
maxIterations?: number;
|
|
79
|
+
/** 每次 LLM 调用的最大输出 token 数,透传给 generateText;不设则由模型/provider 决定 */
|
|
80
|
+
maxOutputTokens?: number;
|
|
79
81
|
redact?: RedactHook;
|
|
80
82
|
lifecycle?: AgentLifecycle;
|
|
81
83
|
}
|
package/dist/agent.js
CHANGED
|
@@ -67,6 +67,12 @@ export function createAgent(opts) {
|
|
|
67
67
|
if (!Number.isInteger(maxIterations) || maxIterations < 1) {
|
|
68
68
|
throw new Error("createAgent: maxIterations must be a positive integer");
|
|
69
69
|
}
|
|
70
|
+
if (opts.maxOutputTokens !== undefined) {
|
|
71
|
+
if (!Number.isInteger(opts.maxOutputTokens) || opts.maxOutputTokens < 1) {
|
|
72
|
+
throw new Error("createAgent: maxOutputTokens must be a positive integer");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const maxOutputTokens = opts.maxOutputTokens;
|
|
70
76
|
const toolDefs = opts.tools ?? {};
|
|
71
77
|
// 以 schema-only 方式把工具交给 AI SDK(不传 execute):
|
|
72
78
|
// 模型的 tool call 原样返回不执行,"决策"与"执行"之间就是我们的 step 边界(§4.1)。
|
|
@@ -102,6 +108,7 @@ export function createAgent(opts) {
|
|
|
102
108
|
system: opts.system,
|
|
103
109
|
messages,
|
|
104
110
|
tools: aiTools,
|
|
111
|
+
maxOutputTokens,
|
|
105
112
|
});
|
|
106
113
|
const memo = {
|
|
107
114
|
text: res.text,
|