Skip to content

feat(ai): pydantic ai structured workflows, prompt caching & client-side token governance research #320

Closed

Description

@dan-petty

Context & Rationale

AI inference routing and agent execution rely on bespoke HTTP callers, manual function call parsers, and custom retry loops that are prone to schema divergence and latency spikes.

Scope & Deliverables

  • Context & Rationale*: AI inference routing and agent execution rely on bespoke HTTP callers, manual function call parsers, and custom retry loops that are prone to schema divergence and latency spikes.
  • Deep Integration & Functional Extension*: Native PydanticAI Agent workflows with dependency injection and typed tool definitions; prompt caching optimizations for Anthropic/OpenAI; client-side token-bucket rate governance; dynamic fallback cascades across LiteLLM, Portkey, LightLLM, and Ollama.
  • Code Optimization & Performance Acceleration*: Reduce prompt token billing and processing latency by up to 80% through prompt caching; eliminate JSON schema parsing failures via Pydantic v2 runtime validation; optimize streaming time-to-first-token.
  • Refactoring Potential & Legacy Elimination*: Refactor src/devops_cli/ai/agent.py, controller.py, and gateway.py to eliminate custom function calling parsers and fragile manual retry loops; adopt standardized PydanticAI streaming agents with typed tool registries.

Strategic Alignment

  • Milestone: v0.2.22 (Deep Subsystem Integration, Architectural Optimization & Extensible Refactoring)
  • Roadmap Reference: docs/ROADMAP.md

Activity

  1. added this to the v0.2.22 milestone on Sep 19, 2026
  2. added
    type/feature
    scope/ai
    priority/p0-critical
    on Sep 19, 2026
  3. added a commit that references this issue on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p0-criticalscope/aitype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions