@springbrand/agent-runtime 0.1.3-alpha.0 → 0.1.3-alpha.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/src/runtime.ts CHANGED
@@ -927,18 +927,19 @@ export abstract class AgentRuntimeKernel<
927
927
  }
928
928
  }
929
929
 
930
- // 作用:按当前内存预算和模型压缩 Pi 上下文。
930
+ // 作用:按当前模型输入预算压缩 Pi 上下文。
931
931
  // 调用:Pi Turn 适配器在发模型请求前通过 `transformContext` 回调。
932
- // 原因:压缩必须使用本 Snapshot 的模型和密钥,不能脱离已固定的 Runtime 配置。
932
+ // 原因:模型窗口必须预留最大输出,压缩也必须使用本 Snapshot 的模型和密钥。
933
933
  private async transformPiContext(
934
934
  submissionId: string,
935
935
  messages: Parameters<PiRuntimeTranscript["compactContext"]>[0],
936
936
  signal?: AbortSignal,
937
937
  ): ReturnType<PiRuntimeTranscript["compactContext"]> {
938
938
  const snapshot = this.assembly();
939
+ const inputBudget = snapshot.pi.model.contextWindow -
940
+ snapshot.pi.model.maxTokens;
939
941
  const compacted = await this.transcript.compactContext(messages, {
940
- compactAfterTokens:
941
- snapshot.profile.memory.compactAfterTokens,
942
+ compactAfterTokens: inputBudget * 0.85,
942
943
  model: snapshot.pi.model,
943
944
  apiKey: this.pi.resolveApiKey(
944
945
  snapshot.bindings.provider,