Open Weights, Cloud Scale: Architecture Patterns for Faster and Cheaper Production Agents
Agents usually start as a simple harness around a single closed-model API. This architecture is convenient, but it limits control over model choice, deployment region, customization, and cost. Running open-weight models locally offers more freedom, but the most capable models demand hardware that is difficult to provision economically, and operating production GPU infrastructure introduces complexity that most teams do not want to absorb.
Managed cloud inference provides a middle path, offering open-weight model access through shared model APIs or dedicated endpoints, without requiring teams to operate the underlying GPU infrastructure. But realizing its full benefits requires more than replacing one API endpoint with another.
This talk presents four practical architecture patterns for building faster and cheaper production agents on open-weight models.
This talk is for Python developers moving agents from prototype to production. It explains four architecture patterns for reducing inference cost and task completion time for agents using managed, open-weight models, drawing on real long-context, tool-using workloads.
- Model qualification: Build a representative evaluation set, define task-specific quality and latency requirements, and select the serving configuration with the lowest measured cost per successfully completed task. Model size, throughput, generation length, retries, and failure rate are treated as parts of the same decision.
- Context design: Separate stable and volatile context, serialize prompts and tool definitions, and structure conversation history to maximize safe prefix-cache reuse. Observed cached tokens are measured, not inferred.
- Runtime routing: Route only across models that have passed the quality gate. Use task type, complexity, risk, conversation phase, and generation budget to select the fastest and most economical qualified model, with explicit fallback and escalation policies.
- Targeted adaptation: Fine-tune or distill a smaller model when the workload is repeated, measurable, and stable. Compare the fixed cost of data preparation, training, evaluation, and deployment with the recurring savings from lower latency, lower inference cost, shorter prompts, or fewer retries.
The four patterns are connected through a Python reference architecture using OpenAI-compatible endpoints, deterministic prompt construction, task evaluation, routing policies, fallbacks, and request-level telemetry. A common scorecard tracks task success, structured-output validity, latency, cached tokens, retries, and inference cost.
Attendees will learn how to choose between closed APIs, local models, and managed open inference; how to apply the four patterns in a practical order; and how to measure whether an optimization improves the cost and response time of successful task completion without reducing quality. The session is scoped to 25 minutes and uses architecture diagrams, short code examples, and a single running case rather than a live demo.
Outline (25 minutes + 5 minutes Q&A)
- Why open weights and managed cloud inference (4 minutes): Compare closed APIs, local models, self-managed serving, and managed open inference.
- Pattern 1, model qualification (4 minutes): Define quality gates and identify the optimal balance of quality, cost and latency.
- Pattern 2, context design and prefix reuse (4 minutes): Implement stable prefixes, deterministic serialization, prefix caching, and request-level cache measurement.
- Pattern 3, runtime routing (4 minutes): Select the fastest and most economical qualified model for each task, with fallback and escalation policies.
- Pattern 4, targeted adaptation (4 minutes): Evaluate when adaptation changes the inference economics enough to justify its fixed costs.
- Python reference architecture (3 minutes): Connect prompt construction, evaluation, routing, endpoints, fallbacks, and telemetry.
- Decision framework and takeaways (1 minute): Apply the patterns in order and select the appropriate deployment model.
- Token Factory and invitation (1 minute): Explore Nebius Token Factory as a managed implementation of the architecture and explain how attendees can try it.
- Q&A (5 minutes).
I am a Principal Solutions Architect at Nebius Token Factory, where I help customers build with Nebius public inference services, and optimized private endpoints - fine tuning, optimizing model serving setups, building agents and refining LLMOps and observability.
Previously I've spent 8 years helping AWS customers build and operationalize ML systems (and later, agents) using services like SageMaker and Bedrock.
I love open source! I compiled my first (FreeBSD) kernel almost 30 years ago.
Come talk with me about model inference, agent architecture and the challenges of operationalizing AI systems.