language-operator 0.1.61 → 0.1.62
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/.claude/commands/persona.md +9 -0
- data/.claude/commands/task.md +46 -1
- data/.rubocop.yml +13 -0
- data/.rubocop_custom/use_ux_helper.rb +44 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +12 -1
- data/Makefile +26 -7
- data/Makefile.common +50 -0
- data/bin/aictl +8 -1
- data/components/agent/Gemfile +1 -1
- data/components/agent/bin/langop-agent +7 -0
- data/docs/README.md +58 -0
- data/docs/{dsl/best-practices.md → best-practices.md} +4 -4
- data/docs/cli-reference.md +274 -0
- data/docs/{dsl/constraints.md → constraints.md} +5 -5
- data/docs/how-agents-work.md +156 -0
- data/docs/installation.md +218 -0
- data/docs/quickstart.md +299 -0
- data/docs/understanding-generated-code.md +265 -0
- data/docs/using-tools.md +457 -0
- data/docs/webhooks.md +509 -0
- data/examples/ux_helpers_demo.rb +296 -0
- data/lib/language_operator/agent/base.rb +11 -1
- data/lib/language_operator/agent/executor.rb +23 -6
- data/lib/language_operator/agent/safety/safe_executor.rb +41 -39
- data/lib/language_operator/agent/task_executor.rb +346 -63
- data/lib/language_operator/agent/web_server.rb +110 -14
- data/lib/language_operator/agent/webhook_authenticator.rb +39 -5
- data/lib/language_operator/agent.rb +88 -2
- data/lib/language_operator/cli/base_command.rb +17 -11
- data/lib/language_operator/cli/command_loader.rb +72 -0
- data/lib/language_operator/cli/commands/agent/base.rb +837 -0
- data/lib/language_operator/cli/commands/agent/code_operations.rb +102 -0
- data/lib/language_operator/cli/commands/agent/helpers/cluster_llm_client.rb +116 -0
- data/lib/language_operator/cli/commands/agent/helpers/code_parser.rb +115 -0
- data/lib/language_operator/cli/commands/agent/helpers/synthesis_watcher.rb +96 -0
- data/lib/language_operator/cli/commands/agent/learning.rb +289 -0
- data/lib/language_operator/cli/commands/agent/lifecycle.rb +102 -0
- data/lib/language_operator/cli/commands/agent/logs.rb +125 -0
- data/lib/language_operator/cli/commands/agent/workspace.rb +327 -0
- data/lib/language_operator/cli/commands/cluster.rb +129 -84
- data/lib/language_operator/cli/commands/install.rb +1 -1
- data/lib/language_operator/cli/commands/model/base.rb +215 -0
- data/lib/language_operator/cli/commands/model/test.rb +165 -0
- data/lib/language_operator/cli/commands/persona.rb +16 -34
- data/lib/language_operator/cli/commands/quickstart.rb +3 -2
- data/lib/language_operator/cli/commands/status.rb +40 -67
- data/lib/language_operator/cli/commands/system/base.rb +44 -0
- data/lib/language_operator/cli/commands/system/exec.rb +147 -0
- data/lib/language_operator/cli/commands/system/helpers/llm_synthesis.rb +183 -0
- data/lib/language_operator/cli/commands/system/helpers/pod_manager.rb +212 -0
- data/lib/language_operator/cli/commands/system/helpers/template_loader.rb +57 -0
- data/lib/language_operator/cli/commands/system/helpers/template_validator.rb +174 -0
- data/lib/language_operator/cli/commands/system/schema.rb +92 -0
- data/lib/language_operator/cli/commands/system/synthesis_template.rb +151 -0
- data/lib/language_operator/cli/commands/system/synthesize.rb +224 -0
- data/lib/language_operator/cli/commands/system/validate_template.rb +130 -0
- data/lib/language_operator/cli/commands/tool/base.rb +271 -0
- data/lib/language_operator/cli/commands/tool/install.rb +255 -0
- data/lib/language_operator/cli/commands/tool/search.rb +69 -0
- data/lib/language_operator/cli/commands/tool/test.rb +115 -0
- data/lib/language_operator/cli/commands/use.rb +29 -6
- data/lib/language_operator/cli/errors/handler.rb +20 -17
- data/lib/language_operator/cli/errors/suggestions.rb +3 -5
- data/lib/language_operator/cli/errors/thor_errors.rb +55 -0
- data/lib/language_operator/cli/formatters/code_formatter.rb +4 -11
- data/lib/language_operator/cli/formatters/log_formatter.rb +8 -15
- data/lib/language_operator/cli/formatters/progress_formatter.rb +6 -8
- data/lib/language_operator/cli/formatters/status_formatter.rb +26 -7
- data/lib/language_operator/cli/formatters/table_formatter.rb +47 -36
- data/lib/language_operator/cli/formatters/value_formatter.rb +75 -0
- data/lib/language_operator/cli/helpers/cluster_context.rb +5 -3
- data/lib/language_operator/cli/helpers/kubeconfig_validator.rb +2 -1
- data/lib/language_operator/cli/helpers/label_utils.rb +97 -0
- data/lib/language_operator/{ux/concerns/provider_helpers.rb → cli/helpers/provider_helper.rb} +10 -29
- data/lib/language_operator/cli/helpers/schedule_builder.rb +21 -1
- data/lib/language_operator/cli/helpers/user_prompts.rb +19 -11
- data/lib/language_operator/cli/helpers/ux_helper.rb +538 -0
- data/lib/language_operator/{ux/concerns/input_validation.rb → cli/helpers/validation_helper.rb} +13 -66
- data/lib/language_operator/cli/main.rb +50 -40
- data/lib/language_operator/cli/templates/tools/generic.yaml +3 -0
- data/lib/language_operator/cli/wizards/agent_wizard.rb +12 -20
- data/lib/language_operator/cli/wizards/model_wizard.rb +271 -0
- data/lib/language_operator/cli/wizards/quickstart_wizard.rb +8 -34
- data/lib/language_operator/client/base.rb +28 -0
- data/lib/language_operator/client/config.rb +4 -1
- data/lib/language_operator/client/mcp_connector.rb +1 -1
- data/lib/language_operator/config/cluster_config.rb +3 -2
- data/lib/language_operator/config.rb +38 -11
- data/lib/language_operator/constants/kubernetes_labels.rb +80 -0
- data/lib/language_operator/constants.rb +13 -0
- data/lib/language_operator/dsl/http.rb +127 -10
- data/lib/language_operator/dsl.rb +153 -6
- data/lib/language_operator/errors.rb +50 -0
- data/lib/language_operator/kubernetes/client.rb +11 -6
- data/lib/language_operator/kubernetes/resource_builder.rb +58 -84
- 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/type_coercion.rb +118 -34
- data/lib/language_operator/utils/secure_path.rb +74 -0
- data/lib/language_operator/utils.rb +7 -0
- data/lib/language_operator/validators.rb +54 -2
- data/lib/language_operator/version.rb +1 -1
- data/synth/001/Makefile +10 -2
- data/synth/001/agent.rb +16 -15
- data/synth/001/output.log +27 -10
- data/synth/002/Makefile +10 -2
- data/synth/003/Makefile +1 -1
- data/synth/003/README.md +205 -133
- data/synth/003/agent.optimized.rb +66 -0
- data/synth/003/agent.synthesized.rb +41 -0
- metadata +111 -35
- data/docs/dsl/agent-reference.md +0 -604
- data/docs/dsl/mcp-integration.md +0 -1177
- data/docs/dsl/webhooks.md +0 -932
- data/docs/dsl/workflows.md +0 -744
- data/lib/language_operator/cli/commands/agent.rb +0 -1712
- data/lib/language_operator/cli/commands/model.rb +0 -366
- data/lib/language_operator/cli/commands/system.rb +0 -1259
- data/lib/language_operator/cli/commands/tool.rb +0 -654
- data/lib/language_operator/cli/formatters/optimization_formatter.rb +0 -226
- data/lib/language_operator/cli/helpers/pastel_helper.rb +0 -24
- data/lib/language_operator/learning/adapters/base_adapter.rb +0 -149
- data/lib/language_operator/learning/adapters/jaeger_adapter.rb +0 -221
- data/lib/language_operator/learning/adapters/signoz_adapter.rb +0 -435
- data/lib/language_operator/learning/adapters/tempo_adapter.rb +0 -239
- data/lib/language_operator/learning/optimizer.rb +0 -319
- data/lib/language_operator/learning/pattern_detector.rb +0 -260
- data/lib/language_operator/learning/task_synthesizer.rb +0 -288
- data/lib/language_operator/learning/trace_analyzer.rb +0 -285
- data/lib/language_operator/templates/task_synthesis.tmpl +0 -98
- data/lib/language_operator/ux/base.rb +0 -81
- data/lib/language_operator/ux/concerns/README.md +0 -155
- data/lib/language_operator/ux/concerns/headings.rb +0 -90
- data/lib/language_operator/ux/create_agent.rb +0 -255
- data/lib/language_operator/ux/create_model.rb +0 -267
- data/lib/language_operator/ux/quickstart.rb +0 -594
- data/synth/003/agent.rb +0 -41
- data/synth/003/output.log +0 -68
- /data/docs/{architecture/agent-runtime.md → agent-internals.md} +0 -0
- /data/docs/{dsl/chat-endpoints.md → chat-endpoints.md} +0 -0
- /data/docs/{dsl/SCHEMA_VERSION.md → schema-versioning.md} +0 -0
data/docs/using-tools.md
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
# Using Tools
|
|
2
|
+
|
|
3
|
+
Language Operator agents interact with external services through the Model Context Protocol (MCP). This guide shows how to configure and use tools in your agent definitions.
|
|
4
|
+
|
|
5
|
+
## How Tools Work
|
|
6
|
+
|
|
7
|
+
Tools in Language Operator are provided by MCP servers that expose specific capabilities to agents. When you define an agent that needs external access, you specify which MCP tools are available.
|
|
8
|
+
|
|
9
|
+
### Tool Examples
|
|
10
|
+
|
|
11
|
+
Common tools agents use:
|
|
12
|
+
- **Database tools**: Query databases, run SQL, manage data
|
|
13
|
+
- **API tools**: Call REST APIs, GraphQL endpoints, webhooks
|
|
14
|
+
- **File tools**: Read/write files, process documents
|
|
15
|
+
- **Communication tools**: Send emails, Slack messages, notifications
|
|
16
|
+
- **Cloud tools**: AWS S3, Google Cloud, Azure services
|
|
17
|
+
- **Git tools**: GitHub, GitLab operations
|
|
18
|
+
|
|
19
|
+
## Using Tools in Agents
|
|
20
|
+
|
|
21
|
+
### Basic Tool Usage in Tasks
|
|
22
|
+
|
|
23
|
+
Tasks can use MCP tools during neural (AI-powered) execution:
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
task :fetch_user_orders do |inputs|
|
|
27
|
+
# Tool usage is handled by the AI synthesis process
|
|
28
|
+
# The AI will determine appropriate tools to call based on:
|
|
29
|
+
# - Available MCP servers
|
|
30
|
+
# - Task requirements
|
|
31
|
+
# - Input/output schemas
|
|
32
|
+
|
|
33
|
+
user_id = inputs[:user_id]
|
|
34
|
+
# AI will synthesize appropriate tool calls
|
|
35
|
+
{ orders: [] } # Placeholder - actual implementation synthesized
|
|
36
|
+
end
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### MCP Tool Server Configuration
|
|
40
|
+
|
|
41
|
+
Tools are provided by MCP servers defined in your agent:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
agent "order-processor" do
|
|
45
|
+
description "Process customer orders"
|
|
46
|
+
|
|
47
|
+
mcp_server do
|
|
48
|
+
# MCP server configuration would go here
|
|
49
|
+
# See components/tool/ directory for examples
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
task :fetch_orders do |inputs|
|
|
53
|
+
# AI synthesis will use available MCP tools
|
|
54
|
+
{ orders: [] }
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Tool Categories
|
|
60
|
+
|
|
61
|
+
### MCP Tool Examples
|
|
62
|
+
|
|
63
|
+
Tools are provided by MCP servers. See `components/tool/examples/` for working examples:
|
|
64
|
+
|
|
65
|
+
```ruby
|
|
66
|
+
# Example calculator tool (from components/tool/examples/calculator.rb)
|
|
67
|
+
tool 'calculate' do
|
|
68
|
+
description 'Perform basic mathematical calculations'
|
|
69
|
+
|
|
70
|
+
parameter 'expression' do
|
|
71
|
+
type :string
|
|
72
|
+
required true
|
|
73
|
+
description 'Mathematical expression to evaluate'
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
execute do |params|
|
|
77
|
+
result = eval(params['expression']) # Note: Use safe evaluation in production
|
|
78
|
+
{ result: result }
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### HTTP/API Tools
|
|
84
|
+
|
|
85
|
+
Call external APIs and web services:
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
# REST API calls
|
|
89
|
+
execute_tool('http', 'get', {
|
|
90
|
+
url: 'https://api.example.com/users',
|
|
91
|
+
headers: { 'Authorization': 'Bearer token123' }
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
# GraphQL queries
|
|
95
|
+
execute_tool('graphql', 'query', {
|
|
96
|
+
endpoint: 'https://api.github.com/graphql',
|
|
97
|
+
query: 'query { viewer { login } }'
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
# Webhook sending
|
|
101
|
+
execute_tool('webhook', 'post', {
|
|
102
|
+
url: 'https://hooks.slack.com/webhook-url',
|
|
103
|
+
payload: { text: 'Hello from agent!' }
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### File System Tools
|
|
108
|
+
|
|
109
|
+
Read and write files:
|
|
110
|
+
|
|
111
|
+
```ruby
|
|
112
|
+
# Read files
|
|
113
|
+
execute_tool('file', 'read', {
|
|
114
|
+
path: '/data/input.json'
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
# Write files
|
|
118
|
+
execute_tool('file', 'write', {
|
|
119
|
+
path: '/output/report.txt',
|
|
120
|
+
content: 'Generated report data...'
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
# List directories
|
|
124
|
+
execute_tool('file', 'list', {
|
|
125
|
+
path: '/data',
|
|
126
|
+
pattern: '*.csv'
|
|
127
|
+
})
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Communication Tools
|
|
131
|
+
|
|
132
|
+
Send notifications and messages:
|
|
133
|
+
|
|
134
|
+
```ruby
|
|
135
|
+
# Email
|
|
136
|
+
execute_tool('email', 'send', {
|
|
137
|
+
to: 'team@company.com',
|
|
138
|
+
subject: 'Daily Report',
|
|
139
|
+
body: 'Report content...',
|
|
140
|
+
attachments: ['/tmp/report.pdf']
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
# Slack
|
|
144
|
+
execute_tool('slack', 'post_message', {
|
|
145
|
+
channel: '#alerts',
|
|
146
|
+
text: 'System alert: High CPU usage detected'
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
# SMS
|
|
150
|
+
execute_tool('sms', 'send', {
|
|
151
|
+
to: '+1234567890',
|
|
152
|
+
message: 'Alert: System down'
|
|
153
|
+
})
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Cloud Services
|
|
157
|
+
|
|
158
|
+
Interact with cloud platforms:
|
|
159
|
+
|
|
160
|
+
```ruby
|
|
161
|
+
# AWS S3
|
|
162
|
+
execute_tool('aws_s3', 'upload', {
|
|
163
|
+
bucket: 'my-bucket',
|
|
164
|
+
key: 'reports/daily.pdf',
|
|
165
|
+
file_path: '/tmp/report.pdf'
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
# Google Cloud Storage
|
|
169
|
+
execute_tool('gcs', 'download', {
|
|
170
|
+
bucket: 'data-bucket',
|
|
171
|
+
key: 'inputs/data.json',
|
|
172
|
+
destination: '/tmp/data.json'
|
|
173
|
+
})
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Development Tools
|
|
177
|
+
|
|
178
|
+
Git, CI/CD, and development workflows:
|
|
179
|
+
|
|
180
|
+
```ruby
|
|
181
|
+
# GitHub operations
|
|
182
|
+
execute_tool('github', 'create_issue', {
|
|
183
|
+
repo: 'company/project',
|
|
184
|
+
title: 'Bug detected by monitoring agent',
|
|
185
|
+
body: 'Details of the issue...',
|
|
186
|
+
labels: ['bug', 'automated']
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
# Docker
|
|
190
|
+
execute_tool('docker', 'run', {
|
|
191
|
+
image: 'nginx:latest',
|
|
192
|
+
ports: ['80:80'],
|
|
193
|
+
environment: { ENV: 'production' }
|
|
194
|
+
})
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Tool Configuration
|
|
198
|
+
|
|
199
|
+
### Automatic Tool Discovery
|
|
200
|
+
|
|
201
|
+
When you create an agent, Language Operator automatically:
|
|
202
|
+
1. Analyzes your agent description
|
|
203
|
+
2. Identifies needed tools
|
|
204
|
+
3. Configures appropriate tool access
|
|
205
|
+
4. Sets up authentication and permissions
|
|
206
|
+
|
|
207
|
+
### Manual Tool Configuration
|
|
208
|
+
|
|
209
|
+
For advanced use cases, you can specify tool requirements:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# During agent creation
|
|
213
|
+
aictl agent create my-agent \
|
|
214
|
+
--tools database,slack,github \
|
|
215
|
+
--database-url postgres://... \
|
|
216
|
+
--slack-token xoxb-... \
|
|
217
|
+
--github-token ghp-...
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Environment Variables
|
|
221
|
+
|
|
222
|
+
Tools often use environment variables for configuration:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Database connections
|
|
226
|
+
export DATABASE_URL="postgresql://user:pass@host:5432/db"
|
|
227
|
+
export REDIS_URL="redis://localhost:6379"
|
|
228
|
+
|
|
229
|
+
# API tokens
|
|
230
|
+
export SLACK_TOKEN="xoxb-your-slack-token"
|
|
231
|
+
export GITHUB_TOKEN="ghp_your-github-token"
|
|
232
|
+
export OPENAI_API_KEY="sk-your-openai-key"
|
|
233
|
+
|
|
234
|
+
# AWS credentials
|
|
235
|
+
export AWS_ACCESS_KEY_ID="AKIA..."
|
|
236
|
+
export AWS_SECRET_ACCESS_KEY="..."
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Tool Discovery
|
|
240
|
+
|
|
241
|
+
Language Operator provides basic tool management commands:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Deploy a tool server to your cluster
|
|
245
|
+
aictl tool deploy ./path/to/tool
|
|
246
|
+
|
|
247
|
+
# Test tool connectivity
|
|
248
|
+
aictl tool test my-tool
|
|
249
|
+
|
|
250
|
+
# View tool logs
|
|
251
|
+
aictl tool logs my-tool
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
For available tools, check the `components/tool/examples/` directory in the repository.
|
|
255
|
+
|
|
256
|
+
## Error Handling
|
|
257
|
+
|
|
258
|
+
### Tool Failures
|
|
259
|
+
|
|
260
|
+
Agents handle tool failures gracefully:
|
|
261
|
+
|
|
262
|
+
```ruby
|
|
263
|
+
task :fetch_data_with_retry,
|
|
264
|
+
inputs: { source: 'string' },
|
|
265
|
+
outputs: { data: 'array' }
|
|
266
|
+
do |inputs|
|
|
267
|
+
retries = 3
|
|
268
|
+
|
|
269
|
+
begin
|
|
270
|
+
data = execute_tool('api', 'fetch', { url: inputs[:source] })
|
|
271
|
+
{ data: data }
|
|
272
|
+
rescue => e
|
|
273
|
+
retries -= 1
|
|
274
|
+
if retries > 0
|
|
275
|
+
sleep(2)
|
|
276
|
+
retry
|
|
277
|
+
else
|
|
278
|
+
{ data: [], error: "Failed after 3 attempts: #{e.message}" }
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Validation
|
|
285
|
+
|
|
286
|
+
Tools validate parameters automatically:
|
|
287
|
+
|
|
288
|
+
```ruby
|
|
289
|
+
# This will fail validation if email format is invalid
|
|
290
|
+
execute_tool('email', 'send', {
|
|
291
|
+
to: 'invalid-email', # ❌ Will raise validation error
|
|
292
|
+
subject: 'Test',
|
|
293
|
+
body: 'Hello'
|
|
294
|
+
})
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Custom Tools
|
|
298
|
+
|
|
299
|
+
### Creating Tool Servers
|
|
300
|
+
|
|
301
|
+
You can create custom tool servers for specialized functionality:
|
|
302
|
+
|
|
303
|
+
```ruby
|
|
304
|
+
# In your custom tool server (see components/tool/examples/)
|
|
305
|
+
tool 'custom_analyzer' do
|
|
306
|
+
description 'Analyzes custom data format'
|
|
307
|
+
|
|
308
|
+
parameter 'data' do
|
|
309
|
+
type :string
|
|
310
|
+
required true
|
|
311
|
+
description 'Raw data to analyze'
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
execute do |params|
|
|
315
|
+
# Your custom analysis logic
|
|
316
|
+
result = analyze_custom_format(params['data'])
|
|
317
|
+
{ analysis: result }
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Registering Custom Tools
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
# Deploy your custom tool server
|
|
326
|
+
aictl tool deploy ./my-custom-tools
|
|
327
|
+
|
|
328
|
+
# Register with Language Operator
|
|
329
|
+
aictl tool register my-custom-tools \
|
|
330
|
+
--endpoint https://my-tools.company.com
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Security and Permissions
|
|
334
|
+
|
|
335
|
+
### Tool Access Control
|
|
336
|
+
|
|
337
|
+
Language Operator provides fine-grained access control:
|
|
338
|
+
|
|
339
|
+
```yaml
|
|
340
|
+
# Agent tool permissions
|
|
341
|
+
apiVersion: languageoperator.io/v1alpha1
|
|
342
|
+
kind: Agent
|
|
343
|
+
metadata:
|
|
344
|
+
name: my-agent
|
|
345
|
+
spec:
|
|
346
|
+
tools:
|
|
347
|
+
database:
|
|
348
|
+
permissions: [read]
|
|
349
|
+
tables: [users, orders]
|
|
350
|
+
slack:
|
|
351
|
+
permissions: [post_message]
|
|
352
|
+
channels: [alerts, notifications]
|
|
353
|
+
github:
|
|
354
|
+
permissions: [read_issues, create_comments]
|
|
355
|
+
repositories: [company/main-repo]
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Credential Management
|
|
359
|
+
|
|
360
|
+
Sensitive credentials are managed securely:
|
|
361
|
+
- Stored as Kubernetes secrets
|
|
362
|
+
- Automatically injected as environment variables
|
|
363
|
+
- Never logged or exposed in agent code
|
|
364
|
+
- Rotated automatically when possible
|
|
365
|
+
|
|
366
|
+
### Audit Logging
|
|
367
|
+
|
|
368
|
+
All tool usage is logged for security and debugging:
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
# View tool usage logs
|
|
372
|
+
aictl agent logs my-agent --tools-only
|
|
373
|
+
|
|
374
|
+
# Audit specific tool usage
|
|
375
|
+
aictl tool audit database --agent my-agent --since 24h
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Performance Optimization
|
|
379
|
+
|
|
380
|
+
### Tool Caching
|
|
381
|
+
|
|
382
|
+
Language Operator automatically caches tool results when appropriate:
|
|
383
|
+
|
|
384
|
+
```ruby
|
|
385
|
+
# This result may be cached for 5 minutes
|
|
386
|
+
execute_tool('external_api', 'fetch_static_data', {
|
|
387
|
+
cache_ttl: 300
|
|
388
|
+
})
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Parallel Tool Execution
|
|
392
|
+
|
|
393
|
+
Execute multiple tools in parallel for better performance:
|
|
394
|
+
|
|
395
|
+
```ruby
|
|
396
|
+
main do |inputs|
|
|
397
|
+
# Run multiple tool calls in parallel
|
|
398
|
+
results = execute_parallel([
|
|
399
|
+
{ tool: 'database', action: 'fetch_users' },
|
|
400
|
+
{ tool: 'api', action: 'fetch_external_data' },
|
|
401
|
+
{ tool: 'redis', action: 'get_cache', params: { key: 'stats' } }
|
|
402
|
+
])
|
|
403
|
+
|
|
404
|
+
# Process combined results
|
|
405
|
+
process_combined_data(results)
|
|
406
|
+
end
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
## Best Practices
|
|
410
|
+
|
|
411
|
+
### Tool Selection
|
|
412
|
+
- Use specific tools rather than generic HTTP calls when available
|
|
413
|
+
- Prefer official tool implementations over custom ones
|
|
414
|
+
- Choose tools with good error handling and retry logic
|
|
415
|
+
|
|
416
|
+
### Error Handling
|
|
417
|
+
- Always handle tool failures gracefully
|
|
418
|
+
- Implement appropriate retry logic for transient failures
|
|
419
|
+
- Provide meaningful error messages for debugging
|
|
420
|
+
|
|
421
|
+
### Performance
|
|
422
|
+
- Cache expensive tool results when appropriate
|
|
423
|
+
- Use parallel execution for independent tool calls
|
|
424
|
+
- Monitor tool response times and optimize slow operations
|
|
425
|
+
|
|
426
|
+
### Security
|
|
427
|
+
- Use environment variables for sensitive configuration
|
|
428
|
+
- Follow principle of least privilege for tool permissions
|
|
429
|
+
- Regularly audit tool usage and access patterns
|
|
430
|
+
|
|
431
|
+
## Troubleshooting
|
|
432
|
+
|
|
433
|
+
### Tool Connection Issues
|
|
434
|
+
|
|
435
|
+
```bash
|
|
436
|
+
# Test tool connectivity
|
|
437
|
+
aictl tool test database
|
|
438
|
+
|
|
439
|
+
# Check tool configuration
|
|
440
|
+
aictl tool config database
|
|
441
|
+
|
|
442
|
+
# View tool logs
|
|
443
|
+
aictl tool logs database --since 1h
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Common Issues
|
|
447
|
+
|
|
448
|
+
**Tool not found**: Check tool registration and spelling
|
|
449
|
+
**Authentication failed**: Verify credentials and permissions
|
|
450
|
+
**Timeout errors**: Check network connectivity and tool server status
|
|
451
|
+
**Validation errors**: Review parameter types and required fields
|
|
452
|
+
|
|
453
|
+
## Next Steps
|
|
454
|
+
|
|
455
|
+
- **[Agent Configuration](agent-configuration.md)** - Configure tool access and permissions
|
|
456
|
+
- **[Best Practices](best-practices.md)** - Patterns for reliable tool usage
|
|
457
|
+
- **[Custom Tools](custom-tools.md)** - Creating your own tool servers
|