Token-Aware Context Router for Agent Workloads

作者:promptpacks发布日期:2026-09-21观看:28

位于智能体与 MCP 服务集群之间的上下文路由器,按意图分类与价值预估挑选工具、装配压缩上下文,并在 token 与延迟预算内输出可解释计划。

01/ 01

You are an ML-infrastructure engineer. Build a context router that sits between coding agents and [INSERT NUMBER] MCP servers, selecting tools and assembling context per task under a token budget. Inputs are a user intent plus session metadata; outputs are a ranked, explainable tool plan and a ready-to-use context bundle, served within [INSERT LATENCY SLA]. Work in modules with approval gates between them. Module 1 Architecture: classify -> retrieve -> plan -> compress pipeline, feedback loop, and mermaid diagrams for cache-hit and cache-miss paths. Module 2 Data model: routing decisions, server capabilities, budgets, outcome feedback signals, and replayable request snapshots. Module 3 Intent layer: task classifier for [INSERT TASK TAXONOMY], confidence calibration, and a cheap-model/strong-model cascade. Module 4 Retrieval: semantic tool index, repository and documentation indexes, and merged ranking of MCP resources into one candidate list. Module 5 Planning: emit ordered tool-call plans, estimate value-of-information per call, and stop when marginal value drops below threshold. Module 6 Budgeting: token and latency budgets by task class, prompt-cache-aware ordering, and graceful degradation when limits are tight. Module 7 Compression: deduplication, snippet selection, schema projection, and summarization that preserves identifiers and API contracts. Module 8 Policy: per-tenant routing rules, data-residency constraints, and forced on-prem routing for [INSERT DATA CLASSIFICATION]. Module 9 API: a single streaming endpoint returning plan deltas and context bundles, plus an MCP-tool facade for legacy agents. Module 10 Feedback: outcome labels (success, user edits, retries), online-learning hooks, and shadow-mode evaluation. Module 11 Testing: golden intent set, plan-quality metrics, A/B experiment framework, and regression tests replaying recorded traffic. Module 12 Deployment: canary routing, per-tenant overrides, dashboards for hit rate and budget utilization, and an operator runbook. Include failure semantics: when the router is uncertain, it must surface alternatives instead of silently picking a high-risk tool. Ask five opening questions, notably peak queries per second and the maximum acceptable planning latency. ================

自动翻译

自动翻译中…

🔥热搜词

评论0

登录后参与评论

还没有评论,来抢沙发吧