Answer: Use `query()` for one-off tasks, and use `ClaudeSDKClient` for interactive applications such as chat interfaces, or when the next action depends on Claude's response. Status: Confirmed Entry: tool/claude-code/agents-and-automation/query-vs-claudesdkclient Revision: 2 Digest: sha256:ed8773518b9ea10c (changes whenever the content changes) Timeline: Created: 2026-11-13T03:02:54Z Last changed: 2026-11-16T12:05:49Z (ClaudeSDKClient recommendation: interactive applications such as chat interfaces, or when the next action depends on Claude's response → Use `ClaudeSDKClient` for interactive applications such as chat interfaces, or when the next action depends on Claude's response.) Last verified: 2026-11-20T12:17:05Z Next check: 2026-11-21T12:17:05Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of query() use case | One-off tasks | [1] | 2026-11-20 ClaudeSDKClient use case | Continuous conversations | [1] | 2026-11-20 ClaudeSDKClient recommendation | Use `ClaudeSDKClient` for interactive applications such as chat interfaces, or when the next action depends on Claude's response. | [1] | 2026-11-20 query() session behavior | Creates a new session by default | [1] | 2026-11-20 ClaudeSDKClient session behavior | Reuses same session | [1] | 2026-11-20 query() conversation | Single exchange | [1] | 2026-11-20 ClaudeSDKClient conversation | Multiple exchanges in same context | [1] | 2026-11-20 Sources: [1] Anthropic. "Agent SDK reference - Python". https://code.claude.com/docs/en/agent-sdk/python.md Role: primary. Accessed: 2026-11-20T12:17:05Z Quote: "| **Use Case** | One-off tasks | Continuous conversations |" (Supports: query() use case, ClaudeSDKClient use case) Quote: "Use `ClaudeSDKClient` for interactive applications such as chat interfaces, or when the next action depends on Claude's response." (Supports: ClaudeSDKClient recommendation) Quote: "| **Session** | Creates a new session by default | Reuses same session |" (Supports: query() session behavior, ClaudeSDKClient session behavior) Quote: "| **Conversation** | Single exchange | Multiple exchanges in same context |" (Supports: query() conversation, ClaudeSDKClient conversation) Published: 2026-11-20T03:41:08Z Snapshot SHA-256: a658fde43f021fe438986ed2b6a6e539fe2f2baa74fce42d6db51ce979b01742 (captured 2026-11-20T12:17:04Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:17:05Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:17:05Z Last attempt: 2026-11-20T12:17:05Z Notes and limitations: Extracted automatically from a single official source (section "Choosing between `query()` and `ClaudeSDKClient`"). Related: https://latestn.com/tool/claude-code/agents-and-automation/reload-plugins-running-session How do I reload or add plugins to a running Claude Code SDK session? https://latestn.com/tool/claude-code/agents-and-automation/restrict-subagent-tools How do I restrict which tools a Claude Code subagent can use? https://latestn.com/tool/claude-code/agents-and-automation/resume-across-hosts How do I resume a Claude Code SDK session across different hosts? https://latestn.com/tool/claude-code/agents-and-automation/plugin-configuration-values How do I ask the user for configuration values in a Claude Code plugin? https://latestn.com/tool/claude-code/agents-and-automation/python-recipes-cookbook Where are the Python recipes for the Claude Code Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/query-function-parameters-returns What does the Claude Code Agent SDK query() function accept and return? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-16T12:05:49Z | changed | ClaudeSDKClient recommendation: interactive applications such as chat interfaces, or when the next action depends on Claude's response → Use `ClaudeSDKClient` for interactive applications such as chat interfaces, or when the next action depends on Claude's response. | [1] 2026-11-13T03:02:54Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/agents-and-automation/query-vs-claudesdkclient/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/agents-and-automation/query-vs-claudesdkclient POST: https://latestn.com/dispute/tool/claude-code/agents-and-automation/query-vs-claudesdkclient with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/agents-and-automation/query-vs-claudesdkclient?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). When should I use query() versus ClaudeSDKClient in the Claude Code Python Agent SDK? Revision 2, last verified 2026-11-20T12:17:05Z. https://latestn.com/tool/claude-code/agents-and-automation/query-vs-claudesdkclient (accessed 2026-11-21T10:01:50Z). @misc{LatestN_tool_claude_code_agents_and_automation_query_vs_claudesdkclient_r2, title = {When should I use query() versus ClaudeSDKClient in the Claude Code Python Agent SDK?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/agents-and-automation/query-vs-claudesdkclient}}, note = {Revision 2; digest sha256:ed8773518b9ea10c; last verified 2026-11-20T12:17:05Z; accessed 2026-11-21T10:01:50Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/agents-and-automation/query-vs-claudesdkclient