Record Class AgentConfiguration
LLM settings
and Agents entries keyed by actual Java type. It does not own instance
names, files, class loading, role binding or filesystem permissions.
The host captures this snapshot and validates all type keys against its complete
registered run types before any LLM call, source ingestion or action. A simple key
must identify exactly one registered type; a qualified key must match its binary
name. A simple key that names both an agent class and a role class, one with
RoleSpec and no AgentSpec, selects the agent class, as in
ClassConfig; a key that names only a role class selects it, as in 0.18.1.
Two keys selecting the same class are rejected. Registration must be complete
before validation, not assembled incrementally while agents execute.
Each Agents entry takes the shape of an agent's @Config file:
llm, knowledge and roles. parse(org.json.JSONObject) checks that shape and
decodes the llm; the host passes the section's text to
ClassConfig.useBaseDirectory(ClassConfig.RunFile), which checks the contents of
all three and applies them over the class's own configuration.
validate(JSONObject, Collection) runs the same check on the host's sections,
so a host can refuse an edited section before saving it.
The bridge then resolves, lowest first: the annotations, the shared()
settings the host registers with
SCOPBridge.llmConfigurationSource(LLMConfigurationSource), as
name -> Optional.of(configuration.shared()), the class configuration files,
the run file's type section and its roles section. The host registers
shared(), not resolve(java.lang.Class<?>, java.util.Collection<java.lang.Class<?>>) .llm(), so the type's llm
applies once, at the run level. resolve(java.lang.Class<?>, java.util.Collection<java.lang.Class<?>>) reads llm only: it gives
neither knowledge nor roles, which reach an agent only through the
section passed to ClassConfig.
Until 0.18.1 a host overlaid its own instance, file and explicit run layers on
resolve(java.lang.Class<?>, java.util.Collection<java.lang.Class<?>>) .llm(), so they won over the type's entry. The
LLMConfigurationSource a host registers now sits below the class configuration
files and the run file's type section, so such layers no longer win over the type's
llm; a setting that must win goes in the run file's section.
- Since:
- 0.17.5
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThellmof oneAgentsentry, or of a file that holds only LLM settings. -
Constructor Summary
ConstructorsConstructorDescriptionAgentConfiguration(LLMOverrides shared, Map<String, AgentConfiguration.AgentSettings> agents) Creates an instance of aAgentConfigurationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionagents()Returns the value of theagentsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static AgentConfigurationparse(org.json.JSONObject sections) Parses only the optionalLLM/Agentsfragment.resolve(Class<?> actualType, Collection<Class<?>> knownTypes) Resolves a registered actual type, independent of its instance name or construction order.shared()Returns the value of thesharedrecord component.final StringtoString()Returns a string representation of this record class.voidvalidate(Collection<Class<?>> knownTypes) Validates every configured type key, including when the complete registry is empty.static voidvalidate(org.json.JSONObject sections, Collection<Class<?>> knownTypes) Parses a host's sections and checks them against the complete registered types of its run.
-
Constructor Details
-
AgentConfiguration
Creates an instance of aAgentConfigurationrecord class.- Parameters:
shared- the value for thesharedrecord componentagents- the value for theagentsrecord component
-
-
Method Details
-
parse
Parses only the optionalLLM/Agentsfragment. A generic host configuration adapter extracts those subtrees without interpreting their fields. Explicit null or a wrong subtree type is invalid, rather than an absent setting. EachAgentsentry takesllm,knowledgeandroles, each optional and an object; onlyllmis decoded here, andClassConfigchecks the contents ofknowledgeandroles.- Parameters:
sections- the fragment, with at most theLLMandAgentssections- Returns:
- the parsed configuration
- Throws:
IllegalArgumentException- if the fragment has another section, a section or entry is not an object, a type key is blank or padded, or an entry has another field or a field that is not an object; the error names the entry by its type, and one that gives an LLM setting such astemperatureflat is told to move the setting underllmLLMConfigurationException- if theLLMsection or an entry'sllmholds an unknown or invalid field- Since:
- 0.17.5
-
validate
Parses a host's sections and checks them against the complete registered types of its run. It checks theAgentssection asClassConfig.checkAgents(ClassConfig.RunFile)does, so a key naming a role class fails and the field names insideknowledgeand inside eachrolesentry are checked; a misspelt role name is not, since aroleskey is checked when the agent binds the roles it plays. It checks eachrolesentry'sllmasparse(org.json.JSONObject)checks an entry's ownllm, and then the type keys asvalidate(Collection)checks them. A host calls it with the sections it gaveparse(org.json.JSONObject)once its run's types are complete, before the run starts, and with edited sections before it saves them. It neither starts a run nor changes the current one.- Parameters:
sections- the fragment, asparse(org.json.JSONObject)takes itknownTypes- the complete registered run types; a class that is not an agent type, such as the run's own class, may be among them- Throws:
IllegalArgumentException- ifparse(org.json.JSONObject)refuses the fragment, ifClassConfig.checkAgents(ClassConfig.RunFile)refuses theAgentssection, with its message, or if the type keys fail asvalidate(Collection)describes; a field of arolesentry'sllmthat is unknown, null or not of its JSON kind fails hereLLMConfigurationException- asparse(org.json.JSONObject)throws it, or if arolesentry'sllmholds a value of the right JSON kind thatLLMOverrides.fromJson(org.json.JSONObject)refuses: atemperatureoutside 0 to 2, amaxTokensthat is not a non-negative whole number within int range, a blank text field or an unknown or unroutable provider; the error names the entry and the role- Since:
- 0.18.2
-
validate
Validates every configured type key, including when the complete registry is empty. It checks the keys only;validate(JSONObject, Collection)checks the wholeAgentssection.- Parameters:
knownTypes- the complete registered run types- Throws:
IllegalArgumentException- if a key matches no registered type, a simple key matches more than one, unless exactly one of them is not a role class, or two keys select the same type- Since:
- 0.17.5
-
resolve
public AgentConfiguration.AgentSettings resolve(Class<?> actualType, Collection<Class<?>> knownTypes) Resolves a registered actual type, independent of its instance name or construction order. All configured keys are validated even when they target another class. It readsllmonly: an entry'sknowledgeandrolesare neither checked nor given here, and reach an agent only through the section a host passes toClassConfig.useBaseDirectory(ClassConfig.RunFile).- Parameters:
actualType- the agent's actual classknownTypes- the complete registered run types- Returns:
- the shared
LLMsettings with the type'sllmover them - Throws:
IllegalArgumentException- ifactualTypeis not registered, or the keys fail asvalidate(Collection)describes- Since:
- 0.17.5
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
agents
Returns the value of theagentsrecord component.- Returns:
- the value of the
agentsrecord component
-