Class SessionTurnAdvisor.Builder

java.lang.Object
org.springframework.ai.session.advisor.SessionTurnAdvisor.Builder
Enclosing class:
SessionTurnAdvisor

public static final class SessionTurnAdvisor.Builder extends Object
  • Method Details

    • order

      public SessionTurnAdvisor.Builder order(int order)
      The order; SessionTurnAdvisor.DEFAULT_ORDER by default. Keep it before the tool-calling advisor, so the loop runs inside the turn.
    • scheduler

      public SessionTurnAdvisor.Builder scheduler(reactor.core.scheduler.Scheduler scheduler)
      The scheduler the session writes of a streamed call run on.
    • compactionTrigger

      public SessionTurnAdvisor.Builder compactionTrigger(CompactionTrigger trigger)
      When to compact once a turn has ended; set together with compactionStrategy.
    • compactionStrategy

      public SessionTurnAdvisor.Builder compactionStrategy(CompactionStrategy strategy)
      How to compact; set together with compactionTrigger.
    • asyncCompaction

      public SessionTurnAdvisor.Builder asyncCompaction(boolean asyncCompaction)
      Whether compaction runs after the call returns, on the scheduler, so a summarizing strategy adds no model call to the reply's latency; false by default. A call() runs it with the caller's thread-local context, the security context for example, captured with Micrometer's context propagation; a stream() ends on the scheduler already. One compaction per session runs at a time from this advisor; a new turn that writes to the session meanwhile stays in the view, the compaction lands rebased onto its events with the same summary. Only another compaction's boundary, or turns that keep overtaking it, make it stand down until the next turn.
    • sessionIdInToolContext

      public SessionTurnAdvisor.Builder sessionIdInToolContext(boolean sessionIdInToolContext)
      Whether the advisor puts the session id into the tool context of the call, under SessionMemoryAdvisor.SESSION_ID_CONTEXT_KEY; false by default. A tool that reads the session, such as SessionRecallTools, then finds the id without the caller passing it with toolContext(..) too. A value the caller sets under the key stands.

      The tool context goes to every tool of the call, so turning this on has three effects beyond the session tools. Every tool that takes a ToolContext sees the session id. The tools of an MCP server get it as request metadata, unless a ToolContextToMcpMetaConverter leaves it out. And a tool that takes a ToolContext is no longer refused when the call passes no tool context: it runs with one that holds the session id only.

    • build

      public SessionTurnAdvisor build()