Skip to content

feat: add system_prompt and allowed_tools to kernel contract#1

Merged
broomva merged 3 commits intomainfrom
feat/skill-system-liquid-prompt
Mar 20, 2026
Merged

feat: add system_prompt and allowed_tools to kernel contract#1
broomva merged 3 commits intomainfrom
feat/skill-system-liquid-prompt

Conversation

@broomva
Copy link
Owner

@broomva broomva commented Mar 20, 2026

Summary

  • Adds system_prompt: Option<String> to ModelCompletionRequest for liquid prompt injection
  • Adds allowed_tools: Option<Vec<String>> to ModelCompletionRequest for skill-based tool filtering
  • Extends TickInput with both fields, threaded through to provider calls

Part of the Arcan Skill System Evolution (6-phase implementation). This is the protocol-level foundation that enables skills to inject context and restrict tools.

Test plan

  • All 102 aiOS workspace tests pass
  • Backward compatible (new fields are Option with serde(default))
  • Arcan adapter consumes both fields correctly

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added system prompt configuration for language model requests
    • Added tool filtering to restrict available tools
    • Added mode change event tracking with transition reasons
    • Enhanced observability with distributed tracing integration and trace correlation
    • Added operational metrics for mode transitions and tool execution tracking

broomva and others added 3 commits March 20, 2026 11:49
Wire vigil phase spans, budget metrics, mode transition metrics, and
trace context dual-write into the canonical KernelRuntime tick loop:

- Phase spans: each loop phase (Perceive, Deliberate, Gate, Execute,
  Commit, Reflect, Sleep) is wrapped in a vigil::spans::phase_span
- Budget metrics: record token/cost budgets in Perceive and Reflect
- Mode transitions: detect and record via GenAiMetrics in Reflect
- Trace context: write OTel trace_id/span_id into every EventRecord
  before appending to the event store (dual-write)
- Add Commit phase emission before StepFinished/RunFinished events

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add per-tick tool call and file mutation tracking in tick_on_branch.
Emit ModeChanged events when OperatingMode transitions occur after
tool execution (both success and error paths). Add operating_mode_str
helper for Vigil metrics integration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extend the aiOS kernel contract to support skill-aware agent interactions:
- system_prompt on ModelCompletionRequest for liquid prompt injection
- allowed_tools on ModelCompletionRequest for skill-based tool filtering
- system_prompt and allowed_tools on TickInput, threaded through to provider

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

A new vigil workspace dependency is introduced for observability, and the kernel/runtime gain support for system prompts and allowed tools filtering in LLM requests. The runtime adds mode change tracking with event emission and enhanced observability through OpenTelemetry tracing and metrics recording.

Changes

Cohort / File(s) Summary
Dependency Management
Cargo.toml, crates/aios-runtime/Cargo.toml
Added workspace dependency for vigil, and introduced tracing-opentelemetry (0.30) and opentelemetry (0.29) for enhanced observability.
Protocol Updates
crates/aios-protocol/src/ports.rs
Extended ModelCompletionRequest with optional system_prompt and allowed_tools fields for LLM request customization.
Kernel Integration
crates/aios-kernel/src/lib.rs
Updated TickInput construction in tick_on_branch to explicitly populate system_prompt and allowed_tools fields as None.
Runtime Core
crates/aios-runtime/src/lib.rs
Enhanced TickInput struct with system_prompt and allowed_tools fields; threaded these into LLM requests. Added per-tick counters, mode change tracking with event emission, metrics recording for GenAI budget and mode transitions, OpenTelemetry span instrumentation, and trace context embedding in event records.

Sequence Diagram

sequenceDiagram
    participant Kernel as AiosKernel
    participant Runtime as AiosRuntime
    participant LLM as LLM Model
    
    Kernel->>Runtime: tick_on_branch with TickInput<br/>(system_prompt, allowed_tools)
    Runtime->>Runtime: Perceive: Record GenAI<br/>budget metrics
    Runtime->>Runtime: Reflect: Create ModelCompletionRequest<br/>populate system_prompt, allowed_tools
    Runtime->>LLM: Send request with custom<br/>system prompt & filtered tools
    LLM-->>Runtime: Model completion response
    Runtime->>Runtime: Record mode transition<br/>& emit EventKind::ModeChanged
    Runtime->>Runtime: Write trace context to<br/>event records (OTel integration)
    Runtime-->>Kernel: Return tick result with<br/>events & observability data
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Hop, hop! A new vigil keeps watch,
System prompts whisper, tools carefully notched,
OpenTelemetry traces the way,
Mode changes gleam in telemetry's display,
Events now carry their story so bright,
Every tick traced by observability's light!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely summarizes the primary change: adding system_prompt and allowed_tools fields to the kernel contract (ModelCompletionRequest and TickInput).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/skill-system-liquid-prompt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@broomva broomva merged commit d19be40 into main Mar 20, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant