Coding agents feel slow when every run_tests or search_repo tool pays a multi-second Lambda cold start. Provisioned concurrency (warm pools) fixed to engineering hours and on-call windows cuts p95 tool latency without burning full peak capacity at 3 a.m.
⚡ TL;DR: Put agent-tool Lambdas behind aliases with scheduled provisioned concurrency for working hours + on-call; keep off-hours at near-zero. Measure cold-start vs warm p95; right-size memory. Pair with LLM Coding Agents on AWS and Lambda Plus Bedrock streaming.
Schedule warm pools to human rhythms
// cdk/agent-tools.ts
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as appscaling from "aws-cdk-lib/aws-applicationautoscaling";
const fn = new lambda.Function(this, "AgentToolSearch", {
runtime: lambda.Runtime.NODEJS_20_X,
memorySize: 1024,
timeout: Duration.seconds(30),
// lean init — see cold-start hygiene below
});
const alias = fn.addAlias("live");
const target = alias.addAutoScaling({ minCapacity: 0, maxCapacity: 20 });
// ✅ Weekday eng hours Asia/Kolkata 09:00–21:00 ≈ 03:30–15:30 UTC
target.scaleOnSchedule("workday-on", {
schedule: appscaling.Schedule.cron({ minute: "30", hour: "3", weekDay: "MON-FRI" }),
minCapacity: 5,
});
target.scaleOnSchedule("workday-off", {
schedule: appscaling.Schedule.cron({ minute: "30", hour: "15", weekDay: "MON-FRI" }),
minCapacity: 0,
});
Add a second schedule for on-call weekends at minCapacity 1–2 — not zero if sev tools must stay snappy.
Cold-start hygiene still matters
Warm pools amplify bad init costs into steady spend. Keep init lean:
// ❌ Eager heavy imports in top-level
import { HugeSdk } from "huge-sdk";
const client = new HugeSdk();
// ✅ Lazy inside handler paths you actually hit
export async function handler(event: Event) {
const { HugeSdk } = await import("huge-sdk");
const client = new HugeSdk();
return client.search(event.query);
}
SLOs for agent tools
| Tool | Warm p95 target | Notes |
|---|---|---|
search_repo |
< 300 ms | Cache symbol index in /tmp carefully |
run_tests |
< 2 s to start | Streaming logs after |
apply_patch |
< 200 ms | CPU small |
bedrock_proxy |
TTFT budget separate | See streaming guide |
Instrument with Powertools / ADOT; alert when cold-start fraction > 5% during scheduled warm windows.
Cost guardrails
# illustrative — cap account spend on provisioned concurrency
aws cloudwatch put-metric-alarm \
--alarm-name agent-pcu-spend \
--metric-name ProvisionedConcurrencyUtilization \
--threshold 0.2 \
--comparison-operator LessThanThreshold \
# low utilization → shrink schedule
❌ Provisioning 50 all day “just in case.” Start from concurrent tool QPS during peak pairing hours × headroom 1.5.
Closing checklist
✅ Dos
– ✅ Alias + scheduled provisioned concurrency for work + on-call
– ✅ Lean init; lazy imports
– ✅ Track cold-start fraction and tool p95
– ✅ Scale to zero (or tiny) off-hours
– ✅ Separate warm pools per critical tool if noisy-neighbor
❌ Don’ts
– ❌ Don’t warm unused preview aliases
– ❌ Don’t hide bloated bundles behind PCU spend
– ❌ Don’t skip concurrency limits / reserved concurrency bulkheads
– ❌ Don’t forget timezone math for global teams
Related reading
- LLM Coding Agents on AWS: Safe Tool Sandboxes with Lambda
- Lambda Plus Bedrock: Stream Tokens Without API Gateway Caps
- Secure AI Sandboxes: Ephemeral ECS Tasks for Agent Tool Execution
- OpenTelemetry for LLMs: Trace Prompt Latency Across Microservices
Last updated on September 11, 2026
Discover more from CheatCoders
Subscribe to get the latest posts sent to your email.

Pingback: Lambda X-Ray Sampling: Cost Versus Debuggability During Incidents - CheatCoders
Pingback: Python Prefork Pitfalls: Inherited Sockets, RNGs, and Pool Re-Init - CheatCoders
Pingback: Python Lambda Warm Strategies: Lean Imports Plus Provisioned Concurrency - CheatCoders
Pingback: Lambda Telemetry API Extensions: Custom Samplers Under Five Milliseconds - CheatCoders