Skip to content

Fleshed out LLM Proxy - #63

Closed
Saaketh0 wants to merge 1 commit into
llm_proxyfrom
feature/llm-proxy-telemetry
Closed

Fleshed out LLM Proxy#63
Saaketh0 wants to merge 1 commit into
llm_proxyfrom
feature/llm-proxy-telemetry

Conversation

@Saaketh0

@Saaketh0 Saaketh0 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator
  • Added telemetry for bedrock
  • Added proxy for ventis
  • moved folder inside ventis
  • every local controller on start would start this separate process

@Saaketh0
Saaketh0 requested a review from iidsample September 2, 2026 00:08
@Saaketh0 Saaketh0 self-assigned this Sep 2, 2026
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 5422877e-99c4-44eb-9e17-54a033fc58e0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@Saaketh0
Saaketh0 force-pushed the feature/llm-proxy-telemetry branch from 091f29d to 6ae6d83 Compare September 2, 2026 00:09
…cture

Implements automatic LLM telemetry capture with zero agent code changes.

## Architecture
- Distributed proxy: One per container, auto-starts on port 8081
- boto3 hook: Injects X-Ventis-Future-Id header from thread-local context
- Token extraction: Automatic parsing of Bedrock responses
- Redis persistence: All 7 metrics written to future:<id> keys

## Key Components
- ventis/llm_proxy/: Complete proxy package (app, hooks, providers)
- ventis/controller/local_controller.py: Auto-starts proxy subprocess
- ventis/controller/utils/process_supervisor.py: Subprocess management
- ventis/stub_generator.py: Copies llm_proxy with full package structure

## Metrics Captured (Bedrock only)
- model: Full model ID from request path
- input_token_count, output_token_count, token_count
- input_cache_tokens (cache reads)
- input_cache_write_tokens (cache writes)
- errors: HTTP status >= 400

## Key Fixes
- Package structure: llm_proxy copied as ventis/llm_proxy/ to preserve imports
- Infinite loop prevention: Proxy's boto3 client uses explicit AWS endpoint
- Hooks initialization: Import hooks inside proxy_request() to get configured instance
- Flask header normalization: Handle X-Ventis-Future-Id (Title-Case)
- Dependencies: Added flask and requests to BASE_AGENT_REQUIREMENTS

## Agent Changes
Agents use standard boto3 - zero telemetry code needed:
- examples/portfolio/agents/advisor_agent.py: Removed ventis.llm imports
- examples/portfolio/agents/intent_agent.py: Removed ventis.llm imports
- examples/text2sql/agents/vllm_agent.py: Removed ventis.llm imports

## Removed
- ventis/llm/: Old bedrock wrapper (deprecated in favor of proxy)
- Planning docs: Consolidated into llm_proxy/README.md

## Testing
Verified end-to-end on EC2:
- LLM calls succeed through proxy
- Token extraction works (inputTokens, outputTokens, cache tokens)
- Redis writes confirmed with all 7 fields
- Environment: boto3 + AWS_ENDPOINT_URL_BEDROCK_RUNTIME auto-routing

## Scope
Bedrock-only for now. OpenAI/Anthropic use different SDKs (not boto3),
would need separate hooks in their HTTP clients.

Achieves complete parity with old ventis/llm/bedrock.py telemetry.
@Saaketh0

Saaketh0 commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

#73 Having all of this code, closing this PR

@Saaketh0 Saaketh0 closed this Sep 5, 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