๊ฐ€์ž… ํ›„ ์ดˆ๋Œ€ ๋งํฌ๋ฅผ ๊ณต์œ ํ•˜๋ฉด ๋™์˜์ƒ ์žฌ์ƒ ๋ฐ ์ดˆ๋Œ€ ๋ณด์ƒ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
๊ฐ€์ž… May 2026
258 ํŒ”๋กœ์ž‰ ์ค‘    220 ํŒฌ
# Practices for Embedding AI Agents in Software # Deadline & Budget Cascade ๐ŸŽฏ The Hook Your agent spawns sub-tasks recursively, and suddenly the bill hits $50. "Billing accidents" happen when no node knows the global budget. There is a structural fix. ๐Ÿ”ฅ The Problem As an agent's call tree deepens, individual nodes have no idea how much resource they are allowed to consume. Expensive LLM calls stack up recursively, and plan-reflect loops retry endlessly even when improvement is unlikely. The root cause is that global budget and deadline constraints never reach local decision points. ๐Ÿ’ก The Pattern Deadline & Budget Cascade sets a deadline (absolute timestamp) and budget (tokens, cost, step count) at the root of the call tree, then subtracts consumed resources before passing the remainder to each child task. Every leaf node knows exactly how much time and cost it has left, and can switch to degraded mode, return partial results, or halt before exhausting the budget. Deadlines are propagated as absolute timestamps, not relative seconds, to prevent drift accumulation across hops. โœ… When to Use Use when: - The agent recursively spawns sub-tasks or delegates to parallel workers - Per-request cost is unpredictable, risking billing accidents without caps - SLAs or time expectations exist for task completion Don't use when: - The call tree is flat (single level) and a simple timeout suffices - Batch jobs with no time pressure and predictable, fixed costs โš ๏ธ Pitfalls - Pass deadlines as absolute timestamps, not relative seconds. Relative values accumulate drift at each propagation hop (same principle as gRPC's grpc-timeout header) - Reserve a margin (10-20% of root budget) at the parent level. Aggregating and formatting child results requires its own time and cost - Decide exhaustion behavior upfront: partial result return, human escalation, or model degradation. Simply throwing a timeout exception destroys the user experience ๐Ÿ”ง Implementation Approach - Define a BudgetContext structure carrying deadline_at (absolute timestamp), max_cost_usd, max_steps, max_tokens, depth, and max_depth. Initialize it at the root when the user request arrives - On each child delegation, compute the child budget by multiplying the remainder by a fraction, subtracting a propagation margin (roughly 2s). Reserve 10-20% of the root budget at the parent for result aggregation - Every node checks remaining time, cost, and steps before proceeding, and switches to degraded mode, partial result return, or halt before the budget is exhausted - For parallel child tasks, note that cost is the sum across children while the deadline is governed by the slowest child. Distribute budget fractions by importance and estimated cost - Emit budget consumption ratio (consumed/limit) as a metric and trigger alerts when it crosses predefined thresholds #AIAgents# #SoftwareArchitecture#
๋” ๋ณด๊ธฐ