Skip to content
English

selectContextSteps ​

SUPPORT · function · 运行时值

Choose steps that fit the remaining call budget.

Feasibility uses exact trim previews and declared call ceilings; the reply reserve and the selector's own allowance are subtracted before candidates are considered, so neither can be spent on reductions.

导入 ​

ts
import { selectContextSteps } from '@jangts/agent-core/support';
js
import { selectContextSteps } from '@jangts/agent-core/support';

其他公开入口:@jangts/agent-core/support、@jangts/agent-core/support/context。

定义 ​

调用 ​

ts
selectContextSteps(input: SelectionInput): Promise<SelectionResult>

Choose steps that fit the remaining call budget.

Feasibility uses exact trim previews and declared call ceilings; the reply reserve and the selector's own allowance are subtracted before candidates are considered, so neither can be spent on reductions.

参数类型传递说明
inputSelectionInput必需—
input 的字段
字段类型必需说明
signalAbortSignal必需只读。见类型定义及调用场景。
diagnosticsDiagnosticContext | undefined可省略见类型定义及调用场景。
selectionContextSelection必需见类型定义及调用场景。
selectorsreadonly ContextSelector[]必需见类型定义及调用场景。
stageIdstring必需只读。见类型定义及调用场景。
candidatesreadonly ContextSelectionCandidate[]必需Reducible candidates, already filtered and measured.
fragmentsreadonly ContextFragment[]必需Only reducible fragments; never protected request or system fragments.
currentTokensnumber | undefined可省略Current input tokens, when a token budget applies.
requiredReductionTokensnumber | undefined可省略Tokens that must be removed to satisfy the token budget.
currentCharsnumber必需见类型定义及调用场景。
requiredReductionCharsnumber必需Characters that must be removed to satisfy the character budget.
remainingCallsnumber必需Calls the selector may still spend through callModel.
callModelContextModelCall必需见类型定义及调用场景。

返回: Promise<SelectionResult>。

等待后的值: SelectionResult。

返回值结构
字段类型必需说明
stepIdsstring[]必需见类型定义及调用场景。
reasonstring必需见类型定义及调用场景。

使用示例 ​

按已登记顺序处理 ​

入门 · Node.js

ts
import { Support } from '@jangts/agent-core';
Support.validateContextSelection({ mode: 'sequence' }, []);
console.log(Object.keys(Support.contextSelectionCatalog));
js
import { Support } from '@jangts/agent-core';
Support.validateContextSelection({ mode: 'sequence' }, []);
console.log(Object.keys(Support.contextSelectionCatalog));

按场景选择策略并精确覆盖 ​

配置 · Node.js

ts
import { Support } from '@jangts/agent-core';
const localOnly = { mode: 'fixed' as const, kind: 'trim' as const };
const preserveMore = { mode: 'auto' as const, maxTrimLossRatio: 0.1, reserveCalls: 2 };
Support.validateContextSelection(localOnly, []);
Support.validateContextSelection(preserveMore, []);
console.log(localOnly, preserveMore);
js
import { Support } from '@jangts/agent-core';
const localOnly = { mode: 'fixed', kind: 'trim' };
const preserveMore = { mode: 'auto', maxTrimLossRatio: 0.1, reserveCalls: 2 };
Support.validateContextSelection(localOnly, []);
Support.validateContextSelection(preserveMore, []);
console.log(localOnly, preserveMore);

相关策略源码 ​

接口参考、使用示例与开发指南。