ランタイムでモデルを選ぶ
model、models、instructions、temperature、maxOutputTokens、topPに動的な値を指定できます。
ツールからアプリのコンテキストを更新する
ツールはcontext.setContext()で後続ターン用の情報を保存できます。
次のターンだけを上書きする
エージェント定義を恒久的に変えず、ツールで次のリクエストを変更するにはnextTurnParamsを使います。
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
エージェントのターン間でモデル、指示、サンプリング、ツールを変更します。
type ResearchContext = {
fast: boolean;
};
const agent = createAgent<string, string, ResearchContext>({
id: "research-agent",
model: ({ context }) =>
context?.fast ? "phaseo/free" : "anthropic/claude-sonnet-4",
instructions: ({ numberOfTurns }) =>
`Research turn ${numberOfTurns}. Cite the evidence you use.`,
});
model、models、instructions、temperature、maxOutputTokens、topPに動的な値を指定できます。
context.setContext()で後続ターン用の情報を保存できます。
const chooseMode = defineTool({
id: "choose-mode",
async execute(input: { fast: boolean }, context) {
context.setContext({ fast: input.fast });
return { selected: input.fast ? "fast" : "thorough" };
},
});
nextTurnParamsを使います。
const broadenSearch = defineTool({
id: "broaden-search",
nextTurnParams: {
temperature: 0.3,
maxOutputTokens: 2_000,
},
async execute() {
return { broadened: true };
},
});