Context
Currently, AI Agents are defined inline within Worker definitions:
spec :
workers :
- name : sentiment-analyzer
capabilities :
- analyzeSentiment
agent :
systemPrompt : " You are a sentiment analyzer..."
inputSchema : " { text: .text }"
outputSchema : " { sentiment: .sentiment }"
model :
openai :
apiKey : " ${OPENAI_API_KEY}"
modelName : " gpt-4"
Current implementation:
Agent is a property of Worker (PR Add AI Agent support as Worker execution type #244 )
No reusability: same agent config must be duplicated across workers
Agents are not first-class participants in the Case model
Location: schema/src/main/resources/schema/CaseDefinition.yaml
Problem
1. No Reusability
If multiple workers need the same LLM configuration, the entire agent block must be duplicated:
workers :
- name : sentiment-worker
agent :
systemPrompt : " Analyze sentiment"
model :
openai :
apiKey : " ${OPENAI_API_KEY}"
modelName : " gpt-4"
temperature : 0.3
- name : classification-worker
agent :
systemPrompt : " Classify documents" # Different prompt
model :
openai :
apiKey : " ${OPENAI_API_KEY}" # Duplicated config
modelName : " gpt-4" # Duplicated config
temperature : 0.3 # Duplicated config
2. Agents are not first-class participants
According to docs/Case Hub, design.md:
A Worker is an autonomous participant in a Case that can perform work or modify the CaseContext. A Worker may be a person, a service, a workflow, a rule, or an autonomous agent .
Currently, agents can only exist as part of a worker. There's no way to define an autonomous agent as a standalone participant.
3. No agent registry/catalog
No way to list available agents
No way to reference agents by name
No agent lifecycle management (deploy, undeploy, version)
Proposed Solution
Option 1: Reusable Agent Definitions (Minimal)
Define agents in use.agents and reference them by name:
use :
agents :
- name : gpt4-analyzer
model :
openai :
apiKey : " ${OPENAI_API_KEY}"
modelName : " gpt-4"
temperature : 0.3
- name : local-llama
model :
ollama :
baseUrl : " http://localhost:11434"
modelName : " llama2"
spec :
workers :
- name : sentiment-worker
capabilities :
- analyzeSentiment
agent :
use : gpt4-analyzer # Reference by name
systemPrompt : " Analyze sentiment"
inputSchema : " { text: .text }"
outputSchema : " { sentiment: .sentiment }"
- name : classification-worker
capabilities :
- classify
agent :
use : gpt4-analyzer # Reuse same model config
systemPrompt : " Classify documents"
inputSchema : " { content: .document }"
outputSchema : " { category: .category }"
Schema changes:
CaseDefinitionUse :
properties :
agents :
type : array
items :
$ref : " #/$defs/AgentDefinition"
AgentDefinition :
type : object
required : [name, model]
properties :
name : { type: string }
model : { $ref: "#/$defs/AgentModel" }
Agent :
properties :
use : { type: string } # Reference to AgentDefinition.name
systemPrompt : { type: string }
inputSchema : { type: string }
outputSchema : { type: string }
model : # Optional: can override model from 'use'
$ref : " #/$defs/AgentModel"
Option 2: First-class Agents (Full)
Agents as top-level participants alongside Workers:
spec :
agents :
- name : sentiment-analyzer
capabilities :
- analyzeSentiment
systemPrompt : " Analyze sentiment"
inputSchema : " { text: .text }"
outputSchema : " { sentiment: .sentiment }"
model :
openai :
apiKey : " ${OPENAI_API_KEY}"
modelName : " gpt-4"
- name : document-classifier
capabilities :
- classify
systemPrompt : " Classify documents"
inputSchema : " { content: .document }"
outputSchema : " { category: .category }"
model :
use : gpt4-analyzer # Can still reference shared config
workers :
- name : http-service
capabilities :
- fetchData
# Traditional service worker
Schema changes:
CaseDefinitionSpec :
properties :
capabilities : ...
workers : ...
agents : # New top-level section
type : array
items :
$ref : " #/$defs/AgentWorker"
AgentWorker :
type : object
required : [name, capabilities, systemPrompt, inputSchema, outputSchema, model]
properties :
name : { type: string }
description : { type: string }
capabilities :
type : array
items : { type: string }
systemPrompt : { type: string }
inputSchema : { type: string }
outputSchema : { type: string }
userMessageTemplate : { type: string }
model :
oneOf :
- type : string # Reference to use.agents[].name
- $ref : " #/$defs/AgentModel" # Inline definition
executionPolicy :
$ref : " #/$defs/ExecutionPolicy"
Option 3: Hybrid (Recommended)
Combine both approaches:
use.agents for reusable model configurations
spec.agents for autonomous agent participants
spec.workers[].agent for inline agent configs (backward compatible)
use :
agents :
- name : gpt4-turbo
model :
openai :
apiKey : " ${OPENAI_API_KEY}"
modelName : " gpt-4-turbo"
temperature : 0.3
spec :
# Autonomous agents (first-class participants)
agents :
- name : sentiment-analyzer
capabilities : [analyzeSentiment]
model :
use : gpt4-turbo
systemPrompt : " Analyze sentiment"
inputSchema : " { text: .text }"
outputSchema : " { sentiment: .sentiment }"
# Service workers with embedded agents
workers :
- name : data-processor
capabilities : [process]
agent :
use : gpt4-turbo
systemPrompt : " Process data"
inputSchema : " { data: .input }"
outputSchema : " { result: .output }"
Implementation Plan
Phase 1: Reusable Agent Definitions
Phase 2: First-class Agents
Phase 3: Advanced Features
Acceptance Criteria
Phase 1 (Minimal):
Phase 2 (Full):
Design Considerations
1. Agent vs Worker
When to use spec.agents vs spec.workers[].agent?
Use Case
Pattern
Pure AI participant (no custom code)
spec.agents
Service with AI augmentation
spec.workers[].agent
Reusable model config
use.agents
2. Reference Resolution
// In CaseDefinitionYamlMapper:
if (agent .getUse () != null ) {
AgentDefinition def = caseDefinition .getUse ()
.getAgents ().stream ()
.filter (a -> a .getName ().equals (agent .getUse ()))
.findFirst ()
.orElseThrow (() -> new IllegalArgumentException (
"Agent '" + agent .getUse () + "' not found in use.agents" ));
// Merge: explicit model overrides referenced model
if (agent .getModel () == null ) {
agent .setModel (def .getModel ());
}
}
3. Backward Compatibility
All existing YAML files must continue to work:
Inline agent.model configurations remain valid
New use and reference patterns are optional
Migration path: extract common models to use.agents
Related
Open Questions
Naming: use.agents or use.models? (agents vs LLM configurations)
Versioning: Should agent definitions include version field?
Scoping: Can agents be defined at namespace level and shared across cases?
Lifecycle: Should autonomous agents have explicit start/stop/pause states?
Context
Currently, AI Agents are defined inline within Worker definitions:
Current implementation:
schema/src/main/resources/schema/CaseDefinition.yamlProblem
1. No Reusability
If multiple workers need the same LLM configuration, the entire
agentblock must be duplicated:2. Agents are not first-class participants
According to
docs/Case Hub, design.md:Currently, agents can only exist as part of a worker. There's no way to define an autonomous agent as a standalone participant.
3. No agent registry/catalog
Proposed Solution
Option 1: Reusable Agent Definitions (Minimal)
Define agents in
use.agentsand reference them by name:Schema changes:
Option 2: First-class Agents (Full)
Agents as top-level participants alongside Workers:
Schema changes:
Option 3: Hybrid (Recommended)
Combine both approaches:
use.agentsfor reusable model configurationsspec.agentsfor autonomous agent participantsspec.workers[].agentfor inline agent configs (backward compatible)Implementation Plan
Phase 1: Reusable Agent Definitions
use.agents[]to schemaAgentto supportusefield (reference by name)Phase 2: First-class Agents
spec.agents[]to schemaAgentWorkertypePhase 3: Advanced Features
Acceptance Criteria
Phase 1 (Minimal):
use.agentsagent.use: "name"agent.modelstill worksuse.agentsPhase 2 (Full):
spec.agents[]supported in schemaDesign Considerations
1. Agent vs Worker
When to use
spec.agentsvsspec.workers[].agent?spec.agentsspec.workers[].agentuse.agents2. Reference Resolution
3. Backward Compatibility
All existing YAML files must continue to work:
agent.modelconfigurations remain validuseand reference patterns are optionaluse.agentsRelated
docs/Case Hub, design.md(agents as participants)Open Questions
use.agentsoruse.models? (agents vs LLM configurations)