Interview Bank
328 questions total; 1 shown with current filters.
CourseAllFrom Frontend Engineer to Agent Engineer in 30 DaysPrompt Engineering From Scratch in 5 DaysMastering Claude: From Conversation to Claude Code in 5 DaysMastering Codex and the OpenAI Agents SDK in 5 DaysMCP in 7 Days: Wire Tools Into Any AgentAgent Skills in 7 Days: Turn Experience Into Reusable CapabilityContext Engineering in 5 DaysRAG in 14 Days: From Retrieval to Trustworthy AnswersBuild an AI Short-Drama Production Pipeline With Agents in 14 Days
Mastering Claude: From Conversation to Claude Code in 5 Days
D5 Automation and Scale: Headless -p Into CI, Parallel Sessions and Worktrees, Writer/Reviewer Dual Sessions, Adversarial Review, Common Failure Modes; a 20-Line Minimal Agent SDK Agent
When do you use the Claude Agent SDK versus the Messages API directly, and how do both relate to claude -p?Agent SDK 和直接调 Messages API 各适合什么场景?它们和 claude -p 是什么关系?
Common in ChinaCommon overseasBasic#agent-sdk#messages-apiHow to reason about it · think before answering
- This tests layered understanding: all three entry points share one model; the difference is who supplies the loop and the tools. 'The SDK is higher level' says nothing.
- Messages API (@anthropic-ai/sdk / anthropic): one request, one response; you define tools, write the loop, manage context. Fits Q&A, extraction, classification, structured output, cited document Q&A, and custom agents where you want full control of the loop.
- Agent SDK (@anthropic-ai/claude-agent-sdk / claude-agent-sdk): Claude Code packaged as a library — built-in Read/Edit/Bash/Glob/Grep, the full agent loop, context management, permissions, hooks, subagents, sessions. You pass a task and options (allowedTools, permissionMode, maxTurns, systemPrompt) and it works in the filesystem. Fits embedding a code-editing agent in your own program.
- claude -p: the CLI form of the same Claude Code capabilities, for shell scripts and CI; the Agent SDK is its library form and the docs present them together. One-line rule: model call → API; filesystem agent → Agent SDK; quick scripted call → -p.
- Production nuance: with the Agent SDK you still own deployment (it supplies the harness, not hosting); auth is ANTHROPIC_API_KEY, and claude.ai subscription login can't be offered to third-party products. Follow-up: is the Agent SDK the same as the Messages API tool runner? No — the tool runner loops over tools you define and has no built-in file tools.
分析过程 · 先想清楚再作答
- 这题考的是分层认知:三个入口底下是同一个模型,差别在于「谁提供循环和工具」。答成「SDK 更高级」没有信息量。
- Messages API(@anthropic-ai/sdk / anthropic):一次请求一次响应,工具由你定义、循环由你写、上下文由你管。适合问答、抽取、分类、结构化输出、带引用的文档问答,以及你想完全掌控循环的自定义 Agent。
- Agent SDK(@anthropic-ai/claude-agent-sdk / claude-agent-sdk):把 Claude Code 打包成库——内置 Read / Edit / Bash / Glob / Grep 等工具、完整的 agent 循环、上下文管理、权限系统、hooks、subagent、会话。你给一句任务和一组选项(allowedTools、permissionMode、maxTurns、systemPrompt),它在文件系统里干活。适合「在自己的程序里嵌一个会改代码的 agent」。
- claude -p:同一套 Claude Code 能力的命令行形态,适合 shell 脚本与 CI;Agent SDK 就是它的库形态,官方文档把两者放在同一页讲。判据一句话:要模型调用用 API,要文件系统里的 agent 用 Agent SDK,只想在脚本里调一下用 -p。
- 生产视角:Agent SDK 的部署仍是你自己的(它只提供循环,不提供托管),密钥走 ANTHROPIC_API_KEY,不能复用 claude.ai 的订阅登录给第三方产品。可预期的追问:Agent SDK 和 Messages API 里的 tool runner 是不是一回事?不是——tool runner 只帮你跑「你自己定义的工具」的循环,没有内置文件工具。
Key points
- Messages API: request/response, you write tools and the loop; for Q&A, extraction, structured output, custom agents
- Agent SDK: Claude Code as a library with built-in file/Bash tools, loop, permissions, hooks; for embedding a code-editing agent
- claude -p is the CLI form of the same capabilities, for scripts and CI
- You still own deployment; auth via ANTHROPIC_API_KEY; the tool runner is not the Agent SDK
答题要点
- Messages API:一问一答,工具与循环自己写;适合问答、抽取、结构化输出、自定义 Agent
- Agent SDK:Claude Code 的库形态,内置文件与 Bash 工具、循环、权限、hooks;适合嵌入会改代码的 agent
- claude -p 是同一能力的命令行形态,适合脚本与 CI
- 部署仍归自己,认证用 ANTHROPIC_API_KEY;tool runner 不是 Agent SDK