language-operator 0.1.70 → 0.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/components/agent/Gemfile +1 -1
- data/docs/persona-driven-system-prompts.md +346 -0
- data/examples/basic_agent_with_default_chat.rb +99 -0
- data/examples/chat_endpoint_agent.rb +7 -19
- data/examples/identity_aware_chat_agent.rb +83 -0
- data/examples/ux_helpers_demo.rb +0 -0
- data/lib/language_operator/agent/metadata_collector.rb +222 -0
- data/lib/language_operator/agent/prompt_builder.rb +282 -0
- data/lib/language_operator/agent/web_server.rb +83 -20
- data/lib/language_operator/dsl/agent_definition.rb +3 -53
- data/lib/language_operator/dsl/chat_endpoint_definition.rb +112 -2
- data/lib/language_operator/templates/schema/agent_dsl_openapi.yaml +1 -1
- data/lib/language_operator/templates/schema/agent_dsl_schema.json +1 -1
- data/lib/language_operator/version.rb +1 -1
- data/synth/003/Makefile +6 -0
- metadata +6 -1
|
@@ -4,7 +4,6 @@ require_relative 'main_definition'
|
|
|
4
4
|
require_relative 'task_definition'
|
|
5
5
|
require_relative 'webhook_definition'
|
|
6
6
|
require_relative 'mcp_server_definition'
|
|
7
|
-
require_relative 'chat_endpoint_definition'
|
|
8
7
|
require_relative '../logger'
|
|
9
8
|
require_relative '../loggable'
|
|
10
9
|
|
|
@@ -64,7 +63,6 @@ module LanguageOperator
|
|
|
64
63
|
@execution_mode = :autonomous
|
|
65
64
|
@webhooks = []
|
|
66
65
|
@mcp_server = nil
|
|
67
|
-
@chat_endpoint = nil
|
|
68
66
|
|
|
69
67
|
logger.debug('Agent definition initialized',
|
|
70
68
|
name: name,
|
|
@@ -314,29 +312,6 @@ module LanguageOperator
|
|
|
314
312
|
@mcp_server
|
|
315
313
|
end
|
|
316
314
|
|
|
317
|
-
# Get chat endpoint definition (always available)
|
|
318
|
-
#
|
|
319
|
-
# Returns the chat endpoint definition. If none was explicitly configured,
|
|
320
|
-
# returns a default chat endpoint with basic configuration.
|
|
321
|
-
#
|
|
322
|
-
# @return [ChatEndpointDefinition] The chat endpoint definition
|
|
323
|
-
def chat_endpoint
|
|
324
|
-
@chat_endpoint ||= create_default_chat_endpoint
|
|
325
|
-
end
|
|
326
|
-
|
|
327
|
-
# Define chat endpoint capabilities
|
|
328
|
-
#
|
|
329
|
-
# Allows this agent to respond to OpenAI-compatible chat completion requests.
|
|
330
|
-
# Other systems can treat this agent as a language model.
|
|
331
|
-
#
|
|
332
|
-
# @yield Chat endpoint configuration block
|
|
333
|
-
# @return [ChatEndpointDefinition] The chat endpoint definition
|
|
334
|
-
def as_chat_endpoint(&block)
|
|
335
|
-
@chat_endpoint ||= ChatEndpointDefinition.new(@name)
|
|
336
|
-
@chat_endpoint.instance_eval(&block) if block
|
|
337
|
-
# Note: Don't force mode change - agents can be autonomous AND have chat endpoints
|
|
338
|
-
@chat_endpoint
|
|
339
|
-
end
|
|
340
315
|
|
|
341
316
|
# Execute the agent
|
|
342
317
|
#
|
|
@@ -363,31 +338,6 @@ module LanguageOperator
|
|
|
363
338
|
|
|
364
339
|
private
|
|
365
340
|
|
|
366
|
-
# Create default chat endpoint configuration
|
|
367
|
-
#
|
|
368
|
-
# @return [ChatEndpointDefinition] Default chat endpoint
|
|
369
|
-
def create_default_chat_endpoint
|
|
370
|
-
endpoint = ChatEndpointDefinition.new(@name)
|
|
371
|
-
|
|
372
|
-
# Set default system prompt based on agent description
|
|
373
|
-
default_prompt = if @description
|
|
374
|
-
"You are #{@description.downcase}. Provide helpful assistance based on your capabilities."
|
|
375
|
-
else
|
|
376
|
-
"You are an AI agent named #{@name}. Provide helpful assistance to users."
|
|
377
|
-
end
|
|
378
|
-
|
|
379
|
-
endpoint.system_prompt(default_prompt)
|
|
380
|
-
endpoint.model(@name) # Use agent name as model name
|
|
381
|
-
endpoint.temperature(0.7) # Balanced default
|
|
382
|
-
endpoint.max_tokens(2000) # Reasonable default
|
|
383
|
-
|
|
384
|
-
logger.debug('Created default chat endpoint',
|
|
385
|
-
agent_name: @name,
|
|
386
|
-
model_name: @name,
|
|
387
|
-
system_prompt: default_prompt[0..100])
|
|
388
|
-
|
|
389
|
-
endpoint
|
|
390
|
-
end
|
|
391
341
|
|
|
392
342
|
def logger_component
|
|
393
343
|
"Agent:#{@name}"
|
|
@@ -403,7 +353,7 @@ module LanguageOperator
|
|
|
403
353
|
name: @name,
|
|
404
354
|
webhooks: @webhooks.size,
|
|
405
355
|
mcp_tools: @mcp_server&.tools&.size || 0,
|
|
406
|
-
chat_endpoint:
|
|
356
|
+
chat_endpoint: true)
|
|
407
357
|
|
|
408
358
|
# Create an Agent::Base instance with this definition
|
|
409
359
|
require_relative '../agent/base'
|
|
@@ -427,8 +377,8 @@ module LanguageOperator
|
|
|
427
377
|
# Register MCP tools
|
|
428
378
|
web_server.register_mcp_tools(@mcp_server) if @mcp_server&.tools?
|
|
429
379
|
|
|
430
|
-
# Register chat endpoint
|
|
431
|
-
web_server.register_chat_endpoint(
|
|
380
|
+
# Register chat endpoint - automatic for all agents
|
|
381
|
+
web_server.register_chat_endpoint(agent)
|
|
432
382
|
|
|
433
383
|
# Start the server
|
|
434
384
|
web_server.start
|
|
@@ -3,11 +3,15 @@
|
|
|
3
3
|
module LanguageOperator
|
|
4
4
|
module Dsl
|
|
5
5
|
# Chat endpoint definition for agents
|
|
6
|
+
#
|
|
7
|
+
# DEPRECATED: This class is deprecated. All agents now automatically get
|
|
8
|
+
# identity-aware chat endpoints without configuration. The `as_chat_endpoint`
|
|
9
|
+
# DSL method is no longer needed.
|
|
6
10
|
#
|
|
7
11
|
# Allows agents to expose an OpenAI-compatible chat completion endpoint.
|
|
8
12
|
# Other systems can treat the agent as a language model.
|
|
9
13
|
#
|
|
10
|
-
# @example Define chat endpoint
|
|
14
|
+
# @example Define basic chat endpoint
|
|
11
15
|
# agent "github-expert" do
|
|
12
16
|
# as_chat_endpoint do
|
|
13
17
|
# system_prompt "You are a GitHub API expert"
|
|
@@ -15,9 +19,26 @@ module LanguageOperator
|
|
|
15
19
|
# max_tokens 2000
|
|
16
20
|
# end
|
|
17
21
|
# end
|
|
22
|
+
#
|
|
23
|
+
# @example Define chat endpoint with identity awareness
|
|
24
|
+
# agent "support-bot" do
|
|
25
|
+
# as_chat_endpoint do
|
|
26
|
+
# system_prompt "You are a helpful customer support assistant"
|
|
27
|
+
#
|
|
28
|
+
# # Configure identity awareness and context injection
|
|
29
|
+
# identity_awareness do
|
|
30
|
+
# enabled true
|
|
31
|
+
# prompt_template :detailed
|
|
32
|
+
# context_injection :standard
|
|
33
|
+
# end
|
|
34
|
+
#
|
|
35
|
+
# temperature 0.8
|
|
36
|
+
# end
|
|
37
|
+
# end
|
|
18
38
|
class ChatEndpointDefinition
|
|
19
39
|
attr_reader :system_prompt, :temperature, :max_tokens, :model_name,
|
|
20
|
-
:top_p, :frequency_penalty, :presence_penalty, :stop_sequences
|
|
40
|
+
:top_p, :frequency_penalty, :presence_penalty, :stop_sequences,
|
|
41
|
+
:identity_awareness_enabled, :prompt_template_level, :context_injection_level
|
|
21
42
|
|
|
22
43
|
def initialize(agent_name)
|
|
23
44
|
@agent_name = agent_name
|
|
@@ -29,6 +50,11 @@ module LanguageOperator
|
|
|
29
50
|
@frequency_penalty = 0.0
|
|
30
51
|
@presence_penalty = 0.0
|
|
31
52
|
@stop_sequences = nil
|
|
53
|
+
|
|
54
|
+
# Identity awareness and context injection settings
|
|
55
|
+
@identity_awareness_enabled = true
|
|
56
|
+
@prompt_template_level = :standard
|
|
57
|
+
@context_injection_level = :standard
|
|
32
58
|
end
|
|
33
59
|
|
|
34
60
|
# Set system prompt for chat mode
|
|
@@ -110,6 +136,90 @@ module LanguageOperator
|
|
|
110
136
|
|
|
111
137
|
@stop_sequences = sequences
|
|
112
138
|
end
|
|
139
|
+
|
|
140
|
+
# Enable or disable identity awareness and context injection
|
|
141
|
+
#
|
|
142
|
+
# When enabled, the system prompt will be dynamically enhanced with
|
|
143
|
+
# agent identity, operational context, and environment information.
|
|
144
|
+
#
|
|
145
|
+
# @param enabled [Boolean] Whether to enable identity awareness
|
|
146
|
+
# @return [Boolean] Current setting
|
|
147
|
+
def enable_identity_awareness(enabled = nil)
|
|
148
|
+
return @identity_awareness_enabled if enabled.nil?
|
|
149
|
+
|
|
150
|
+
@identity_awareness_enabled = enabled
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Set the prompt template level for context injection
|
|
154
|
+
#
|
|
155
|
+
# Available levels:
|
|
156
|
+
# - :minimal - Basic agent identity only
|
|
157
|
+
# - :standard - Identity + basic operational context (default)
|
|
158
|
+
# - :detailed - Full context with capabilities
|
|
159
|
+
# - :comprehensive - All available context and guidelines
|
|
160
|
+
#
|
|
161
|
+
# @param level [Symbol] Template level
|
|
162
|
+
# @return [Symbol] Current template level
|
|
163
|
+
def prompt_template(level = nil)
|
|
164
|
+
return @prompt_template_level if level.nil?
|
|
165
|
+
|
|
166
|
+
valid_levels = [:minimal, :standard, :detailed, :comprehensive]
|
|
167
|
+
unless valid_levels.include?(level)
|
|
168
|
+
raise ArgumentError, "Invalid template level: #{level}. Must be one of: #{valid_levels.join(', ')}"
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
@prompt_template_level = level
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Set the context injection level for conversations
|
|
175
|
+
#
|
|
176
|
+
# Controls how much operational context is injected into ongoing conversations.
|
|
177
|
+
#
|
|
178
|
+
# Available levels:
|
|
179
|
+
# - :none - No context injection
|
|
180
|
+
# - :minimal - Basic status only
|
|
181
|
+
# - :standard - Standard operational context (default)
|
|
182
|
+
# - :detailed - Full context with metrics
|
|
183
|
+
#
|
|
184
|
+
# @param level [Symbol] Context injection level
|
|
185
|
+
# @return [Symbol] Current context injection level
|
|
186
|
+
def context_injection(level = nil)
|
|
187
|
+
return @context_injection_level if level.nil?
|
|
188
|
+
|
|
189
|
+
valid_levels = [:none, :minimal, :standard, :detailed]
|
|
190
|
+
unless valid_levels.include?(level)
|
|
191
|
+
raise ArgumentError, "Invalid context level: #{level}. Must be one of: #{valid_levels.join(', ')}"
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
@context_injection_level = level
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Configure identity awareness with options block
|
|
198
|
+
#
|
|
199
|
+
# @example
|
|
200
|
+
# identity_awareness do
|
|
201
|
+
# enabled true
|
|
202
|
+
# prompt_template :detailed
|
|
203
|
+
# context_injection :standard
|
|
204
|
+
# end
|
|
205
|
+
#
|
|
206
|
+
# @yield Block for configuring identity awareness options
|
|
207
|
+
def identity_awareness(&block)
|
|
208
|
+
if block_given?
|
|
209
|
+
instance_eval(&block)
|
|
210
|
+
else
|
|
211
|
+
{
|
|
212
|
+
enabled: @identity_awareness_enabled,
|
|
213
|
+
prompt_template: @prompt_template_level,
|
|
214
|
+
context_injection: @context_injection_level
|
|
215
|
+
}
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Alias methods for convenience
|
|
220
|
+
alias_method :enabled, :enable_identity_awareness
|
|
221
|
+
alias_method :template, :prompt_template
|
|
222
|
+
alias_method :context, :context_injection
|
|
113
223
|
end
|
|
114
224
|
end
|
|
115
225
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"$id": "https://github.com/language-operator/language-operator-gem/schema/agent-dsl.json",
|
|
4
4
|
"title": "Language Operator Agent DSL",
|
|
5
5
|
"description": "Schema for defining autonomous AI agents using the Language Operator DSL",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.71",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
9
|
"name": {
|
data/synth/003/Makefile
CHANGED
|
@@ -27,11 +27,17 @@ inspect:
|
|
|
27
27
|
learning-status:
|
|
28
28
|
$(AICTL) learning status $(AGENT)
|
|
29
29
|
|
|
30
|
+
learn:
|
|
31
|
+
kubectl patch languageagent $(AGENT) --type='merge' -p='{"status":{"runsPendingLearning":10}}'
|
|
32
|
+
|
|
33
|
+
|
|
30
34
|
logs:
|
|
31
35
|
$(AICTL) logs $(AGENT)
|
|
32
36
|
|
|
33
37
|
clean:
|
|
34
38
|
$(AICTL) delete $(AGENT) --force
|
|
39
|
+
kubectl delete configmaps -l app.kubernetes.io/name=$(AGENT) --ignore-not-found=true
|
|
40
|
+
kubectl delete configmaps --field-selector metadata.name~=$(AGENT)-v --ignore-not-found=true
|
|
35
41
|
|
|
36
42
|
save:
|
|
37
43
|
$(AICTL) code $(AGENT) --raw > agent.rb
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: language-operator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.71
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Ryan
|
|
@@ -517,13 +517,16 @@ files:
|
|
|
517
517
|
- docs/how-agents-work.md
|
|
518
518
|
- docs/installation.md
|
|
519
519
|
- docs/observability.md
|
|
520
|
+
- docs/persona-driven-system-prompts.md
|
|
520
521
|
- docs/quickstart.md
|
|
521
522
|
- docs/schema-versioning.md
|
|
522
523
|
- docs/understanding-generated-code.md
|
|
523
524
|
- docs/using-tools.md
|
|
524
525
|
- docs/webhooks.md
|
|
526
|
+
- examples/basic_agent_with_default_chat.rb
|
|
525
527
|
- examples/chat_endpoint_agent.rb
|
|
526
528
|
- examples/hybrid_agent.rb
|
|
529
|
+
- examples/identity_aware_chat_agent.rb
|
|
527
530
|
- examples/pure_agent_test.rb
|
|
528
531
|
- examples/ux_helpers_demo.rb
|
|
529
532
|
- lib/language_operator.rb
|
|
@@ -532,7 +535,9 @@ files:
|
|
|
532
535
|
- lib/language_operator/agent/event_config.rb
|
|
533
536
|
- lib/language_operator/agent/executor.rb
|
|
534
537
|
- lib/language_operator/agent/instrumentation.rb
|
|
538
|
+
- lib/language_operator/agent/metadata_collector.rb
|
|
535
539
|
- lib/language_operator/agent/metrics_tracker.rb
|
|
540
|
+
- lib/language_operator/agent/prompt_builder.rb
|
|
536
541
|
- lib/language_operator/agent/safety/ast_validator.rb
|
|
537
542
|
- lib/language_operator/agent/safety/audit_logger.rb
|
|
538
543
|
- lib/language_operator/agent/safety/budget_tracker.rb
|