Interface Thinker<I extends ThinkerInput, O extends ThinkerOutput<? extends Reasoning>>
- Type Parameters:
I- Input type - must extend ThinkerInput for uniform query handlingO- Output type - must extend ThinkerOutput for uniform response handling
- All Superinterfaces:
ConversationCarrier, GuardedExecution, Identifiable, Job<O>, ModelDependent, ModelDependentTool<I,O>, Orchestrator<I, O>, ScopeAuthority, Tool<I, O>
- All Known Implementing Classes:
AbstractThinker, AbstractToollessThinker, CaseAgent, ChatThinker, DemoAgent, EPOThinker, LiteratureAggregator, OrderAgent, ReactiveThinker, SelectingAgent, SingleObjectiveThinker, SubThinker, UsptoOdpThinker
public interface Thinker<I extends ThinkerInput, O extends ThinkerOutput<? extends Reasoning>>
extends Orchestrator<I,O>, ModelDependentTool<I,O>, ConversationCarrier
Interface for reasoning agents that coordinate tool execution.
Thinkers are specialized tools that solve problems by iteratively using available tools. They accept structured input like all tools, but their execution involves complex multi-step reasoning and tool orchestration.
Key difference from simple tools: Thinkers run conversation loops with LLMs and dynamically select which tools to use, while simple tools perform single operations.
Composition: Since thinkers are tools, they can be used by other thinkers, enabling hierarchical multi-agent systems where meta-agents coordinate specialist agents.
- Since:
- 0.1 (2025-09-19)
- Author:
- Andrey Santrosyan
-
Field Summary
Fields inherited from interface Job
DEFAULT_UPSTREAM_RETRIESFields inherited from interface Tool
OBS_INPUT, OBS_OUTPUT -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTool(ToolProvider provider) Adds aToolProviderto this thinker's available tools.voidAdds a tool to this thinker's available tools.Builds tool definition blocks for all registered tools.booleanReturns whether all conversation messages should be cached.Gets the conversation ID for this thinker.getDepth()How much effort this thinker's calls ask for: its input's depth for a goal-directed thinker, its declared field for a reactive one.Gets the retention duration after the thinker finishes (execute()'s finally block).How much answer this thinker's turns book: anOutputSizerung or a raw count, declared in the constructor next to the grade.Gets all currently registered providers (class-based and otherwise).Gets the retention duration for intermediate releases (between tool calls).Collection<Class<? extends Tool>> getTools()Gets all currently registered tool classes.booleanChecks if a tool class is registered with this thinker.booleanChecks if a tool name is registered with this thinker.booleanWhether this thinker's conversation identity was minted fresh (as opposed to adopted or left on the temporary jobId default).booleanWhether a human is waiting on this thinker's answers - a demand flavor pickers may weigh.booleanReturns whether this thinker was invoked as a tool by another thinker.Mints a durable identity for a brand-new conversation, decoupled from job lineage.voidremoveTool(Class<? extends Tool> toolClass) Removes a tool from this thinker's available tools.voidremoveTool(String toolName) Removes a tool by registered name.voidsetCacheAllMessages(boolean cacheAllMessages) Sets whether all conversation messages should be cached.voidsetConversationId(String conversationId) Adopts an existing conversation: the thinker resumes the conversation with this id, and obtaining it fails when no store holds it - a resume that silently minted an empty conversation would leave the model defending reasoning it can no longer see.voidsetFinalRetainDuration(Duration finalRetainDuration) Sets the retention duration after the thinker finishes.voidsetInvokedAsTool(boolean invokedAsTool) Marks this thinker as being invoked as a tool.voidsetRetainDuration(Duration retainDuration) Sets the retention duration for intermediate releases.Methods inherited from interface GuardedExecution
declareAdmissionGuardrails, declareAuthGuardrails, declareContentGuardrailsMethods inherited from interface Identifiable
getParentJobId, getUserId, getWorkflowIdMethods inherited from interface Job
getDisplayName, getId, getJobId, getJobType, getName, getPriority, getRequirements, getTimeout, getUpstreamRetries, postExecute, preExecuteMethods inherited from interface ModelDependent
getGrade, pinModel, pinnedModel, requireSeat, setGradeMethods inherited from interface ScopeAuthority
getScopeGuard, sealScopeGuard, setScopeGuardMethods inherited from interface Tool
execute, getInput, guardedInputTarget, setInput
-
Method Details
-
isInteractive
boolean isInteractive()Whether a human is waiting on this thinker's answers - a demand flavor pickers may weigh. -
getDepth
Depth getDepth()How much effort this thinker's calls ask for: its input's depth for a goal-directed thinker, its declared field for a reactive one. Stamped onto the conversation by ConversationService at obtain time, next to the grade. -
getOutputDeclaration
OutputDeclaration getOutputDeclaration()How much answer this thinker's turns book: anOutputSizerung or a raw count, declared in the constructor next to the grade. Null before the declaration; execution refuses a thinker that reaches it without one. Stamped onto the conversation by ConversationService at obtain time. -
addTool
-
addTool
Adds aToolProviderto this thinker's available tools. Mirror ofaddTool(Class)for providers that are not class-backed (e.g. MCP-bound).- Parameters:
provider- the provider to add
-
removeTool
-
removeTool
Removes a tool by registered name. Mirror ofremoveTool(Class)for providers without an associated Java class.- Parameters:
toolName- the tool name to remove
-
hasTool
-
hasTool
Checks if a tool name is registered with this thinker.- Parameters:
toolName- the tool name to check- Returns:
- true if the tool is registered
-
getTools
Collection<Class<? extends Tool>> getTools()Gets all currently registered tool classes.- Returns:
- unmodifiable collection of tool classes
-
getProviders
Collection<ToolProvider> getProviders()Gets all currently registered providers (class-based and otherwise).- Returns:
- unmodifiable collection of providers
-
buildToolDefinitionBlocks
List<ContentBlocks.ToolDefinitionBlock> buildToolDefinitionBlocks()Builds tool definition blocks for all registered tools. Used for conversation context when loading from persistence.- Returns:
- list of tool definition blocks
-
cacheAllMessages
boolean cacheAllMessages()Returns whether all conversation messages should be cached. When enabled, every message added to the conversation context will have caching enabled automatically (if supported by the LLM provider).- Returns:
- true to cache all messages, false for manual control
-
setCacheAllMessages
void setCacheAllMessages(boolean cacheAllMessages) Sets whether all conversation messages should be cached.- Parameters:
cacheAllMessages- true to enable caching for all messages
-
isInvokedAsTool
boolean isInvokedAsTool()Returns whether this thinker was invoked as a tool by another thinker. When true, the thinker should not stream results directly to the user - the results will be returned to the parent thinker as a tool result.- Returns:
- true if invoked as a tool, false if running standalone
-
setInvokedAsTool
void setInvokedAsTool(boolean invokedAsTool) Marks this thinker as being invoked as a tool. Set automatically by the parent thinker when using this thinker as a tool.- Parameters:
invokedAsTool- true if being used as a tool
-
getRetainDuration
Duration getRetainDuration()Gets the retention duration for intermediate releases (between tool calls). Controls how long the conversation stays in memory during active processing.- Returns:
- the intermediate retention duration
-
setRetainDuration
Sets the retention duration for intermediate releases.- Parameters:
retainDuration- the intermediate retention duration
-
getFinalRetainDuration
Duration getFinalRetainDuration()Gets the retention duration after the thinker finishes (execute()'s finally block). Controls how long the conversation persists in memory after the thinker completes.- Returns:
- the final retention duration
-
setFinalRetainDuration
Sets the retention duration after the thinker finishes.- Parameters:
finalRetainDuration- the final retention duration
-
getConversationId
String getConversationId()Gets the conversation ID for this thinker. By default returns the job ID for new conversations. Can be set to resume existing conversations.- Returns:
- the conversation ID (job ID if not explicitly set)
-
setConversationId
Adopts an existing conversation: the thinker resumes the conversation with this id, and obtaining it fails when no store holds it - a resume that silently minted an empty conversation would leave the model defending reasoning it can no longer see.- Specified by:
setConversationIdin interfaceConversationCarrier- Parameters:
conversationId- the existing conversation ID to resume
-
mintConversationId
String mintConversationId()Mints a durable identity for a brand-new conversation, decoupled from job lineage. The id follows the framework's readable shape - the thinker's class name, aconvmarker, and a short random tail (e.g.ChatThinker-conv-a26f-52b01fa3bd75) - so DB rows and logs stay scannable and a minted id is never mistaken for a job id. The conversation is created fresh under this id and every later turn adopts it viasetConversationId(String). Thinkers that call neither keep the default: a temporary conversation keyed by the thinker's own job id.- Returns:
- the minted conversation ID
-
isConversationMinted
boolean isConversationMinted()Whether this thinker's conversation identity was minted fresh (as opposed to adopted or left on the temporary jobId default). A minted conversation has no durable record yet: its first user-message save CREATES the record - titled and embedded from that message, exactly once - and every later save is an update.- Returns:
- true when
mintConversationId()named this conversation
-