Class SessionTurnAdvisor.Builder
java.lang.Object
org.springframework.ai.session.advisor.SessionTurnAdvisor.Builder
- Enclosing class:
- SessionTurnAdvisor
-
Method Summary
Modifier and TypeMethodDescriptionasyncCompaction(boolean asyncCompaction) Whether compaction runs after the call returns, on thescheduler, so a summarizing strategy adds no model call to the reply's latency;falseby default.build()compactionStrategy(CompactionStrategy strategy) How to compact; set together withcompactionTrigger.compactionTrigger(CompactionTrigger trigger) When to compact once a turn has ended; set together withcompactionStrategy.order(int order) The order;SessionTurnAdvisor.DEFAULT_ORDERby default.scheduler(reactor.core.scheduler.Scheduler scheduler) The scheduler the session writes of a streamed call run on.sessionIdInToolContext(boolean sessionIdInToolContext) Whether the advisor puts the session id into the tool context of the call, underSessionMemoryAdvisor.SESSION_ID_CONTEXT_KEY;falseby default.
-
Method Details
-
order
The order;SessionTurnAdvisor.DEFAULT_ORDERby default. Keep it before the tool-calling advisor, so the loop runs inside the turn. -
scheduler
The scheduler the session writes of a streamed call run on. -
compactionTrigger
When to compact once a turn has ended; set together withcompactionStrategy. -
compactionStrategy
How to compact; set together withcompactionTrigger. -
asyncCompaction
Whether compaction runs after the call returns, on thescheduler, so a summarizing strategy adds no model call to the reply's latency;falseby default. Acall()runs it with the caller's thread-local context, the security context for example, captured with Micrometer's context propagation; astream()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
Whether the advisor puts the session id into the tool context of the call, underSessionMemoryAdvisor.SESSION_ID_CONTEXT_KEY;falseby default. A tool that reads the session, such asSessionRecallTools, then finds the id without the caller passing it withtoolContext(..)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
ToolContextsees the session id. The tools of an MCP server get it as request metadata, unless aToolContextToMcpMetaConverterleaves it out. And a tool that takes aToolContextis no longer refused when the call passes no tool context: it runs with one that holds the session id only. -
build
-