Agent Skills
› serithemage/serverless-openclaw
› lambda-migration
lambda-migration
GitHub指导 Lambda 容器迁移第二阶段实施,按步骤提供目标、交付物及验证标准。涵盖镜像构建、CDK 部署、流式集成、会话管理及成本优化,强调零修改上游代码与低成本的约束。
Trigger Scenarios
用户询问 Lambda 迁移具体步骤细节
需要获取特定迁移阶段的交付物和验证标准
Install
npx skills add serithemage/serverless-openclaw --skill lambda-migration -g -y
SKILL.md
Frontmatter
{
"name": "lambda-migration",
"description": "Guides Phase 2 Lambda Container Migration steps. Pass a specific step number (2-1 through 2-5) to get the goals, deliverables, validation criteria, and detailed design for that step.",
"allowed-tools": "Read, Write, Edit, Bash, Glob, Grep",
"argument-hint": "[step-number, e.g. 2-1]"
}
Phase 2: Lambda Container Migration Guide
Step to implement: $ARGUMENTS
Implementation Procedure
- Read the detailed plan for the step in the references below
- Verify that dependent steps are completed
- Create/modify files specified in the deliverables
- Write tests first (TDD) before implementing
- Verify results according to validation criteria
- Update step status in
docs/progress.md
References
- Full migration plan with architecture and design: lambda-migration-plan.md
- OpenClaw analysis (internals, API surface, serverless blockers): openclaw-analysis.md
- Current architecture: architecture.md
- Cost constraints: cost-optimization.md
- Deployment procedures: deployment.md
Step Overview
| Step | Title | Dependencies | Key Deliverables |
|---|---|---|---|
| 2-1 | Lambda Container Image + Handler | None | Dockerfile, handler.ts, session-sync.ts |
| 2-2 | CDK LambdaAgentStack | 2-1 | lambda-agent-stack.ts, ECR, IAM |
| 2-3 | Response Streaming Integration | 2-1, 2-2 | routeMessage update, WS push, Telegram |
| 2-4 | Session Lifecycle Management | 2-1, 2-3 | S3 lifecycle, locking, compaction |
| 2-5 | Fargate Deprecation + Cost Verification | 2-1~2-4 | Feature flag, docs, cost dashboard |
Critical Constraints (Must Check Every Step)
- Zero OpenClaw code modifications — Wrapper layer only, upstream compatible
- Zero fixed costs — No resources that incur charges while idle
- No NAT Gateway — Lambda outside VPC (accesses S3 via public endpoint)
- No secrets on disk — API keys via env vars (SSM SecureString resolved at runtime)
- Backward compatible — Fargate path must remain functional as fallback
- Cost target — Total monthly cost < $1 at low usage (< 100 requests)
Key Technical Details
OpenClaw Library Import
// Use extensionAPI.js — avoids CLI/Gateway initialization
import { runEmbeddedPiAgent } from "openclaw/dist/extensionAPI.js";
Session File Path Convention
S3: s3://{bucket}/sessions/{userId}/{sessionId}.jsonl
Lambda /tmp: /tmp/.openclaw/agents/default/sessions/{sessionId}.jsonl
SessionManager Behavior
SessionManager.open(path)→ callsloadEntriesFromFile(path)- File not found → returns empty array (no error)
- Uses sync fs:
readFileSync,appendFileSync,writeFileSync - All operations work on Lambda
/tmp
Config Initialization
// HOME=/tmp → OpenClaw reads /tmp/.openclaw/openclaw.json
process.env.HOME = '/tmp';
// Minimal config (no gateway server needed)
{ "gateway": { "mode": "local" } }
Post-Validation Tasks
After implementation of each step:
- Update step status in
docs/progress.md - Check if
docs/architecture.mdneeds updating - Run full test suite:
npm run test && npm run test:e2e
Version History
- 504300d Current 2026-07-25 09:02


