AS AgentScopeAPI 手册 / API Reference

SessionFreshnessEvaluator

public class SessionFreshnessEvaluator
源码Source io/agentscope/harness/agent/memory/session/SessionFreshnessEvaluator.java:33–93

会话 Freshness 评估器,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.harness.agent.memory.session 包。核心成员包括 isStale、getDailyResetHour、getIdleTimeout、SessionFreshnessEvaluator。

Evaluates whether a session is still "fresh" or should be reset.

Inspired by agentscope-claw's SessionFreshnessEvaluator. Supports two reset policies:

  • Daily reset: AgentStateStore resets after a configured hour each day

  • Idle timeout: AgentStateStore resets after inactivity exceeding a threshold

构造器摘要Constructor Summary

构造器Constructor说明Description
public SessionFreshnessEvaluator()
初始化 `SessionFreshnessEvaluator` 实例。
Creates a freshness evaluator with default settings: daily reset at 4 AM, idle timeout of 2 hours, system timezone.
public SessionFreshnessEvaluator(int dailyResetHour, Duration idleTimeout, ZoneId timezone)
初始化 `SessionFreshnessEvaluator` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public boolean isStale(Instant lastActivityAt)
判断是否过期。
Determines if the session should be considered stale and reset.
public int getDailyResetHour()
获取 `getDailyResetHour`。
Returns the daily reset hour.
public Duration getIdleTimeout()
获取 `getIdleTimeout`。
Returns the idle timeout.

构造器详情Constructor Detail

SessionFreshnessEvaluator

public SessionFreshnessEvaluator()

初始化 SessionFreshnessEvaluator 实例。

Creates a freshness evaluator with default settings: daily reset at 4 AM, idle timeout of 2 hours, system timezone.

源码Source io/agentscope/harness/agent/memory/session/SessionFreshnessEvaluator.java:43–45

SessionFreshnessEvaluator

public SessionFreshnessEvaluator(int dailyResetHour, Duration idleTimeout, ZoneId timezone)

初始化 SessionFreshnessEvaluator 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
dailyResetHourintdaily 重置 Hour(类型 `int`)。The daily reset hour.
idleTimeoutDurationidle 超时(类型 `Duration`)。The idle timeout.
timezoneZoneIdtimezone(类型 `ZoneId`)。The timezone.
源码Source io/agentscope/harness/agent/memory/session/SessionFreshnessEvaluator.java:47–51

方法详情Method Detail

isStale

public boolean isStale(Instant lastActivityAt)

判断是否过期。

Determines if the session should be considered stale and reset.

参数Parameters
名称Name类型Type说明Description
lastActivityAtInstant最后 Activity At(类型 `Instant`)。the timestamp of the last activity in the session
返回Returns boolean
返回布尔值,表示判断结果。true if the session should be reset
源码Source io/agentscope/harness/agent/memory/session/SessionFreshnessEvaluator.java:59–84

getDailyResetHour

public int getDailyResetHour()

获取 getDailyResetHour。

Returns the daily reset hour.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/harness/agent/memory/session/SessionFreshnessEvaluator.java:86–88

getIdleTimeout

public Duration getIdleTimeout()

获取 getIdleTimeout。

Returns the idle timeout.

返回Returns Duration
返回时长。Returns duration.
源码Source io/agentscope/harness/agent/memory/session/SessionFreshnessEvaluator.java:90–92
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.