language-operator 0.1.67 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 189b6f8a2bcc795cbc29f0830bf31d6ce51e483ec2e6bb2fc42d43d79292db87
4
- data.tar.gz: 0eb8429834de65902c51157eb2bfcf2eb8bc0d79937c8567110b2b60700a69e0
3
+ metadata.gz: 11da2ddaf7396a49d94451edc45cd07a05b8ac2d9239b587f46cf7b5a938714f
4
+ data.tar.gz: 998d0061d7a4a7fee8a61de4b034766bceb4421363cf177b4e6e38ada37c04b0
5
5
  SHA512:
6
- metadata.gz: 0e7a055a00b4b5cd37c3a157f396b1d91daa863b0ce7857f12339f6d6ac30dd9bfff419abc8076d1434dd8ff736e68bef7302ce46f41f401be5d9c3ddc0b9bbe
7
- data.tar.gz: 538c6d8df05f4a665b6a6bebaef5bd94933edf3c91eaf73c01739eaa0ba05fb9336b2659741250cdc9f2c4d75d554addf708d081fb8049a40679979eda67565c
6
+ metadata.gz: 44f424c8f7ff4a5d147f86027a7e68e4bfacbda5ed3a0747793c35e5967d58e339b001dc421eb3826c6d1cd359343fc74ea9de96cc0e1d5eeefd45d101ca3d1e
7
+ data.tar.gz: b74bcaf2d2762cccb6c282041b3cd40d6c1ffd6635dfc1920855f68ffbf9bbe8c46e5e8bb052e77d4807d0ba2c28eaf92b516649be4891cd64ca1a04ceaf476f
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- language-operator (0.1.67)
4
+ language-operator (0.1.71)
5
5
  faraday (~> 2.0)
6
+ json-schema (~> 5.0)
6
7
  k8s-ruby (~> 0.17)
7
8
  lru_redux (~> 1.1)
8
9
  mcp (~> 0.4)
@@ -27,14 +28,14 @@ PATH
27
28
  GEM
28
29
  remote: https://rubygems.org/
29
30
  specs:
30
- addressable (2.8.7)
31
- public_suffix (>= 2.0.2, < 7.0)
31
+ addressable (2.8.8)
32
+ public_suffix (>= 2.0.2, < 8.0)
32
33
  ast (2.4.3)
33
34
  base64 (0.3.0)
34
35
  benchmark (0.5.0)
35
36
  bigdecimal (3.3.1)
36
37
  coderay (1.1.3)
37
- concurrent-ruby (1.3.5)
38
+ concurrent-ruby (1.3.6)
38
39
  crack (1.0.1)
39
40
  bigdecimal
40
41
  rexml
@@ -72,24 +73,24 @@ GEM
72
73
  logger
73
74
  faraday-multipart (1.1.1)
74
75
  multipart-post (~> 2.0)
75
- faraday-net_http (3.4.1)
76
- net-http (>= 0.5.0)
76
+ faraday-net_http (3.4.2)
77
+ net-http (~> 0.5)
77
78
  faraday-retry (2.3.2)
78
79
  faraday (~> 2.0)
79
- google-protobuf (4.33.0)
80
+ google-protobuf (4.33.2)
80
81
  bigdecimal
81
82
  rake (>= 13)
82
- google-protobuf (4.33.0-x86_64-linux-gnu)
83
+ google-protobuf (4.33.2-x86_64-linux-gnu)
83
84
  bigdecimal
84
85
  rake (>= 13)
85
86
  googleapis-common-protos-types (1.22.0)
86
87
  google-protobuf (~> 4.26)
87
88
  hashdiff (1.2.1)
88
89
  http-2 (1.1.1)
89
- httpx (1.6.3)
90
+ httpx (1.7.0)
90
91
  http-2 (>= 1.0.0)
91
92
  ice_nine (0.11.2)
92
- json (2.15.2)
93
+ json (2.18.0)
93
94
  json-schema (5.2.2)
94
95
  addressable (~> 2.8)
95
96
  bigdecimal (~> 3.1)
@@ -117,10 +118,10 @@ GEM
117
118
  json_rpc_handler (~> 0.1)
118
119
  memory_profiler (1.1.0)
119
120
  method_source (1.1.0)
120
- multi_json (1.17.0)
121
+ multi_json (1.18.0)
121
122
  multipart-post (2.4.1)
122
- net-http (0.7.0)
123
- uri
123
+ net-http (0.9.1)
124
+ uri (>= 0.11.1)
124
125
  nio4r (2.7.5)
125
126
  opentelemetry-api (1.7.0)
126
127
  opentelemetry-common (0.23.0)
@@ -136,7 +137,7 @@ GEM
136
137
  opentelemetry-api (~> 1.7)
137
138
  opentelemetry-common (~> 0.21)
138
139
  opentelemetry-registry (~> 0.1)
139
- opentelemetry-instrumentation-http (0.27.0)
140
+ opentelemetry-instrumentation-http (0.27.1)
140
141
  opentelemetry-instrumentation-base (~> 0.25)
141
142
  opentelemetry-instrumentation-rack (0.29.0)
142
143
  opentelemetry-instrumentation-base (~> 0.25)
@@ -158,18 +159,18 @@ GEM
158
159
  racc
159
160
  pastel (0.8.0)
160
161
  tty-color (~> 0.5)
161
- prism (1.6.0)
162
+ prism (1.7.0)
162
163
  pry (0.15.2)
163
164
  coderay (~> 1.1)
164
165
  method_source (~> 1.0)
165
- public_suffix (6.0.2)
166
+ public_suffix (7.0.0)
166
167
  puma (6.6.1)
167
168
  nio4r (~> 2.0)
168
169
  racc (1.8.1)
169
170
  rack (3.2.4)
170
171
  rack-test (2.2.0)
171
172
  rack (>= 1.3)
172
- rackup (2.2.1)
173
+ rackup (2.3.1)
173
174
  rack (>= 3)
174
175
  rainbow (3.1.1)
175
176
  rake (13.3.1)
@@ -191,7 +192,7 @@ GEM
191
192
  diff-lcs (>= 1.2.0, < 2.0)
192
193
  rspec-support (~> 3.13.0)
193
194
  rspec-support (3.13.6)
194
- rubocop (1.81.7)
195
+ rubocop (1.82.1)
195
196
  json (~> 2.3)
196
197
  language_server-protocol (~> 3.17.0.2)
197
198
  lint_roller (~> 1.1.0)
@@ -199,10 +200,10 @@ GEM
199
200
  parser (>= 3.3.0.2)
200
201
  rainbow (>= 2.2.2, < 4.0)
201
202
  regexp_parser (>= 2.9.3, < 3.0)
202
- rubocop-ast (>= 1.47.1, < 2.0)
203
+ rubocop-ast (>= 1.48.0, < 2.0)
203
204
  ruby-progressbar (~> 1.7)
204
205
  unicode-display_width (>= 2.4.0, < 4.0)
205
- rubocop-ast (1.47.1)
206
+ rubocop-ast (1.48.0)
206
207
  parser (>= 3.3.7.2)
207
208
  prism (~> 1.4)
208
209
  rubocop-performance (1.26.1)
@@ -220,12 +221,12 @@ GEM
220
221
  marcel (~> 1.0)
221
222
  ruby_llm-schema (~> 0.2.1)
222
223
  zeitwerk (~> 2)
223
- ruby_llm-mcp (0.7.0)
224
+ ruby_llm-mcp (0.8.0)
224
225
  httpx (~> 1.4)
225
226
  json-schema (~> 5.0)
226
227
  ruby_llm (~> 1.9)
227
228
  zeitwerk (~> 2)
228
- ruby_llm-schema (0.2.1)
229
+ ruby_llm-schema (0.2.5)
229
230
  strings (0.2.1)
230
231
  strings-ansi (~> 0.2)
231
232
  unicode-display_width (>= 1.5, < 3.0)
@@ -262,8 +263,8 @@ GEM
262
263
  wisper (2.0.1)
263
264
  yajl-ruby (1.4.3)
264
265
  yaml-safe_load_stream3 (0.1.2)
265
- yard (0.9.37)
266
- zeitwerk (2.7.3)
266
+ yard (0.9.38)
267
+ zeitwerk (2.7.4)
267
268
 
268
269
  PLATFORMS
269
270
  ruby
@@ -2,7 +2,7 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'language-operator', '~> 0.1.66'
5
+ gem 'language-operator', '~> 0.1.70'
6
6
 
7
7
  # Agent-specific dependencies for autonomous execution
8
8
  gem 'concurrent-ruby', '~> 1.3'
@@ -0,0 +1,346 @@
1
+ # Persona-Driven System Prompts
2
+
3
+ Language Operator v0.1.71+ introduces **persona-driven system prompts** that transform agents from generic chatbots into context-aware entities with deep understanding of their identity, role, environment, and operational state.
4
+
5
+ ## Overview
6
+
7
+ Traditional AI agents respond with generic outputs lacking awareness of their purpose or context. With persona-driven prompts, agents become intelligent entities that:
8
+
9
+ - **Know their identity**: Name, role, and specific purpose
10
+ - **Understand their environment**: Cluster, namespace, operational mode
11
+ - **Track operational state**: Uptime, status, capabilities, tools available
12
+ - **Provide contextual responses**: References to their actual function and situation
13
+
14
+ ## Quick Example
15
+
16
+ **Before (Generic Response):**
17
+ ```
18
+ User: "hello"
19
+ Agent: "Hello! How can I assist you today?"
20
+ ```
21
+
22
+ **After (Identity-Aware Response):**
23
+ ```
24
+ User: "hello"
25
+ Agent: "Hello! I'm say-something, running in the code-games cluster.
26
+ I've been active for 3 hours now, helping log interesting messages
27
+ and interactions. How can I assist you today?"
28
+ ```
29
+
30
+ ## Configuration
31
+
32
+ ### Basic Usage
33
+
34
+ Enable identity awareness in your chat endpoint:
35
+
36
+ ```ruby
37
+ agent "support-bot" do
38
+ description "Customer support assistant"
39
+ mode :reactive
40
+
41
+ as_chat_endpoint do
42
+ system_prompt "You are a helpful customer support assistant"
43
+
44
+ # Enable persona-driven prompts
45
+ identity_awareness do
46
+ enabled true
47
+ prompt_template :standard
48
+ context_injection :standard
49
+ end
50
+ end
51
+ end
52
+ ```
53
+
54
+ ### Template Levels
55
+
56
+ Choose how much context to inject into system prompts:
57
+
58
+ #### `:minimal` - Basic Identity Only
59
+ ```ruby
60
+ identity_awareness do
61
+ enabled true
62
+ prompt_template :minimal
63
+ end
64
+ ```
65
+
66
+ **Generated prompt includes:**
67
+ - Agent name and cluster location
68
+ - Basic operational status
69
+
70
+ #### `:standard` - Balanced Context (Default)
71
+ ```ruby
72
+ identity_awareness do
73
+ enabled true
74
+ prompt_template :standard # Default
75
+ end
76
+ ```
77
+
78
+ **Generated prompt includes:**
79
+ - Agent identity (name, role, mode)
80
+ - Basic operational context (uptime, cluster, status)
81
+ - Behavioral guidelines
82
+
83
+ #### `:detailed` - Full Context with Capabilities
84
+ ```ruby
85
+ identity_awareness do
86
+ enabled true
87
+ prompt_template :detailed
88
+ end
89
+ ```
90
+
91
+ **Generated prompt includes:**
92
+ - Complete identity and operational context
93
+ - Available tools and capabilities
94
+ - Workspace status and environment details
95
+ - Detailed behavioral guidelines
96
+
97
+ #### `:comprehensive` - Maximum Context
98
+ ```ruby
99
+ identity_awareness do
100
+ enabled true
101
+ prompt_template :comprehensive
102
+ end
103
+ ```
104
+
105
+ **Generated prompt includes:**
106
+ - All available metadata
107
+ - Environment specifications
108
+ - Complete capability listing
109
+ - Full behavioral framework
110
+
111
+ ### Context Injection Levels
112
+
113
+ Control how much operational context appears in ongoing conversations:
114
+
115
+ ```ruby
116
+ identity_awareness do
117
+ enabled true
118
+ context_injection :standard # Options: :none, :minimal, :standard, :detailed
119
+ end
120
+ ```
121
+
122
+ - **`:none`** - No conversation context injection
123
+ - **`:minimal`** - Basic status only
124
+ - **`:standard`** - Agent name, mode, uptime, status
125
+ - **`:detailed`** - Full operational metrics
126
+
127
+ ## Implementation Details
128
+
129
+ ### Architecture
130
+
131
+ The persona-driven prompt system consists of:
132
+
133
+ 1. **MetadataCollector** - Gathers agent runtime and configuration data
134
+ 2. **PromptBuilder** - Generates dynamic prompts from templates and metadata
135
+ 3. **ChatEndpointDefinition** - Enhanced with identity awareness configuration
136
+ 4. **WebServer** - Integrates dynamic prompts into conversation handling
137
+
138
+ ### Available Metadata
139
+
140
+ Agents can access the following runtime information:
141
+
142
+ ```ruby
143
+ {
144
+ identity: {
145
+ name: "support-bot",
146
+ description: "Customer support assistant",
147
+ persona: "helpful-assistant",
148
+ mode: "reactive",
149
+ version: "0.1.71"
150
+ },
151
+ runtime: {
152
+ uptime: "3h 45m",
153
+ started_at: "2024-01-15T10:30:00Z",
154
+ workspace_available: true,
155
+ mcp_servers_connected: 2
156
+ },
157
+ environment: {
158
+ cluster: "production",
159
+ namespace: "support",
160
+ kubernetes_enabled: true,
161
+ telemetry_enabled: true
162
+ },
163
+ operational: {
164
+ status: "ready",
165
+ ready: true,
166
+ mode: "reactive"
167
+ },
168
+ capabilities: {
169
+ total_tools: 5,
170
+ tools: [
171
+ { server: "github-tools", tool_count: 3 },
172
+ { server: "slack-tools", tool_count: 2 }
173
+ ],
174
+ llm_provider: "anthropic",
175
+ llm_model: "claude-3-haiku"
176
+ }
177
+ }
178
+ ```
179
+
180
+ ## Migration Guide
181
+
182
+ ### Existing Agents
183
+
184
+ Persona-driven prompts are **backward compatible**. Existing agents continue working without changes.
185
+
186
+ To enable for existing agents:
187
+
188
+ ```ruby
189
+ # Before
190
+ as_chat_endpoint do
191
+ system_prompt "You are a GitHub expert"
192
+ temperature 0.7
193
+ end
194
+
195
+ # After - Add identity awareness
196
+ as_chat_endpoint do
197
+ system_prompt "You are a GitHub expert"
198
+
199
+ identity_awareness do
200
+ enabled true # Enable the feature
201
+ prompt_template :standard
202
+ context_injection :standard
203
+ end
204
+
205
+ temperature 0.7
206
+ end
207
+ ```
208
+
209
+ ### Gradual Adoption
210
+
211
+ 1. **Start with `:minimal`** template to test basic identity awareness
212
+ 2. **Upgrade to `:standard`** for balanced context
213
+ 3. **Use `:detailed`** for rich conversational experiences
214
+ 4. **Apply `:comprehensive`** only when maximum context is needed
215
+
216
+ ### Disabling Features
217
+
218
+ ```ruby
219
+ # Disable completely
220
+ identity_awareness do
221
+ enabled false
222
+ end
223
+
224
+ # Disable conversation context only
225
+ identity_awareness do
226
+ enabled true
227
+ prompt_template :standard
228
+ context_injection :none
229
+ end
230
+ ```
231
+
232
+ ## Best Practices
233
+
234
+ ### Template Selection
235
+
236
+ - **Customer-facing agents**: Use `:standard` or `:detailed`
237
+ - **Internal tools**: Use `:detailed` or `:comprehensive`
238
+ - **Simple utilities**: Use `:minimal`
239
+ - **Legacy compatibility**: Use `enabled false`
240
+
241
+ ### Performance Considerations
242
+
243
+ - Metadata collection is lightweight but cached
244
+ - Higher template levels increase token usage
245
+ - Context injection adds minimal overhead
246
+ - Templates are generated once per conversation
247
+
248
+ ### Security
249
+
250
+ - No sensitive information (secrets, keys) included in prompts
251
+ - Environment details are cluster/namespace level only
252
+ - PII detection prevents accidental exposure
253
+
254
+ ## Examples
255
+
256
+ ### Complete Identity-Aware Agent
257
+
258
+ ```ruby
259
+ LanguageOperator::Dsl.define do
260
+ agent "customer-support" do
261
+ description "24/7 customer support specialist for SaaS platform"
262
+ mode :reactive
263
+
264
+ as_chat_endpoint do
265
+ system_prompt <<~PROMPT
266
+ You are a knowledgeable customer support specialist with expertise in:
267
+ - Account management and billing
268
+ - Product features and troubleshooting
269
+ - Technical documentation and guides
270
+
271
+ Provide helpful, accurate, and empathetic support to customers.
272
+ PROMPT
273
+
274
+ identity_awareness do
275
+ enabled true
276
+ prompt_template :detailed
277
+ context_injection :standard
278
+ end
279
+
280
+ model "customer-support-v1"
281
+ temperature 0.7
282
+ max_tokens 2000
283
+ end
284
+
285
+ constraints do
286
+ requests_per_minute 30
287
+ daily_budget 1000
288
+ end
289
+ end
290
+ end
291
+ ```
292
+
293
+ ### Development vs Production Templates
294
+
295
+ ```ruby
296
+ # Development - comprehensive context for debugging
297
+ identity_awareness do
298
+ enabled true
299
+ prompt_template :comprehensive
300
+ context_injection :detailed
301
+ end
302
+
303
+ # Production - balanced context for performance
304
+ identity_awareness do
305
+ enabled true
306
+ prompt_template :standard
307
+ context_injection :standard
308
+ end
309
+ ```
310
+
311
+ ## Troubleshooting
312
+
313
+ ### Common Issues
314
+
315
+ **Agent still gives generic responses:**
316
+ - Verify `enabled true` in identity_awareness block
317
+ - Check agent has proper name and description
318
+ - Ensure cluster environment variables are set
319
+
320
+ **Prompts too long/expensive:**
321
+ - Reduce template level (`:detailed` → `:standard` → `:minimal`)
322
+ - Disable context injection (`:none`)
323
+
324
+ **Missing environment context:**
325
+ - Verify Kubernetes environment variables
326
+ - Check cluster and namespace configuration
327
+ - Ensure agent has proper metadata access
328
+
329
+ ### Debug Information
330
+
331
+ Enable debug logging to see generated prompts:
332
+
333
+ ```bash
334
+ DEBUG=true ruby examples/identity_aware_chat_agent.rb
335
+ ```
336
+
337
+ ## API Reference
338
+
339
+ See the complete API documentation:
340
+ - [`ChatEndpointDefinition`](api/chat-endpoint-definition.md)
341
+ - [`MetadataCollector`](api/metadata-collector.md)
342
+ - [`PromptBuilder`](api/prompt-builder.md)
343
+
344
+ ---
345
+
346
+ **Next Steps:** Try the [identity-aware chat agent example](../examples/identity_aware_chat_agent.rb) to see persona-driven prompts in action.
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Basic Agent with Default Chat Endpoint
5
+ #
6
+ # This example demonstrates that agents automatically expose chat endpoints
7
+ # without explicitly defining them via as_chat_endpoint.
8
+ #
9
+ # This agent:
10
+ # - Runs autonomous work (logging every 10 seconds)
11
+ # - Automatically exposes chat endpoint at /v1/chat/completions
12
+ # - No explicit as_chat_endpoint block needed!
13
+ #
14
+ # Usage:
15
+ # ruby examples/basic_agent_with_default_chat.rb
16
+ #
17
+ # Test default chat endpoint:
18
+ # curl -X POST http://localhost:8080/v1/chat/completions \
19
+ # -H "Content-Type: application/json" \
20
+ # -d '{
21
+ # "model": "basic-worker",
22
+ # "messages": [
23
+ # {"role": "user", "content": "What are you doing right now?"}
24
+ # ]
25
+ # }'
26
+
27
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
28
+
29
+ require 'language_operator'
30
+
31
+ # Define a basic agent - NO explicit chat endpoint!
32
+ agent "basic-worker" do
33
+ description "Simple worker that performs basic tasks"
34
+ mode :autonomous
35
+
36
+ # Simple main loop - this is the autonomous work
37
+ task :do_work,
38
+ instructions: "Perform some basic work and log progress",
39
+ inputs: {},
40
+ outputs: {
41
+ work_done: 'boolean',
42
+ message: 'string',
43
+ timestamp: 'string'
44
+ }
45
+
46
+ main do |inputs|
47
+ puts "🔨 Performing autonomous work..."
48
+
49
+ # Execute the work task
50
+ work_result = execute_task(:do_work)
51
+
52
+ puts "✅ Work completed: #{work_result[:message]}"
53
+ puts "😴 Sleeping for 10 seconds..."
54
+
55
+ sleep 10
56
+
57
+ work_result
58
+ end
59
+
60
+ # Basic constraints
61
+ constraints do
62
+ max_iterations 999999
63
+ timeout '30s'
64
+ end
65
+ end
66
+
67
+ # Start the agent
68
+ if __FILE__ == $PROGRAM_NAME
69
+ puts "🚀 Starting Basic Agent with Default Chat Endpoint"
70
+ puts ""
71
+ puts "This agent demonstrates automatic chat endpoint creation:"
72
+ puts " ✅ Runs autonomous work every 10 seconds"
73
+ puts " ✅ Automatically exposes chat at /v1/chat/completions"
74
+ puts " ✅ No explicit as_chat_endpoint block needed!"
75
+ puts ""
76
+ puts "Agent info:"
77
+ puts " Name: basic-worker"
78
+ puts " Description: Simple worker that performs basic tasks"
79
+ puts " Mode: autonomous"
80
+ puts ""
81
+ puts "Available endpoints (auto-generated):"
82
+ puts " POST /v1/chat/completions - Chat with basic-worker"
83
+ puts " GET /v1/models - Available models"
84
+ puts " GET /health - Health check"
85
+ puts " GET /ready - Readiness check"
86
+ puts ""
87
+ puts "Test command:"
88
+ puts "curl -X POST http://localhost:8080/v1/chat/completions \\"
89
+ puts ' -H "Content-Type: application/json" \\'
90
+ puts ' -d \'{"model": "basic-worker", "messages": [{"role": "user", "content": "What are you doing?"}]}\''
91
+ puts ""
92
+ puts "Expected system prompt (auto-generated):"
93
+ puts '"You are simple worker that performs basic tasks. Provide helpful assistance based on your capabilities."'
94
+ puts ""
95
+ puts "Press Ctrl+C to stop"
96
+ puts "=" * 80
97
+
98
+ LanguageOperator::Agent.run
99
+ end
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Chat Endpoint Agent Example
5
+ #
6
+ # This example demonstrates how to create an agent that exposes
7
+ # an OpenAI-compatible chat completion endpoint.
8
+ #
9
+ # Usage:
10
+ # ruby examples/chat_endpoint_agent.rb
11
+ #
12
+ # Then test with curl:
13
+ # curl -X POST http://localhost:8080/v1/chat/completions \
14
+ # -H "Content-Type: application/json" \
15
+ # -d '{
16
+ # "model": "github-expert-v1",
17
+ # "messages": [
18
+ # {"role": "user", "content": "How do I create a pull request?"}
19
+ # ]
20
+ # }'
21
+
22
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
23
+
24
+ require 'language_operator'
25
+
26
+ # Define an agent with chat endpoint capabilities
27
+ LanguageOperator::Dsl.define do
28
+ agent "github-expert" do
29
+ description "You are a GitHub expert assistant with deep knowledge of GitHub API, workflows, pull requests, issues, code review, GitHub Actions, CI/CD, and repository management best practices"
30
+ mode :reactive
31
+
32
+ # Chat endpoint is automatic! No configuration needed.
33
+ # Every agent automatically gets:
34
+ # - OpenAI-compatible chat endpoint at /v1/chat/completions
35
+ # - Identity-aware responses with agent context
36
+ # - Operational state awareness (uptime, cluster, etc.)
37
+ # - Professional, contextual conversation style
38
+
39
+ # Optional: Add constraints for safety and cost management
40
+ constraints do
41
+ timeout '30s'
42
+ requests_per_minute 30
43
+ daily_budget 1000 # $10/day
44
+ end
45
+ end
46
+ end
47
+
48
+ # Start the agent
49
+ if __FILE__ == $PROGRAM_NAME
50
+ puts "Starting GitHub Expert Chat Endpoint Agent..."
51
+ puts "Server will be available at http://localhost:8080"
52
+ puts ""
53
+ puts "Endpoints available:"
54
+ puts " POST /v1/chat/completions - Chat completion (OpenAI-compatible)"
55
+ puts " GET /v1/models - List available models"
56
+ puts " GET /health - Health check"
57
+ puts " GET /ready - Readiness check"
58
+ puts ""
59
+ puts "Test with curl:"
60
+ puts ' curl -X POST http://localhost:8080/v1/chat/completions \\'
61
+ puts ' -H "Content-Type: application/json" \\'
62
+ puts ' -d \'{"model": "github-expert-v1", "messages": [{"role": "user", "content": "How do I create a pull request?"}]}\''
63
+ puts ""
64
+
65
+ LanguageOperator::Agent.run
66
+ end