Skip to content

feat: usage limits, tool timeout, structured output validation, and OTel instrumentation#40

Merged
SecBear merged 3 commits intomainfrom
feat/pydantic-features
Feb 24, 2026
Merged

feat: usage limits, tool timeout, structured output validation, and OTel instrumentation#40
SecBear merged 3 commits intomainfrom
feat/pydantic-features

Conversation

@SecBear
Copy link
Owner

@SecBear SecBear commented Feb 24, 2026

Summary

Four Pydantic AI-inspired features implemented as independent building blocks, following neuron's "serde, not serde_json" philosophy:

  • UsageLimits — Token budget enforcement (request, tool call, input/output/total token limits) checked at 3 points per iteration in both run() and run_stream() paths
  • TimeoutMiddleware — Per-tool execution timeout with default and per-tool overrides, implementing ToolMiddleware
  • StructuredOutputValidator + RetryLimitedValidator — JSON Schema validation with ToolError::ModelRetry self-correction and atomic retry counting
  • neuron-otel — New crate with OtelHook implementing ObservabilityHook using gen_ai.* GenAI semantic conventions

Bug fix included

  • Usage limit enforcement was completely missing from run_stream() — added 3 checkpoints matching run() path

Quality

  • 1042 tests passing (49 new), zero clippy warnings, zero doc warnings
  • Full streaming parity for all new features
  • Doc-audit and test-audit skills both pass all checks
  • Philosophy audit confirms all features are building blocks with no circular deps

New files

  • neuron-otel/ — new crate (leaf node, depends only on neuron-types)
  • .claude/skills/test-audit/SKILL.md — automated test coverage verification
  • docs/book/src/guides/observability.md — OTel guide

Test plan

  • cargo clippy --workspace --tests --examples -- -Dwarnings — zero warnings
  • cargo test --workspace — 1042 tests pass
  • cargo build --workspace --examples — all examples compile
  • cargo doc --workspace --no-deps — zero warnings
  • mdbook build docs/book/ — docs site builds
  • Doc-audit skill — all 7 checks pass
  • Test-audit skill — all 7 checks pass
  • Philosophy audit — no circular deps, all features are composable building blocks

🤖 Generated with Claude Code

…nd OTel instrumentation

Four Pydantic AI-inspired features implemented as independent building blocks:

- **UsageLimits** (neuron-types + neuron-loop): Token budget enforcement with
  request, tool call, input/output/total token limits. Checked at 3 points per
  loop iteration (pre-request, post-response, pre-tool-call) in both run() and
  run_stream() paths.

- **TimeoutMiddleware** (neuron-tool): Per-tool execution timeout via
  tokio::time::timeout with default and per-tool overrides. Implements
  ToolMiddleware trait.

- **StructuredOutputValidator + RetryLimitedValidator** (neuron-tool): JSON
  Schema validation returning ToolError::ModelRetry for self-correction, with
  atomic retry counting. Both implement ToolMiddleware trait.

- **neuron-otel** (new crate): OtelHook implementing ObservabilityHook with
  gen_ai.* GenAI semantic convention tracing spans. Leaf node depending only
  on neuron-types.

Also includes:
- Fix: usage limit enforcement was missing from run_stream() path
- 49 new tests (1042 total), full streaming parity
- Comprehensive doc updates across all surfaces (mdBook, READMEs, llms.txt,
  CLAUDE.md, ROADMAP.md)
- New test-audit skill for automated test coverage verification
- All clippy warnings resolved workspace-wide including tests/examples
Run cargo fmt --all and add LICENSE-MIT/LICENSE-APACHE symlinks to
neuron-otel to fix CI format and link checker failures.
…ease

Add publish.yml that triggers on GitHub release creation, parses the
release tag to determine the crate, and publishes it to crates.io with
retry logic for index propagation delays. Also register the new
neuron-otel crate in release-please config and manifest.
This was referenced Feb 24, 2026
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