QuotaCheap Playbook

Claude Agent SDK overview: dùng Claude Code như library để build production agents

Tìm hiểu claude agent sdk overview: dùng claude code như library để build production agents theo Claude Code docs: Python, TypeScript, custom tools, cost t…

Agent SDK overview nói SDK cho phép build AI agents autonomously read files, run commands, search web, edit code và dùng cùng tools, agent loop, context management như Claude Code; SDK có Python và TypeScript packages.

Bài Claude Agent SDK Playbook: Agent SDK overview nói SDK cho phép build AI agents autonomously read files, run commands, search web, edit code và dùng cùng tools, agent loop, context management như Claude Code; SDK có Python và TypeScript packages. Bài viết bám documentation, tập trung production workflow, tools, permissions, cost và observability.

Claude Agent SDK overview: dùng Claude Code như library để build production agents Agent SDK overview nói SDK cho phép build AI agents autonomously read files, run commands, search web, edit code và dùng cùng tools, agent loop, context management như Claude Code; SDK có Python và TypeScript packages.

Điều docs xác nhận Agent SDK overview nói SDK cho phép build AI agents autonomously read files, run commands, search web, edit code và dùng cùng tools, agent loop, context management như Claude Code; SDK có Python và TypeScript packages.

SDK khác với dùng Claude Code tương tác trong terminal.

Ở terminal, developer dẫn dắt conversation.

Với SDK, bạn nhúng agent loop vào Python hoặc TypeScript app, truyền options, đọc stream message, cấp tool, cấu hình permissions và quan sát usage.

Vì vậy bài viết phải nói bằng ngôn ngữ production engineering: interface, trust boundary, retry, telemetry, cost, test harness và failure mode.

Khi nào nên dùng Agent SDK Dùng SDK khi agent là một sản phẩm hoặc workflow lặp lại: bug fixing bot, repo reviewer, internal assistant, research worker, code migration helper, support triage tool hoặc automation chạy theo event.

Không cần SDK nếu bạn chỉ muốn hỏi repo vài câu hoặc sửa bug thủ công; Claude Code interactive đủ nhanh và ít overhead hơn.

SDK có giá trị khi bạn cần điều khiển bằng code: truyền prompt theo template, giới hạn tools, chạy trong folder xác định, đọc structured stream, tích hợp với queue, lưu audit log, hoặc expose agent workflow qua UI nội bộ.

Nhưng mỗi quyền bạn cấp cho agent phải có lý do.

Built in tools có thể đọc file, chạy command và edit code; custom tools có thể gọi API của bạn.

Đây là năng lực mạnh, không phải chatbot embed đơn giản.

Prompt mẫu cho agent workflow Prompt này không thay thế permissions, nhưng làm output dễ audit hơn.

Với SDK, output contract quan trọng vì caller thường là app hoặc queue worker, không phải người đọc transcript liên tục.

Runbook triển khai Bước một: làm quickstart nhỏ trong repo sandbox.

Bước hai: xác định tool allowlist.

Agent sửa code cần Read/Edit/Bash có giới hạn; agent research có thể chỉ cần read only.

Bước ba: chuẩn hóa output schema hoặc message parsing.

Bước bốn: thêm telemetry/cost tracking trước khi cho chạy nhiều task.

Bước năm: chạy với fixture repo hoặc branch thử nghiệm.

Không nên bắt đầu bằng production queue xử lý hàng trăm jobs.

Hãy chạy 5 10 job mẫu, xem agent fail như thế nào, rồi mới mở rộng.

Failure mode của agent thường không nằm ở “model không biết code”, mà nằm ở scope mơ hồ, tool quá rộng, verification thiếu, hoặc app không xử lý message/error đúng.

Tool và permission boundary Custom tools cần name, description, input schema và handler rõ.