类 ToolContextState

java.lang.Object
io.agentscope.core.state.ToolContextState

public final class ToolContextState extends Object
Read-cache backing for file-touching tools (Read / Write / Edit).

Maintains an ordered LRU list of ReadCacheEntry bounded by both entry count and total bytes. Cache reads are validated against the file's current mtime; stale entries are evicted on access. All filesystem interaction runs on Schedulers.boundedElastic() so Reactor's non-blocking schedulers are never blocked.

Only configuration fields (maxCacheFiles, maxCacheBytes, activatedGroups) participate in JSON serialization. The in-memory LRU cache itself is runtime state and is reconstructed empty on deserialization.

  • 方法详细资料

    • getMaxCacheFiles

      public int getMaxCacheFiles()
    • getMaxCacheBytes

      public double getMaxCacheBytes()
    • getReadFileCache

      public List<ReadCacheEntry> getReadFileCache()
      Snapshot of the cache list at call time. Modifications do not affect the live cache.
    • getActivatedGroups

      public List<String> getActivatedGroups()
    • setActivatedGroups

      public void setActivatedGroups(List<String> groups)
      Replace the activated tool groups with the given list.
      参数:
      groups - the new activated groups; null clears the list
    • getSpawnRegistry

      public Map<String,ToolContextState.SpawnEntry> getSpawnRegistry()
    • putSpawnEntry

      public void putSpawnEntry(String key, ToolContextState.SpawnEntry entry)
      Register a spawned subagent entry so it survives session restore and cross-replica routing.
      参数:
      key - the agent key (e.g. agent:general-purpose:uuid)
      entry - the serializable spawn metadata
    • removeSpawnEntry

      public void removeSpawnEntry(String key)
      Remove a spawn entry by key.
    • getCache

      public reactor.core.publisher.Mono<Optional<ReadCacheEntry>> getCache(String filePath)
      Look up the cached entry for filePath. Evicts and returns empty if the file's mtime has changed or the file no longer exists.
    • cacheFile

      public reactor.core.publisher.Mono<Void> cacheFile(String filePath, List<String> lines)
      Insert lines for filePath into the cache, evicting older entries to satisfy both maxCacheFiles and maxCacheBytes. If the file's mtime is unavailable the insert is silently skipped.
    • builder

      public static ToolContextState.Builder builder()