java.lang.Object
com.agentforge4j.runtime.llm.AgentInvoker
Drives a single agent invocation: resolves the agent definition, picks the first enabled provider preference, renders
the input context as JSON, executes against the resolved
LlmClient, and parses the structured command
output.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum characters recorded perWorkflowEventType.LLM_OUTPUTevent.static final intDefault maximum characters for the rendered, untrusted tool-catalog section appended to the system prompt. -
Method Summary
Modifier and TypeMethodDescriptionstatic AgentInvoker.Builderbuilder()Returns a new builder forAgentInvoker.invoke(String agentId, ContextMapping contextMapping, WorkflowState state, String stepPrompt) Invokes an agent without a step-level tier override (equivalent to passingnull).invoke(String agentId, ContextMapping contextMapping, WorkflowState state, String stepPrompt, String stepModelTier) Invokes an agent, optionally overriding the agent's capability tier for this step.invoke(String agentId, ContextMapping contextMapping, WorkflowState state, String stepPrompt, String stepModelTier, String activeWorkflowId) Invokes an agent, carrying the innermost active workflow id onto the invocation identity.
-
Field Details
-
DEFAULT_LLM_OUTPUT_EVENT_CHAR_CAP
public static final int DEFAULT_LLM_OUTPUT_EVENT_CHAR_CAPDefault maximum characters recorded perWorkflowEventType.LLM_OUTPUTevent.- See Also:
-
DEFAULT_TOOL_CATALOG_CHAR_CAP
public static final int DEFAULT_TOOL_CATALOG_CHAR_CAPDefault maximum characters for the rendered, untrusted tool-catalog section appended to the system prompt. A registered MCP/HTTP tool server is an external, untrusted-provenance source; without a bound, an oversizeddescription()/inputSchema()could mount a prompt-stuffing/token-cost attack.0disables truncation.- See Also:
-
-
Method Details
-
builder
Returns a new builder forAgentInvoker.- Returns:
- new builder; never
null
-
invoke
public AgentInvocationResult invoke(String agentId, ContextMapping contextMapping, WorkflowState state, String stepPrompt) Invokes an agent without a step-level tier override (equivalent to passingnull).- Parameters:
agentId- the agent to invoke; must not be blankcontextMapping- context mapping for input rendering; must not benullstate- mutable run state; must not benullstepPrompt- optional static step prompt material; may be blank- Returns:
- the parsed invocation result; never
null
-
invoke
public AgentInvocationResult invoke(String agentId, ContextMapping contextMapping, WorkflowState state, String stepPrompt, String stepModelTier) Invokes an agent, optionally overriding the agent's capability tier for this step. Callers without an active-workflow context use the run's root workflow id (fromstate) as the invocation identity's workflow id; callers driving a nested workflow should use theactiveWorkflowIdoverload so the identity reflects the innermost active workflow.- Parameters:
agentId- the agent to invoke; must not be blankcontextMapping- context mapping for input rendering; must not benullstate- mutable run state; must not benullstepPrompt- optional static step prompt material; may be blankstepModelTier- optional step-level tier name overriding the agent tier;nullor blank inherits the agent tier- Returns:
- the parsed invocation result; never
null
-
invoke
public AgentInvocationResult invoke(String agentId, ContextMapping contextMapping, WorkflowState state, String stepPrompt, String stepModelTier, String activeWorkflowId) Invokes an agent, carrying the innermost active workflow id onto the invocation identity. The run executes under a single root run/state (WorkflowState.workflowIdis the root and is immutable), so the active workflow id of a nested workflow is not recoverable fromstate— the caller (which holds the execution context) supplies it here so thatLlmInvocationIdentity.workflowId()distinguishes steps of different nested workflows under one run.- Parameters:
agentId- the agent to invoke; must not be blankcontextMapping- context mapping for input rendering; must not benullstate- mutable run state; must not benullstepPrompt- optional static step prompt material; may be blankstepModelTier- optional step-level tier name overriding the agent tier;nullor blank inherits the agent tieractiveWorkflowId- innermost active workflow id for this call (the run's root workflow id when not nested); must not be blank- Returns:
- the parsed invocation result; never
null
-